Skip to content

Commit

Permalink
Allow to launch example-cnf without launching the test scripts (#111)
Browse files Browse the repository at this point in the history
* Allow to launch example-cnf without launching the test scripts

* Update required-annotations file

* add missed if-else entries

* Change dates

* Use a different path for trex script
  • Loading branch information
ramperher authored Jan 20, 2025
1 parent 6d2fe0e commit 2eb6d6d
Show file tree
Hide file tree
Showing 22 changed files with 81 additions and 67 deletions.
2 changes: 1 addition & 1 deletion testpmd-container-app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL := /bin/bash

DATE ?= $(shell date --utc +%Y%m%d%H%M)
SHA ?= $(shell git rev-parse --short HEAD)
VERSION ?= 0.2.15
VERSION ?= 0.2.16
REGISTRY ?= quay.io
ORG ?= rh-nfv-int
CONTAINER_CLI ?= podman
Expand Down
2 changes: 1 addition & 1 deletion testpmd-container-app/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

TAG=${TAG:-"v0.2.15"}
TAG=${TAG:-"v0.2.16"}

CLI=${CLI:="podman"}
ORG=${ORG:="rh-nfv-int"}
Expand Down
4 changes: 2 additions & 2 deletions testpmd-container-app/cnfapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ FROM quay.io/rh-nfv-int/ubi8-base-testpmd:v0.0.1
LABEL name="NFV Example CNF Application" \
maintainer="telcoci" \
vendor="fredco" \
version="v0.2.15" \
release="v0.2.15" \
version="v0.2.16" \
release="v0.2.16" \
summary="An example CNF for platform validation" \
description="An example CNF for platform validation"

Expand Down
17 changes: 14 additions & 3 deletions testpmd-container-app/cnfapp/scripts/testpmd-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -ex

echo "Running testpmd"

RUN_APP=${run_app:=1}
RUN_DEPLOYMENT=${run_deployment:=1}
REDUCED_MODE=${reduced_mode:=0}

LOG_DIR="/var/log/testpmd"
Expand Down Expand Up @@ -86,7 +86,6 @@ RXD=${rx_descriptors:=1024}
TXD=${tx_descriptors:=1024}
STATS_PERIOD=${stats_period:=1}

# modify RXD and TXD (x2)
# If reduced mode is selected:
# - Manipulate the cores to use to just use the 1st core (for console) and 2nd core with its sibling
# - Double RXD and TXD values
Expand All @@ -98,6 +97,7 @@ if [[ $REDUCED_MODE != "0" ]]; then
TXD=$((TXD*2))
fi

# Build script to run testpmd in auto-start mode
RUN="/usr/local/bin/example-cnf/run/testpmd-run"
CMD="/usr/local/bin/example-cnf/testpmd"
CMD="${CMD} -l $LCORES --in-memory $PCI --socket-mem ${SOCKET_MEM} -n ${MEMORY_CHANNELS} --proc-type auto --file-prefix pg"
Expand All @@ -108,6 +108,16 @@ CMD="${CMD} 2>&1 | tee /var/log/testpmd/app.log"
echo "${CMD}" > $RUN
chmod +x $RUN

# Build script to run testpmd in interactive mode (requires manual intervention)
RUN_INT="/usr/local/bin/example-cnf/run/testpmd-interactive"
CMD_INT="/usr/local/bin/example-cnf/testpmd"
CMD_INT="${CMD_INT} -l $LCORES --in-memory $PCI --socket-mem ${SOCKET_MEM} -n ${MEMORY_CHANNELS} --proc-type auto --file-prefix pg"
CMD_INT="${CMD_INT} --"
CMD_INT="${CMD_INT} --nb-cores=${FORWARDING_CORES} --rxq=${RXQ} --txq=${TXQ} --rxd=${RXD} --txd=${TXD}"
CMD_INT="${CMD_INT} --i ${ETH_PEER} --forward-mode=mac"
echo "${CMD_INT}" > $RUN_INT
chmod +x $RUN_INT

function sig_term() {
echo $(date +"%F %T,%3N") > /var/log/testpmd/sigterm-received.log
# kill testpmd application
Expand All @@ -116,7 +126,8 @@ function sig_term() {
}
trap sig_term SIGTERM

if [[ $RUN_APP == "1" ]]; then
if [[ $RUN_DEPLOYMENT == "1" ]]; then
# Run auto-start mode
sudo /usr/local/bin/example-cnf/run/testpmd-run
else
sleep infinity
Expand Down
4 changes: 4 additions & 0 deletions testpmd-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

## [Unreleased] -

## [0.2.24] - 2025-01-20

- Allow to enable/disable the deployment of the test scripts from outside

## [0.2.23] - 2024-12-27

- Enable reduced mode
Expand Down
4 changes: 2 additions & 2 deletions testpmd-operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ FROM quay.io/operator-framework/ansible-operator:v1.36.1
LABEL name="NFV Example CNF Application Opertor" \
maintainer="telcoci" \
vendor="fredco" \
version="v0.2.23" \
release="v0.2.23" \
version="v0.2.24" \
release="v0.2.24" \
summary="An example CNF for platform validation" \
description="An example CNF for platform validation"

Expand Down
2 changes: 1 addition & 1 deletion testpmd-operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# To re-generate a bundle for another specific version without changing the standard setup, you can:
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
VERSION := 0.2.23
VERSION := 0.2.24

# Set the Operator SDK version to use. By default, what is installed on the system is used.
# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
Expand Down
8 changes: 8 additions & 0 deletions testpmd-operator/roles/testpmd/templates/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ spec:
securityContext:
runAsNonRoot: true
runAsUser: 56560
{% if run_deployment is defined and run_deployment == 1 %}
readOnlyRootFilesystem: true
{% endif %}
{% if privileged %}
privileged: true
{% else %}
Expand Down Expand Up @@ -128,10 +130,15 @@ spec:
value: "{{ tx_descriptors }}"
- name: reduced_mode
value: "{{ reduced_mode }}"
{% if run_deployment is defined %}
- name: run_deployment
value: "{{ run_deployment }}"
{% endif %}
{% for key, value in environments.items() %}
- name: {{ key }}
value: "{{ value }}"
{% endfor %}
{% if run_deployment is defined and run_deployment == 1 %}
lifecycle:
postStart:
exec:
Expand All @@ -157,6 +164,7 @@ spec:
port: 8095
initialDelaySeconds: 30
periodSeconds: 10
{% endif %}
terminationMessagePolicy: FallbackToLogsOnError
volumes:
- name: hugepage
Expand Down
2 changes: 1 addition & 1 deletion trex-container-app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL := /bin/bash

DATE ?= $(shell date --utc +%Y%m%d%H%M)
SHA ?= $(shell git rev-parse --short HEAD)
VERSION ?= 0.2.14
VERSION ?= 0.2.15
REGISTRY ?= quay.io
ORG ?= rh-nfv-int
CONTAINER_CLI ?= podman
Expand Down
4 changes: 2 additions & 2 deletions trex-container-app/app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ FROM registry.access.redhat.com/ubi8/python-311:latest
LABEL name="NFV Example TRexApp Application" \
maintainer="telcoci" \
vendor="fredco" \
version="v0.2.14" \
release="v0.2.14" \
version="v0.2.15" \
release="v0.2.15" \
summary="An example CNF for platform validation" \
description="An example CNF for platform validation"

Expand Down
2 changes: 0 additions & 2 deletions trex-container-app/app/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ In order to choose a usecase, provide `run_app` with appropriate value in
the container environment, while creating the POD.

`run_app=1` - Run the app with default profile. Monitory for mac update CR.

`run_app=2` - Run the app in binary search mode
33 changes: 0 additions & 33 deletions trex-container-app/app/scripts/run-binary-search

This file was deleted.

9 changes: 2 additions & 7 deletions trex-container-app/app/scripts/trex-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ echo_ts() {
echo "$(date -u +"%Y-%m-%dT%H:%M:%S%z") $@"
}

RUN_APP=${run_app:=1}
RUN_DEPLOYMENT=${run_deployment:=1}
SERVER=${TREX_SERVER_URL:="0.0.0.0"}
MODE=${MODE:="direct"}

if [[ "${MODE}" == "direct" ]]; then
echo_ts "MODE is ${MODE}"
RUN_APP=1
fi

LOG_DIR="/var/log/trex"
Expand Down Expand Up @@ -52,15 +51,11 @@ if [ ! -z ${TREX_PROFILE_NAME} ]; then
fi
fi

if [[ $RUN_APP == "1" ]]; then
if [[ $RUN_DEPLOYMENT == "1" ]]; then
# leave the server running for 10s before starting application
sleep 10
echo_ts "Running TRex"
/usr/local/bin/run-trex
elif [[ $RUN_APP == "2" ]]; then
sleep 10
echo_ts "Running binary search"
/usr/local/bin/run-binary-search
else
echo_ts "Skipping TRex run, waiting ..."
sleep infinity
Expand Down
2 changes: 1 addition & 1 deletion trex-container-app/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if [[ "$1" == "-h" ]] ; then
exit 0
fi

TAG="${TAG:-v0.2.14}"
TAG="${TAG:-v0.2.15}"

CLI=${CLI:="podman"}
ORG=${ORG:="rh-nfv-int"}
Expand Down
4 changes: 2 additions & 2 deletions trex-container-app/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ FROM quay.io/rh-nfv-int/ubi8-base-trex:v0.0.1
LABEL name="NFV Example TRexServer Application" \
maintainer="telcoci" \
vendor="fredco" \
version="v0.2.14" \
release="v0.2.14" \
version="v0.2.15" \
release="v0.2.15" \
summary="An example CNF for platform validation" \
description="An example CNF for platform validation"

Expand Down
13 changes: 8 additions & 5 deletions trex-container-app/server/scripts/trex-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ echo_ts() {

# direct variables
MODE=${MODE:="direct"}
LB_MACS=${LB_MACS:=""}

# environments
RUN_CONFIGURE=${run_configure:=1}
RUN_SERVER=${run_server:=1}
RUN_DEPLOYMENT=${run_deployment:=1}
RUN_DELAY=${run_delay:=1}
# trex_core_count (trexCoreCount)

Expand Down Expand Up @@ -44,14 +43,18 @@ if [[ $((CORE_COUNT_CFG + 2)) != $TREX_CPU ]]; then
exit 1
fi

SERVER="sudo -E /usr/local/bin/trex-server"
RUN="/usr/local/bin/example-cnf/trex-server-run"
CMD="/usr/local/bin/trex-server"
CMD="${CMD} $CORE_COUNT"
echo "${CMD}" > $RUN
chmod +x $RUN

if [[ $RUN_SERVER == "1" ]]; then
if [[ $RUN_DEPLOYMENT == "1" ]]; then
sleep $RUN_DELAY
#echo_ts "Starting TRex daemon server ..."
#./trex_daemon_server start
echo_ts "Starting TRex server ..."
$SERVER $CORE_COUNT
sudo -E /usr/local/bin/example-cnf/trex-server-run
else
echo_ts "Skipping TRex server start, waiting ..."
sleep infinity
Expand Down
4 changes: 4 additions & 0 deletions trex-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

## [Unreleased] -

## [0.2.25] - 2025-01-20

- Allow to enable/disable the deployment of the test scripts from outside

## [0.2.24] - 2024-12-12

- Updated OperatorSDK to v1.38.0, kube-rbac-proxy is no longer included
Expand Down
4 changes: 2 additions & 2 deletions trex-operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ FROM quay.io/operator-framework/ansible-operator:v1.36.1
LABEL name="NFV Example CNF TRex Operator" \
maintainer="telcoci" \
vendor="fredco" \
version="v0.2.24" \
release="v0.2.24" \
version="v0.2.25" \
release="v0.2.25" \
summary="An example CNF for platform validation" \
description="An example CNF for platform validation"

Expand Down
2 changes: 1 addition & 1 deletion trex-operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# To re-generate a bundle for another specific version without changing the standard setup, you can:
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
VERSION ?= 0.2.24
VERSION ?= 0.2.25

# Set the Operator SDK version to use. By default, what is installed on the system is used.
# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
Expand Down
8 changes: 8 additions & 0 deletions trex-operator/roles/trexapp/templates/job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ spec:
securityContext:
runAsNonRoot: true
runAsUser: 56560
{% if run_deployment is defined and run_deployment == 1 %}
readOnlyRootFilesystem: true
{% endif %}
volumeMounts:
- name: varlog
mountPath: /var/log
Expand Down Expand Up @@ -75,6 +77,11 @@ spec:
- name: PACKET_RATE
value: "{{ packet_rate }}"
{% endif %}
{% if run_deployment is defined %}
- name: run_deployment
value: "{{ run_deployment }}"
{% endif %}
{% if run_deployment is defined and run_deployment == 1 %}
lifecycle:
postStart:
exec:
Expand All @@ -100,6 +107,7 @@ spec:
port: 8095
initialDelaySeconds: 30
periodSeconds: 10
{% endif %}
resources:
limits:
cpu: 4
Expand Down
Loading

0 comments on commit 2eb6d6d

Please sign in to comment.