From cb853790e186fa66487b1a22042345af7163ce34 Mon Sep 17 00:00:00 2001 From: JvD_Ericsson Date: Fri, 15 Dec 2023 09:22:40 +0000 Subject: Move mount node after cps test during CSITs * Split test plans into cps and ncmp * Check sdnc moved to after cps tests * Moved mounting of node to after cps tests Issue-ID: CPS-2001 Signed-off-by: JvD_Ericsson Change-Id: I5a36238d8ee6c91087cd2712c69e169257d48faa --- csit/plans/cps/sdnc/check_sdnc_mount_node.sh | 82 ++++++++++++++++++++++++ csit/plans/cps/sdnc/sdnc_setup.sh | 24 +------ csit/plans/cps/setup.sh | 47 -------------- csit/plans/cps/testplan.txt | 28 --------- csit/plans/cps/testplanCps.txt | 21 +++++++ csit/plans/cps/testplanNcmp.txt | 25 ++++++++ csit/run-csit.sh | 93 +++++++++++++++++----------- 7 files changed, 185 insertions(+), 135 deletions(-) create mode 100644 csit/plans/cps/sdnc/check_sdnc_mount_node.sh delete mode 100644 csit/plans/cps/testplan.txt create mode 100644 csit/plans/cps/testplanCps.txt create mode 100644 csit/plans/cps/testplanNcmp.txt (limited to 'csit') diff --git a/csit/plans/cps/sdnc/check_sdnc_mount_node.sh b/csit/plans/cps/sdnc/check_sdnc_mount_node.sh new file mode 100644 index 0000000000..9ea6670769 --- /dev/null +++ b/csit/plans/cps/sdnc/check_sdnc_mount_node.sh @@ -0,0 +1,82 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2023 Nordix Foundation +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= + +# WAIT 10 minutes maximum and test every 30 seconds if SDNC is up using HealthCheck API +TIME_OUT=600 +INTERVAL=30 +TIME=0 +while [ "$TIME" -lt "$TIME_OUT" ]; do + response=$(curl --write-out '%{http_code}' --silent --output /dev/null -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X POST -H "X-FromAppId: csit-sdnc" -H "X-TransactionId: csit-sdnc" -H "Accept: application/json" -H "Content-Type: application/json" http://$SDNC_HOST:$SDNC_PORT/restconf/operations/SLI-API:healthcheck ); + echo $response + + if [ "$response" == "200" ]; then + echo SDNC started in $TIME seconds + break; + fi + + echo Sleep: $INTERVAL seconds before testing if SDNC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds + sleep $INTERVAL + TIME=$(($TIME+$INTERVAL)) +done + +if [ "$TIME" -ge "$TIME_OUT" ]; then + echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities... +fi + +###################### mount pnf-sim as PNFDemo ########################## +SDNC_TIME_OUT=250 +SDNC_INTERVAL=10 +SDNC_TIME=0 + +while [ "$SDNC_TIME" -le "$SDNC_TIME_OUT" ]; do + + # Mount netconf node + curl --location --request PUT 'http://'$SDNC_HOST:$SDNC_PORT'/restconf/config/network-topology:network-topology/topology/topology-netconf/node/PNFDemo' \ + --header 'Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==' \ + --header 'Content-Type: application/json' \ + --data-raw '{ + "node": [ + { + "node-id": "PNFDemo", + "netconf-node-topology:protocol": { + "name": "TLS" + }, + "netconf-node-topology:host": "'$LOCAL_IP'", + "netconf-node-topology:key-based": { + "username": "netconf", + "key-id": "ODL_private_key_0" + }, + "netconf-node-topology:port": 6512, + "netconf-node-topology:tcp-only": false, + "netconf-node-topology:max-connection-attempts": 5 + } + ] + }' + + # Verify node has been mounted + + RESPONSE=$( curl --location --request GET 'http://'$SDNC_HOST:$SDNC_PORT'/restconf/config/network-topology:network-topology/topology/topology-netconf' --header 'Authorization: basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==') + + if [[ "$RESPONSE" == *"PNFDemo"* ]]; then + echo "Node mounted in $SDNC_TIME" + sleep 10 + break; + fi + + sleep $SDNC_INTERVAL + SDNC_TIME=$((SDNC_TIME + SDNC_INTERVAL)) + +done \ No newline at end of file diff --git a/csit/plans/cps/sdnc/sdnc_setup.sh b/csit/plans/cps/sdnc/sdnc_setup.sh index 9c17b836b0..61c61fc289 100644 --- a/csit/plans/cps/sdnc/sdnc_setup.sh +++ b/csit/plans/cps/sdnc/sdnc_setup.sh @@ -24,26 +24,4 @@ export SDNC_CERT_PATH=$WORKSPACE/plans/cps/sdnc/certs #start SDNC containers with docker compose and configuration from docker-compose.yml -docker-compose -f $WORKSPACE/plans/cps/sdnc/docker-compose.yml up -d - -# WAIT 10 minutes maximum and test every 30 seconds if SDNC is up using HealthCheck API -TIME_OUT=600 -INTERVAL=30 -TIME=0 -while [ "$TIME" -lt "$TIME_OUT" ]; do - response=$(curl --write-out '%{http_code}' --silent --output /dev/null -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X POST -H "X-FromAppId: csit-sdnc" -H "X-TransactionId: csit-sdnc" -H "Accept: application/json" -H "Content-Type: application/json" http://$SDNC_HOST:$SDNC_PORT/restconf/operations/SLI-API:healthcheck ); - echo $response - - if [ "$response" == "200" ]; then - echo SDNC started in $TIME seconds - break; - fi - - echo Sleep: $INTERVAL seconds before testing if SDNC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds - sleep $INTERVAL - TIME=$(($TIME+$INTERVAL)) -done - -if [ "$TIME" -ge "$TIME_OUT" ]; then - echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities... -fi \ No newline at end of file +docker-compose -f $WORKSPACE/plans/cps/sdnc/docker-compose.yml up -d \ No newline at end of file diff --git a/csit/plans/cps/setup.sh b/csit/plans/cps/setup.sh index c4e5c153d9..80829eba14 100755 --- a/csit/plans/cps/setup.sh +++ b/csit/plans/cps/setup.sh @@ -72,53 +72,6 @@ source $WORKSPACE/plans/cps/sdnc/sdnc_setup.sh ###################### setup pnfsim ##################################### docker-compose -f $WORKSPACE/plans/cps/pnfsim/docker-compose.yml up -d -# Allow time for netconf-pnp-simulator & SDNC to come up fully -sleep 30s - -###################### mount pnf-sim as PNFDemo ########################## -SDNC_TIME_OUT=250 -SDNC_INTERVAL=10 -SDNC_TIME=0 - -while [ "$SDNC_TIME" -le "$SDNC_TIME_OUT" ]; do - - # Mount netconf node - curl --location --request PUT 'http://'$SDNC_HOST:$SDNC_PORT'/restconf/config/network-topology:network-topology/topology/topology-netconf/node/PNFDemo' \ - --header 'Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==' \ - --header 'Content-Type: application/json' \ - --data-raw '{ - "node": [ - { - "node-id": "PNFDemo", - "netconf-node-topology:protocol": { - "name": "TLS" - }, - "netconf-node-topology:host": "'$LOCAL_IP'", - "netconf-node-topology:key-based": { - "username": "netconf", - "key-id": "ODL_private_key_0" - }, - "netconf-node-topology:port": 6512, - "netconf-node-topology:tcp-only": false, - "netconf-node-topology:max-connection-attempts": 5 - } - ] - }' - - # Verify node has been mounted - - RESPONSE=$( curl --location --request GET 'http://'$SDNC_HOST:$SDNC_PORT'/restconf/config/network-topology:network-topology/topology/topology-netconf' --header 'Authorization: basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==') - - if [[ "$RESPONSE" == *"PNFDemo"* ]]; then - echo "Node mounted in $SDNC_TIME" - break; - fi - - sleep $SDNC_INTERVAL - SDNC_TIME=$((SDNC_TIME + SDNC_INTERVAL)) - -done - ###################### verify ncmp-cps health ########################## check_health $CPS_CORE_HOST:$CPS_CORE_PORT 'cps-ncmp' diff --git a/csit/plans/cps/testplan.txt b/csit/plans/cps/testplan.txt deleted file mode 100644 index 45e8381a1e..0000000000 --- a/csit/plans/cps/testplan.txt +++ /dev/null @@ -1,28 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (C) 2021-2023 Nordix Foundation -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= - -# Test suites are relative paths under csit/tests/. -# Place the suites in run order. -actuator -cps-admin -cps-data -cps-model-sync -cps-data-sync -cps-subscriptions -ncmp-passthrough -cm-handle-query -cps-trust-level -cps-data-operations \ No newline at end of file diff --git a/csit/plans/cps/testplanCps.txt b/csit/plans/cps/testplanCps.txt new file mode 100644 index 0000000000..8b0ad08980 --- /dev/null +++ b/csit/plans/cps/testplanCps.txt @@ -0,0 +1,21 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2023 Nordix Foundation +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= + +# Test suites are relative paths under csit/tests/. +# Place the suites in run order. +actuator +cps-admin +cps-data \ No newline at end of file diff --git a/csit/plans/cps/testplanNcmp.txt b/csit/plans/cps/testplanNcmp.txt new file mode 100644 index 0000000000..81c5468618 --- /dev/null +++ b/csit/plans/cps/testplanNcmp.txt @@ -0,0 +1,25 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2023 Nordix Foundation +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= + +# Test suites are relative paths under csit/tests/. +# Place the suites in run order. +cps-model-sync +cps-data-sync +cps-subscriptions +ncmp-passthrough +cm-handle-query +cps-trust-level +cps-data-operations \ No newline at end of file diff --git a/csit/run-csit.sh b/csit/run-csit.sh index 9a344c1ffd..6f5142c917 100755 --- a/csit/run-csit.sh +++ b/csit/run-csit.sh @@ -43,6 +43,32 @@ fi # functions # +# relax set options so the sourced file will not fail +# the responsibility is shifted to the sourced file... +function relax_set() { + set +e + set +o pipefail +} + +# load the saved set options +function load_set() { + _setopts="$-" + + # bash shellopts + for i in $(echo "$SHELLOPTS" | tr ':' ' ') ; do + set +o ${i} + done + for i in $(echo "$RUN_CSIT_SHELLOPTS" | tr ':' ' ') ; do + set -o ${i} + done + + # other options + for i in $(echo "$_setopts" | sed 's/./& /g') ; do + set +${i} + done + set -${RUN_CSIT_SAVE_SET} +} + # wrapper for sourcing a file function source_safely() { [ -z "$1" ] && return 1 @@ -104,36 +130,26 @@ function save_set() { RUN_CSIT_SHELLOPTS="$SHELLOPTS" } -# load the saved set options -function load_set() { - _setopts="$-" - - # bash shellopts - for i in $(echo "$SHELLOPTS" | tr ':' ' ') ; do - set +o ${i} - done - for i in $(echo "$RUN_CSIT_SHELLOPTS" | tr ':' ' ') ; do - set -o ${i} - done - - # other options - for i in $(echo "$_setopts" | sed 's/./& /g') ; do - set +${i} - done - set -${RUN_CSIT_SAVE_SET} -} - # set options for quick bailout when error function harden_set() { set -xeo pipefail set +u # enabled it would probably fail too many often } -# relax set options so the sourced file will not fail -# the responsibility is shifted to the sourced file... -function relax_set() { - set +e - set +o pipefail +function run_test_plan() { + testplan=$1 + + cd "$WORKDIR" + echo "Reading the testplan:" + cat "${TESTPLANDIR}/${testplan}.txt" | egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' | sed "s|^|${WORKSPACE}/tests/|" > ${testplan}.txt + cat ${testplan}.txt + SUITES=$( xargs -a ${testplan}.txt ) + + python3 -m robot.run -N ${TESTPLAN} -v WORKSPACE:/tmp ${ROBOT_VARIABLES} ${TESTOPTIONS} ${SUITES} + RESULT=$? + load_set + echo "RESULT: $RESULT" + return $RESULT } # @@ -158,10 +174,10 @@ if [ -z "$WORKSPACE" ]; then export WORKSPACE=$(git rev-parse --show-toplevel) fi -if [ -f "${WORKSPACE}/${1}/testplan.txt" ]; then +if [ -f "${WORKSPACE}/${1}/testplanCps.txt" ]; then export TESTPLAN="${1}" else - echo "testplan not found: ${WORKSPACE}/${TESTPLAN}/testplan.txt" + echo "testplan not found: ${WORKSPACE}/${TESTPLAN}/testplanCps.txt or testplanNcmp.txt" exit 2 fi @@ -198,12 +214,6 @@ fi docker_stats | tee "$WORKSPACE/archives/$TESTPLAN/_sysinfo-1-after-setup.txt" # Run test plan -cd "$WORKDIR" -echo "Reading the testplan:" -cat "${TESTPLANDIR}/testplan.txt" | egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' | sed "s|^|${WORKSPACE}/tests/|" > testplan.txt -cat testplan.txt -SUITES=$( xargs -a testplan.txt ) - echo ROBOT_VARIABLES="${ROBOT_VARIABLES}" echo "Starting Robot test suites ${SUITES} ..." relax_set @@ -213,9 +223,18 @@ python3 --version pip freeze python3 -m robot.run --version || : -python3 -m robot.run -N ${TESTPLAN} -v WORKSPACE:/tmp ${ROBOT_VARIABLES} ${TESTOPTIONS} ${SUITES} -RESULT=$? -load_set -echo "RESULT: $RESULT" +run_test_plan "testplanCps" +CPSRESULT="$?" + +cd "${TESTPLANDIR}" +checkandmount="${TESTPLANDIR}/sdnc/check_sdnc_mount_node.sh" +if [ -f "${checkandmount}" ]; then + echo "Running check_sdnc_mount_node script ${checkandmount}" + source_safely "${checkandmount}" +fi + +run_test_plan "testplanNcmp" +NCMPRESULT="$?" + # Note that the final steps are done in on_exit function after this exit! -exit $RESULT +exit $CPSRESULT || $NCMPRESULT -- cgit 1.2.3-korg