Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nodeName as a new parameter to support MNO cluster testing #84

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -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.
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
Expand All @@ -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","$PTPNODENAME" ,"/usr/vse/kubeconfig"]
16 changes: 16 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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=<nodeName>
-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

Expand Down
34 changes: 26 additions & 8 deletions cmd/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 - <<EOF
Usage: $(basename "$0") [-i INTERFACE_NAME] [-d DURATION] ?kubeconfig?
Usage: $(basename "$0") [-i INTERFACE_NAME] [-d DURATION] [-n nodeName] ?kubeconfig?

Arguments:
kubeconfig: path to the kubeconfig to be used
Expand All @@ -56,6 +57,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
Expand All @@ -66,12 +68,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" ;;
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
Expand All @@ -93,15 +96,28 @@ 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
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"
Expand Down Expand Up @@ -155,7 +171,8 @@ 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

if [ $? -gt 0 ]
then
cat $ENVJSONRAW
Expand All @@ -171,7 +188,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..."
Expand Down
Loading