From 70da93a0b2b5e012a5b6ac55d22870c7615b74fc Mon Sep 17 00:00:00 2001 From: Nishant Parekh Date: Wed, 9 Oct 2024 00:07:36 -0400 Subject: [PATCH 1/4] added changes to include a new parameter nodeName to pass in the the node to test in an MNO cluster. * updated e2e.sh to add validations and pass in the nodeName to the verify env and collect scripts. * updated Containerfile to add in nodeName as an argument set to emptyString by default (SNO case) Signed-off-by: Nishant Parekh --- Containerfile | 5 +++-- cmd/e2e.sh | 29 ++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Containerfile b/Containerfile index 597bb62..afacdc0 100644 --- a/Containerfile +++ b/Containerfile @@ -1,5 +1,6 @@ FROM registry.access.redhat.com/ubi9/ubi-minimal:latest - +#node name should be passed in when testing an MNO cluster defaulting to SNO usecase of empty. +ARG NODENAME="" RUN microdnf install -y git golang python3 python3-pip tar python3-yaml jq ruby RUN pip3 install pandas junitparser matplotlib allantools RUN gem install asciidoctor-pdf:2.3.9 asciidoctor-diagram:2.2.14 rouge:3.30.0 @@ -20,4 +21,4 @@ WORKDIR ${VSE_DIR}/vse-sync-collection-tools RUN go mod vendor WORKDIR ${VSE_DIR} -CMD ["./vse-sync-test/cmd/e2e.sh", "-d", "2000s", "/usr/vse/kubeconfig"] +CMD ["./vse-sync-test/cmd/e2e.sh", "-d", "2000s","-n","$NODENAME" ,"/usr/vse/kubeconfig"] diff --git a/cmd/e2e.sh b/cmd/e2e.sh index 1251d3d..ca0ec7a 100755 --- a/cmd/e2e.sh +++ b/cmd/e2e.sh @@ -56,6 +56,7 @@ Options: -i: name of the network interface under test -g: name of the gnss device under test -d: how many seconds to run data collection + -n: nodeName that we need to run the tests on (Required for MNO use case) If kubeconfig is not supplied then data collection is skipped: a pre-existing dataset must be available in $DATADIR @@ -66,12 +67,13 @@ EOF } # Parse arguments and options -while getopts ':i:g:d:l' option; do +while getopts ':i:g:d:l:n' option; do case "$option" in i) INTERFACE_NAME="$OPTARG" ;; g) GNSS_NAME="$OPTARG" ;; d) DURATION="$OPTARG" ;; l) DIFF_LOG=1 ;; + n) NODE_NAME="$OPTARG" ;; \?) usage >&2 && exit 1 ;; :) usage >&2 && exit 1 ;; esac @@ -96,12 +98,26 @@ if [ ! -z "$LOCAL_KUBECONFIG" ]; then oc project --kubeconfig=$LOCAL_KUBECONFIG $NAMESPACE # set namespace for data collection + if [ -z $NODE_NAME ]; then + NUM_OF_NODES=$(oc --kubeconfig=$LOCAL_KUBECONFIG get nodes --output json | jq -j '.items | length') + if [[ "$NUM_OF_NODES" -gt 1 ]]; then + echo "nodeName is required for an MNO cluster test run. Please pass in the nodename linked to the interface connected to the GNSS signal" + exit 1 + fi + fi + if [ -z $INTERFACE_NAME ]; then if [[ -z $GNSS_NAME ]]; then GNSS_NAME=gnss0 fi - INTERFACE_NAME=$(oc --kubeconfig=$LOCAL_KUBECONFIG exec daemonset/linuxptp-daemon -c linuxptp-daemon-container -- ls /sys/class/gnss/${GNSS_NAME}/device/net/) - echo "Discovered interface name: $INTERFACE_NAME" + if [ ! -z $NODE_NAME ]; then + POD_NAME=$(oc --kubeconfig=$LOCAL_KUBECONFIG get pods --field-selector="spec.nodeName=$NODE_NAME" -o json | jq -r '.items[] | select(.metadata.name | test("linuxptp-daemon")).metadata.name') + INTERFACE_NAME=$(oc --kubeconfig=$LOCAL_KUBECONFIG exec POD_NAME -c linuxptp-daemon-container -- ls /sys/class/gnss/${GNSS_NAME}/device/net/) + echo "Discovered interface name: $INTERFACE_NAME" + else + INTERFACE_NAME=$(oc --kubeconfig=$LOCAL_KUBECONFIG exec daemonset/linuxptp-daemon -c linuxptp-daemon-container -- ls /sys/class/gnss/${GNSS_NAME}/device/net/) + echo "Discovered interface name: $INTERFACE_NAME" + fi fi else CLUSTER_UNDER_TEST="offline" @@ -155,7 +171,9 @@ verify_env(){ dt=$(date --rfc-3339='seconds' -u) local junit_template=$(echo ".[].data + { \"timestamp\": \"$dt\", "duration": 0}") set +e - go run main.go env verify --interface="$INTERFACE_NAME" --kubeconfig="$LOCAL_KUBECONFIG" --use-analyser-format > $ENVJSONRAW + go run main.go env verify --interface="$INTERFACE_NAME" --nodeName="$NODE_NAME" --kubeconfig="$LOCAL_KUBECONFIG" --use-analyser-format > $ENVJSONRAW + fi + if [ $? -gt 0 ] then cat $ENVJSONRAW @@ -171,7 +189,8 @@ collect_data(){ pushd "$COLLECTORPATH" >/dev/null 2>&1 echo "Collecting $DURATION of data. Please wait..." - go run main.go collect --interface="$INTERFACE_NAME" --kubeconfig="$LOCAL_KUBECONFIG" --logs-output="$PTP_DAEMON_LOGFILE" --output="$COLLECTED_DATA_FILE" --use-analyser-format --duration=$DURATION + go run main.go collect --interface="$INTERFACE_NAME" --nodeName=$NODE_NAME --kubeconfig="$LOCAL_KUBECONFIG" --logs-output="$PTP_DAEMON_LOGFILE" --output="$COLLECTED_DATA_FILE" --use-analyser-format --duration=$DURATION + if [ ${DIFF_LOG} -eq 1 ] then echo "Collecting $DURATION of data using old method. Please wait..." From fb644409f53bcd88c540f829455567e9fabc1279 Mon Sep 17 00:00:00 2001 From: Nishant Parekh Date: Wed, 9 Oct 2024 17:04:53 -0400 Subject: [PATCH 2/4] updated to use environment variable instead of argument * use of env is preferrable as it only a runtime setting instead of a change to the container build itself * bugfixes identified from local run Signed-off-by: Nishant Parekh --- Containerfile | 4 ++-- cmd/e2e.sh | 15 +++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Containerfile b/Containerfile index afacdc0..a37996b 100644 --- a/Containerfile +++ b/Containerfile @@ -1,6 +1,6 @@ FROM registry.access.redhat.com/ubi9/ubi-minimal:latest #node name should be passed in when testing an MNO cluster defaulting to SNO usecase of empty. -ARG NODENAME="" +ENV PTPNODENAME="" RUN microdnf install -y git golang python3 python3-pip tar python3-yaml jq ruby RUN pip3 install pandas junitparser matplotlib allantools RUN gem install asciidoctor-pdf:2.3.9 asciidoctor-diagram:2.2.14 rouge:3.30.0 @@ -21,4 +21,4 @@ WORKDIR ${VSE_DIR}/vse-sync-collection-tools RUN go mod vendor WORKDIR ${VSE_DIR} -CMD ["./vse-sync-test/cmd/e2e.sh", "-d", "2000s","-n","$NODENAME" ,"/usr/vse/kubeconfig"] +CMD ["./vse-sync-test/cmd/e2e.sh", "-d", "2000s","-n","$PTPNODENAME" ,"/usr/vse/kubeconfig"] diff --git a/cmd/e2e.sh b/cmd/e2e.sh index ca0ec7a..49acea6 100755 --- a/cmd/e2e.sh +++ b/cmd/e2e.sh @@ -42,12 +42,13 @@ FULLJUNIT="$OUTPUTDIR/sync_test_report.xml" # defaults DURATION=2000s NAMESPACE=openshift-ptp +NODE_NAME="" GNSS_NAME= DIFF_LOG=0 usage() { cat - <&2 && exit 1 ;; :) usage >&2 && exit 1 ;; esac @@ -95,7 +96,6 @@ if [ ! -z "$LOCAL_KUBECONFIG" ]; then echo "$0: error: $NAMESPACE is not active. Check the status of ptp operator namespace." 1>&2 exit 1 fi - oc project --kubeconfig=$LOCAL_KUBECONFIG $NAMESPACE # set namespace for data collection if [ -z $NODE_NAME ]; then @@ -112,7 +112,7 @@ if [ ! -z "$LOCAL_KUBECONFIG" ]; then fi if [ ! -z $NODE_NAME ]; then POD_NAME=$(oc --kubeconfig=$LOCAL_KUBECONFIG get pods --field-selector="spec.nodeName=$NODE_NAME" -o json | jq -r '.items[] | select(.metadata.name | test("linuxptp-daemon")).metadata.name') - INTERFACE_NAME=$(oc --kubeconfig=$LOCAL_KUBECONFIG exec POD_NAME -c linuxptp-daemon-container -- ls /sys/class/gnss/${GNSS_NAME}/device/net/) + INTERFACE_NAME=$(oc --kubeconfig=$LOCAL_KUBECONFIG exec $POD_NAME -c linuxptp-daemon-container -- ls /sys/class/gnss/${GNSS_NAME}/device/net/) echo "Discovered interface name: $INTERFACE_NAME" else INTERFACE_NAME=$(oc --kubeconfig=$LOCAL_KUBECONFIG exec daemonset/linuxptp-daemon -c linuxptp-daemon-container -- ls /sys/class/gnss/${GNSS_NAME}/device/net/) @@ -172,7 +172,6 @@ verify_env(){ local junit_template=$(echo ".[].data + { \"timestamp\": \"$dt\", "duration": 0}") set +e go run main.go env verify --interface="$INTERFACE_NAME" --nodeName="$NODE_NAME" --kubeconfig="$LOCAL_KUBECONFIG" --use-analyser-format > $ENVJSONRAW - fi if [ $? -gt 0 ] then @@ -189,7 +188,7 @@ collect_data(){ pushd "$COLLECTORPATH" >/dev/null 2>&1 echo "Collecting $DURATION of data. Please wait..." - go run main.go collect --interface="$INTERFACE_NAME" --nodeName=$NODE_NAME --kubeconfig="$LOCAL_KUBECONFIG" --logs-output="$PTP_DAEMON_LOGFILE" --output="$COLLECTED_DATA_FILE" --use-analyser-format --duration=$DURATION + go run main.go collect --interface="$INTERFACE_NAME" --nodeName="$NODE_NAME" --kubeconfig="$LOCAL_KUBECONFIG" --logs-output="$PTP_DAEMON_LOGFILE" --output="$COLLECTED_DATA_FILE" --use-analyser-format --duration=$DURATION if [ ${DIFF_LOG} -eq 1 ] then From 30003c0ff9e8f496e0ed2c5db3218b09b8f24c0d Mon Sep 17 00:00:00 2001 From: Nishant Parekh Date: Fri, 11 Oct 2024 14:42:18 -0400 Subject: [PATCH 3/4] add MNO support instructions to README.adoc Signed-off-by: Nishant Parekh --- README.adoc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.adoc b/README.adoc index b66c194..403a706 100644 --- a/README.adoc +++ b/README.adoc @@ -99,6 +99,22 @@ podman run \ -v /home/redhat/tmp/data:/usr/vse/data:Z \ quay.io/redhat-partner-solutions/vse-sync-test:latest ./vse-sync-test/cmd/e2e.sh ---- +== MNO Support + +If you are looking to run the tests on a Grandmaster interface on an Multi Node Cluster we +need to pass in an additional value to the container. We need to set the ptpNodeName, +which is the node that has the NIC connected to the GNSS signal. The nodeName is passed as +an environment variable. + +For example: +[source,shell] +---- +podman run \ + -e $PTPNODENAME= + -v ~/kubeconfig:/usr/vse/kubeconfig:Z \ + -v /home/redhat/tmp/data:/usr/vse/data:Z \ + quay.io/redhat-partner-solutions/vse-sync-test:latest +---- == Development Setup From ae6e5fa88fec9343e89ff2b04722ca8237ba51af Mon Sep 17 00:00:00 2001 From: Nishant Parekh Date: Sun, 13 Oct 2024 22:04:36 -0400 Subject: [PATCH 4/4] review fix Signed-off-by: Nishant Parekh --- README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index 403a706..3c2fa62 100644 --- a/README.adoc +++ b/README.adoc @@ -110,7 +110,7 @@ For example: [source,shell] ---- podman run \ - -e $PTPNODENAME= + -e PTPNODENAME= -v ~/kubeconfig:/usr/vse/kubeconfig:Z \ -v /home/redhat/tmp/data:/usr/vse/data:Z \ quay.io/redhat-partner-solutions/vse-sync-test:latest