From 70da93a0b2b5e012a5b6ac55d22870c7615b74fc Mon Sep 17 00:00:00 2001 From: Nishant Parekh Date: Wed, 9 Oct 2024 00:07:36 -0400 Subject: [PATCH] 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..."