diff options
author | 2023-12-19 08:48:25 +0000 | |
---|---|---|
committer | 2023-12-19 08:48:25 +0000 | |
commit | 9d7b4954a17c86e4d0c878220c18d1551560244d (patch) | |
tree | 2dba3dc8d360673bc12b16b37f1f53f9e5dd48d8 /csit | |
parent | a966bab93a17fcba4e7fc28354c01b3f0878fbbe (diff) | |
parent | cb853790e186fa66487b1a22042345af7163ce34 (diff) |
Merge "Move mount node after cps test during CSITs"
Diffstat (limited to 'csit')
-rw-r--r-- | csit/plans/cps/sdnc/check_sdnc_mount_node.sh | 82 | ||||
-rw-r--r-- | csit/plans/cps/sdnc/sdnc_setup.sh | 24 | ||||
-rwxr-xr-x | csit/plans/cps/setup.sh | 47 | ||||
-rw-r--r-- | csit/plans/cps/testplanCps.txt | 21 | ||||
-rw-r--r-- | csit/plans/cps/testplanNcmp.txt (renamed from csit/plans/cps/testplan.txt) | 5 | ||||
-rwxr-xr-x | csit/run-csit.sh | 93 |
6 files changed, 161 insertions, 111 deletions
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 000000000..9ea667076 --- /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 9c17b836b..61c61fc28 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 c4e5c153d..80829eba1 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/testplanCps.txt b/csit/plans/cps/testplanCps.txt new file mode 100644 index 000000000..8b0ad0898 --- /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/testplan.txt b/csit/plans/cps/testplanNcmp.txt index 45e8381a1..81c546861 100644 --- a/csit/plans/cps/testplan.txt +++ b/csit/plans/cps/testplanNcmp.txt @@ -1,5 +1,5 @@ # ============LICENSE_START======================================================= -# Copyright (C) 2021-2023 Nordix Foundation +# 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. @@ -16,9 +16,6 @@ # 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 diff --git a/csit/run-csit.sh b/csit/run-csit.sh index 9a344c1ff..6f5142c91 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 |