3 # ============LICENSE_START===============================================
4 # Copyright (C) 2020 Nordix Foundation. All rights reserved.
5 # ========================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END=================================================
20 # This is a script that contains all the functions needed for auto test
21 # Arg: local|remote|remote-remove [auto-clean] [--stop-at-error] [--ricsim-prefix <prefix> ] [--use-local-image <app-nam> [<app-name>]*]
24 #Formatting for 'echo' cmd
29 GREEN="\033[32m\033[1m"
31 YELLOW="\033[33m\033[1m"
36 if [ $? -ne 0 ] || [ -z tmp ]; then
37 echo -e $RED"python3 is required to run the test environment, pls install"$ERED
41 if [ $? -ne 0 ] || [ -z tmp ]; then
42 echo -e $RED"docker is required to run the test environment, pls install"$ERED
46 tmp=$(which docker-compose)
47 if [ $? -ne 0 ] || [ -z tmp ]; then
48 echo -e $RED"docker-compose is required to run the test environment, pls install"$ERED
52 # Just resetting any previous echo formatting...
55 # source test environment variables
56 . ../common/test_env.sh
58 echo "Test case started as: ${BASH_SOURCE[$i+1]} "$@
60 #Vars for A1 interface version and container count
68 # Vars to switch between http and https. Extra curl flag needed for https
69 export RIC_SIM_HTTPX="http"
70 export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:"
71 export RIC_SIM_PORT=$RIC_SIM_INTERNAL_PORT
72 export RIC_SIM_CERT_MOUNT_DIR="./cert"
74 export MR_HTTPX="http"
75 export MR_PORT=$MR_INTERNAL_PORT
76 export MR_LOCAL_PORT=$MR_EXTERNAL_PORT #When agent is running outside the docker net
78 export CR_HTTPX="http"
79 export CR_PORT=$CR_INTERNAL_PORT
80 export CR_LOCAL_PORT=$CR_EXTERNAL_PORT #When CR is running outside the docker net
82 export SDNC_HTTPX="http"
83 export SDNC_PORT=$SDNC_INTERNAL_PORT
84 export SDNC_LOCAL_PORT=$SDNC_EXTERNAL_PORT #When agent is running outside the docker net
87 LOCALHOST="http://localhost:"
89 # Make curl retries for http response codes set in this env var, space separated list of codes
92 # Var to contol if the agent runs in a container (normal = 0) or as application on the local machine ( = 1)
95 # Var to hold 'auto' in case containers shall be stopped when test case ends
98 # Var to hold the app names to use local image for when running 'remote' or 'remote-remove'
101 # List of available apps to override with local image
102 AVAILABLE_LOCAL_IMAGES_OVERRIDE="PA CP SDNC RICSIM"
104 # Use this var (STOP_AT_ERROR=1 in the test script) for debugging/trouble shooting to take all logs and exit at first FAIL test case
107 # Set a description string for the test case
108 if [ -z "$TC_ONELINE_DESCR" ]; then
109 TC_ONELINE_DESCR="<no-description>"
110 echo "No test case description found, TC_ONELINE_DESCR should be set on in the test script , using "$TC_ONELINE_DESCR
113 # Counter for test suites
114 if [ -f .tmp_tcsuite_ctr ]; then
115 tmpval=$(< .tmp_tcsuite_ctr)
117 echo $tmpval > .tmp_tcsuite_ctr
120 # Create a test case id, ATC (Auto Test Case), from the name of the test case script.
121 # FTC1.sh -> ATC == FTC1
122 ATC=$(basename "${BASH_SOURCE[$i+1]}" .sh)
124 # Create the logs dir if not already created in the current dir
125 if [ ! -d "logs" ]; then
130 # Create a http message log for this testcase
131 HTTPLOG=$PWD"/.httplog_"$ATC".txt"
134 #Create result file (containing '1' for error) for this test case
135 #Will be replaced with a file containing '0' if script is ok
137 echo "1" > "$PWD/.result$ATC.txt"
139 # Create a log dir for the test case
140 mkdir -p $TESTLOGS/$ATC
142 # Clear the log dir for the test case
143 rm $TESTLOGS/$ATC/*.log &> /dev/null
144 rm $TESTLOGS/$ATC/*.txt &> /dev/null
145 rm $TESTLOGS/$ATC/*.json &> /dev/null
147 # Log all output from the test case to a TC log
148 TCLOG=$TESTLOGS/$ATC/TC.log
149 exec &> >(tee ${TCLOG})
151 #Variables for counting tests as well as passed and failed tests
158 #File to keep deviation messages
159 DEVIATION_FILE=".tmp_deviations"
160 rm $DEVIATION_FILE &> /dev/null
162 #Var for measuring execution time
163 TCTEST_START=$SECONDS
165 #File to save timer measurement results
166 TIMER_MEASUREMENTS=".timer_measurement.txt"
167 echo -e "Activity \t Duration" > $TIMER_MEASUREMENTS
170 echo "-------------------------------------------------------------------------------------------------"
171 echo "----------------------------------- Test case: "$ATC
172 echo "----------------------------------- Started: "$(date)
173 echo "-------------------------------------------------------------------------------------------------"
174 echo "-- Description: "$TC_ONELINE_DESCR
175 echo "-------------------------------------------------------------------------------------------------"
176 echo "----------------------------------- Test case setup -----------------------------------"
180 if [ $# -lt 1 ]; then
183 if [ $paramerror -eq 0 ]; then
184 if [ "$1" != "remote" ] && [ "$1" != "remote-remove" ] && [ "$1" != "local" ]; then
191 while [ $paramerror -eq 0 ] && [ $foundparm -eq 0 ]; do
193 if [ $paramerror -eq 0 ]; then
194 if [ "$1" == "auto-clean" ]; then
196 echo "Option set - Auto clean at end of test script"
201 if [ $paramerror -eq 0 ]; then
202 if [ "$1" == "--stop-at-error" ]; then
204 echo "Option set - Stop at first error"
209 if [ $paramerror -eq 0 ]; then
210 if [ "$1" == "--ricsim-prefix" ]; then
216 echo "Option set - Overriding RIC_SIM_PREFIX with: "$1
222 if [ $paramerror -eq 0 ]; then
223 if [ "$1" == "--use-local-image" ]; then
226 while [ $# -gt 0 ] && [[ "$1" != "--"* ]]; do
227 USE_LOCAL_IMAGES=$USE_LOCAL_IMAGES" "$1
228 if [[ "$AVAILABLE_LOCAL_IMAGES_OVERRIDE" != *"$1"* ]]; then
234 if [ -z "$USE_LOCAL_IMAGES" ]; then
237 echo "Option set - Override remote images for app(s):"$USE_LOCAL_IMAGES
245 if [ $paramerror -eq 0 ] && [ $# -gt 0 ]; then
249 if [ $paramerror -eq 1 ]; then
250 echo -e $RED"Expected arg: local|remote|remote-remove [auto-clean] [--stop-at-error] [--ricsim-prefix <prefix> ] [--use-local-image <app-nam> [<app-name>]*]"$ERED
254 echo -e $BOLD"Checking configured image setting for this test case"$EBOLD
256 #Temp var to check for image variable name errors
258 #Create a file with image info for later printing as a table
259 image_list_file=".image-list"
260 echo -e " Container\tImage\ttag" > $image_list_file
262 # Check if image env var is set and if so export the env var with image to use (used by docker compose files)
263 # arg: <image name> <script start-arg> <target-variable-name> <image-variable-name> <image-tag-variable-name>
264 __check_image_var() {
265 if [ $# -ne 5 ]; then
266 echo "Expected arg: <image name> <script start-arg> <target-variable-name> <image-variable-name> <image-tag-variable-name>"
271 #Create var from the input var names
275 if [ -z $image ]; then
276 echo -e $RED"\$"$4" not set in test_env"$ERED
279 tmp=$tmp"<no-image>\t"
284 echo -e $RED"\$"$5" not set in test_env"$ERED
291 echo -e "$tmp" >> $image_list_file
293 export "${3}"=$image":"$tag
295 #echo " Configured image for ${1} (script start arg=${2}): "$image":"$tag
299 #Check if app local image shall override remote image
300 __check_image_local_override() {
301 for im in $USE_LOCAL_IMAGES; do
302 if [ "$1" == "$im" ]; then
309 #Check if app uses image excluded from this test run
310 __check_excluded_image() {
311 for im in $EXCLUDED_IMAGES; do
312 if [ "$1" == "$im" ]; then
319 # Check that image env setting are available
322 if [ $START_ARG == "local" ]; then
325 __check_image_var " Policy Agent" $START_ARG "POLICY_AGENT_IMAGE" "POLICY_AGENT_LOCAL_IMAGE" "POLICY_AGENT_LOCAL_IMAGE_TAG"
327 #Local Control Panel image
328 __check_image_var " Control Panel" $START_ARG "CONTROL_PANEL_IMAGE" "CONTROL_PANEL_LOCAL_IMAGE" "CONTROL_PANEL_LOCAL_IMAGE_TAG"
331 __check_image_var " SDNC A1 Controller" $START_ARG "SDNC_A1_CONTROLLER_IMAGE" "SDNC_A1_CONTROLLER_LOCAL_IMAGE" "SDNC_A1_CONTROLLER_LOCAL_IMAGE_TAG"
334 __check_image_var " RIC Simulator" $START_ARG "RIC_SIM_IMAGE" "RIC_SIM_LOCAL_IMAGE" "RIC_SIM_LOCAL_IMAGE_TAG"
336 elif [ $START_ARG == "remote" ] || [ $START_ARG == "remote-remove" ]; then
338 __check_image_local_override 'PA'
339 if [ $? -eq 0 ]; then
341 __check_image_var " Policy Agent" $START_ARG "POLICY_AGENT_IMAGE" "POLICY_AGENT_REMOTE_IMAGE" "POLICY_AGENT_REMOTE_IMAGE_TAG"
344 __check_image_var " Policy Agent" $START_ARG "POLICY_AGENT_IMAGE" "POLICY_AGENT_LOCAL_IMAGE" "POLICY_AGENT_LOCAL_IMAGE_TAG"
347 __check_image_local_override 'CP'
348 if [ $? -eq 0 ]; then
349 #Remote Control Panel image
350 __check_image_var " Control Panel" $START_ARG "CONTROL_PANEL_IMAGE" "CONTROL_PANEL_REMOTE_IMAGE" "CONTROL_PANEL_REMOTE_IMAGE_TAG"
352 #Local Control Panel image
353 __check_image_var " Control Panel" $START_ARG "CONTROL_PANEL_IMAGE" "CONTROL_PANEL_LOCAL_IMAGE" "CONTROL_PANEL_LOCAL_IMAGE_TAG"
356 __check_image_local_override 'SDNC'
357 if [ $? -eq 0 ]; then
359 __check_image_var " SDNC A1 Controller" $START_ARG "SDNC_A1_CONTROLLER_IMAGE" "SDNC_A1_CONTROLLER_REMOTE_IMAGE" "SDNC_A1_CONTROLLER_REMOTE_IMAGE_TAG"
362 __check_image_var " SDNC A1 Controller" $START_ARG "SDNC_A1_CONTROLLER_IMAGE" "SDNC_A1_CONTROLLER_LOCAL_IMAGE" "SDNC_A1_CONTROLLER_LOCAL_IMAGE_TAG"
365 __check_image_local_override 'RICSIM'
366 if [ $? -eq 0 ]; then
367 #Remote ric sim image
368 __check_image_var " RIC Simulator" $START_ARG "RIC_SIM_IMAGE" "RIC_SIM_REMOTE_IMAGE" "RIC_SIM_REMOTE_IMAGE_TAG"
371 __check_image_var " RIC Simulator" $START_ARG "RIC_SIM_IMAGE" "RIC_SIM_LOCAL_IMAGE" "RIC_SIM_LOCAL_IMAGE_TAG"
375 #Should never get here....
376 echo "Unknow args: "$@
381 # These images are not built as part of this project official images, just check that env vars are set correctly
382 __check_image_var " Message Router" $START_ARG "MRSTUB_IMAGE" "MRSTUB_LOCAL_IMAGE" "MRSTUB_LOCAL_IMAGE_TAG"
383 __check_image_var " Callback Receiver" $START_ARG "CR_IMAGE" "CR_LOCAL_IMAGE" "CR_LOCAL_IMAGE_TAG"
384 __check_image_var " Consul" $START_ARG "CONSUL_IMAGE" "CONSUL_REMOTE_IMAGE" "CONSUL_REMOTE_IMAGE_TAG"
385 __check_image_var " CBS" $START_ARG "CBS_IMAGE" "CBS_REMOTE_IMAGE" "CBS_REMOTE_IMAGE_TAG"
386 __check_image_var " SDNC DB" $START_ARG "SDNC_DB_IMAGE" "SDNC_DB_REMOTE_IMAGE" "SDNC_DB_REMOTE_IMAGE_TAG"
387 __check_excluded_image 'SDNC_ONAP'
388 if [ $? -eq 0 ]; then
389 __check_image_var " SDNC ONAP A1 Adapter" $START_ARG "SDNC_ONAP_A1_ADAPTER_IMAGE" "SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE" "SDNC_ONAP_A1_ADAPTER_REMOTE_IMAGE_TAG"
390 __check_image_var " SDNC ONAP DB" $START_ARG "SDNC_ONAP_DB_IMAGE" "SDNC_ONAP_DB_REMOTE_IMAGE" "SDNC_ONAP_DB_REMOTE_IMAGE_TAG"
393 #Errors in image setting - exit
394 if [ $IMAGE_ERR -ne 0 ]; then
398 #Print a tables of the image settings
399 echo -e $BOLD"Images configured for start arg: "$START $EBOLD
400 column -t -s $'\t' $image_list_file
405 #Set the SIM_GROUP var
406 echo -e $BOLD"Setting var to main dir of all container/simulator scripts"$EBOLD
407 if [ -z "$SIM_GROUP" ]; then
408 SIM_GROUP=$PWD/../simulator-group
409 if [ ! -d $SIM_GROUP ]; then
410 echo "Trying to set env var SIM_GROUP to dir 'simulator-group' in the nontrtric repo, but failed."
411 echo -e $RED"Please set the SIM_GROUP manually in the test_env.sh"$ERED
414 echo " SIM_GROUP auto set to: " $SIM_GROUP
416 elif [ $SIM_GROUP = *simulator_group ]; then
417 echo -e $RED"Env var SIM_GROUP does not seem to point to dir 'simulator-group' in the repo, check common/test_env.sh"$ERED
420 echo " SIM_GROUP env var already set to: " $SIM_GROUP
425 #Temp var to check for image pull errors
428 #Function to check if image exist and stop+remove the container+pull new images as needed
429 #args <script-start-arg> <descriptive-image-name> <container-base-name> <image-with-tag>
430 __check_and_pull_image() {
432 echo -e " Checking $BOLD$2$EBOLD container(s) with basename: $BOLD$3$EBOLD using image: $BOLD$4$EBOLD"
433 format_string="\"{{.Repository}}\\t{{.Tag}}\\t{{.CreatedSince}}\\t{{.Size}}\""
434 tmp_im=$(docker images --format $format_string ${4})
436 if [ $1 == "local" ]; then
437 if [ -z "$tmp_im" ]; then
438 echo -e " "$2" (local image): \033[1m"$4"\033[0m $RED does not exist in local registry, need to be built (or manually pulled)"$ERED
442 echo -e " "$2" (local image): \033[1m"$4"\033[0m "$GREEN"OK"$EGREEN
444 elif [ $1 == "remote" ] || [ $1 == "remote-remove" ]; then
445 if [ $1 == "remote-remove" ]; then
446 echo -ne " Attempt to stop and remove container(s), if running - ${SAMELINE}"
447 tmp="$(docker ps -aq --filter name=${3})"
448 if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then
449 docker stop $tmp &> .dockererr
450 if [ $? -ne 0 ]; then
453 echo -e $RED" Container(s) could not be stopped - try manual stopping the container(s)"$ERED
458 echo -ne " Attempt to stop and remove container(s), if running - "$GREEN"stopped"$EGREEN"${SAMELINE}"
459 tmp="$(docker ps -aq --filter name=${3})" &> /dev/null
460 if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then
461 docker rm $tmp &> .dockererr
462 if [ $? -ne 0 ]; then
465 echo -e $RED" Container(s) could not be removed - try manual removal of the container(s)"$ERED
470 echo -e " Attempt to stop and remove container(s), if running - "$GREEN"stopped removed"$EGREEN
471 echo -ne " Removing image - ${SAMELINE}"
472 tmp="$(docker images -q ${4})" &> /dev/null
473 if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then
474 docker rmi $4 &> .dockererr
475 if [ $? -ne 0 ]; then
478 echo -e $RED" Image could not be removed - try manual removal of the image"$ERED
482 echo -e " Removing image - "$GREEN"removed"$EGREEN
484 echo -e " Removing image - "$GREEN"image not in repository"$EGREEN
488 if [ -z "$tmp_im" ]; then
489 echo -ne " Pulling image${SAMELINE}"
490 docker pull $4 &> .dockererr
491 tmp_im=$(docker images ${4} | grep -v REPOSITORY)
492 if [ -z "$tmp_im" ]; then
494 echo -e " Pulling image -$RED could not be pulled"$ERED
499 echo -e " Pulling image -$GREEN Pulled $EGREEN"
501 echo -e " Pulling image -$GREEN OK $EGREEN(exists in local repository)"
508 echo -e $BOLD"Pulling configured images, if needed"$EBOLD
510 START_ARG_MOD=$START_ARG
511 __check_image_local_override 'PA'
512 if [ $? -eq 1 ]; then
513 START_ARG_MOD="local"
515 app="Policy Agent"; __check_and_pull_image $START_ARG_MOD "$app" $POLICY_AGENT_APP_NAME $POLICY_AGENT_IMAGE
517 START_ARG_MOD=$START_ARG
518 __check_image_local_override 'CP'
519 if [ $? -eq 1 ]; then
520 START_ARG_MOD="local"
522 app="Non-RT RIC Control Panel"; __check_and_pull_image $START_ARG_MOD "$app" $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_IMAGE
524 START_ARG_MOD=$START_ARG
525 __check_image_local_override 'RICSIM'
526 if [ $? -eq 1 ]; then
527 START_ARG_MOD="local"
529 app="Near-RT RIC Simulator"; __check_and_pull_image $START_ARG_MOD "$app" $RIC_SIM_PREFIX"_"$RIC_SIM_BASE $RIC_SIM_IMAGE
531 app="Consul"; __check_and_pull_image $START_ARG "$app" $CONSUL_APP_NAME $CONSUL_IMAGE
532 app="CBS"; __check_and_pull_image $START_ARG "$app" $CBS_APP_NAME $CBS_IMAGE
533 __check_excluded_image 'SDNC'
534 if [ $? -eq 0 ]; then
535 START_ARG_MOD=$START_ARG
536 __check_image_local_override 'SDNC'
537 if [ $? -eq 1 ]; then
538 START_ARG_MOD="local"
540 app="SDNC A1 Controller"; __check_and_pull_image $START_ARG_MOD "$app" $SDNC_APP_NAME $SDNC_A1_CONTROLLER_IMAGE
541 app="SDNC DB"; __check_and_pull_image $START_ARG "$app" $SDNC_APP_NAME $SDNC_DB_IMAGE
543 echo -e $YELLOW" Excluding SDNC image and related DB image from image check/pull"$EYELLOW
545 __check_excluded_image 'SDNC_ONAP'
546 if [ $? -eq 0 ]; then
547 app="SDNC ONAP A1 Adapter"; __check_and_pull_image $START_ARG "$app" $SDNC_ONAP_APP_NAME $SDNC_ONAP_A1_ADAPTER_IMAGE
548 app="SDNC ONAP DB"; __check_and_pull_image $START_ARG "$app" $SDNC_ONAP_APP_NAME $SDNC_ONAP_DB_IMAGE
550 echo -e $YELLOW" Excluding ONAP SDNC image and related DB image from image check/pull"$EYELLOW
552 # MR stub image not checked, will be built by this script - only local image
553 # CR stub image not checked, will be built by this script - only local image
556 #Errors in image setting - exit
557 if [ $IMAGE_ERR -ne 0 ]; then
559 echo "#################################################################################################"
560 echo -e $RED"One or more images could not be pulled or containers using the images could not be stopped/removed"$ERED
561 echo -e $RED"Or local image, overriding remote image, does not exist"$ERED
562 echo "#################################################################################################"
569 echo -e $BOLD"Building images needed for test"$EBOLD
574 echo " Building mrstub image: mrstub:latest"
575 docker build -t mrstub . &> .dockererr
576 if [ $? -eq 0 ]; then
577 echo -e $GREEN" Build Ok"$EGREEN
579 echo -e $RED" Build Failed"$ERED
586 echo " Building Callback Receiver image: callback-receiver:latest"
587 docker build -t callback-receiver . &> .dockererr
588 if [ $? -eq 0 ]; then
589 echo -e $GREEN" Build Ok"$EGREEN
591 echo -e $RED" Build Failed"$ERED
599 # Create a table of the images used in the script
600 echo -e $BOLD"Local docker registry images used in the this test script"$EBOLD
602 docker_tmp_file=.docker-images-table
603 format_string="{{.Repository}}\\t{{.Tag}}\\t{{.CreatedSince}}\\t{{.Size}}"
604 echo -e " Application\tRepository\tTag\tCreated Since\tSize" > $docker_tmp_file
605 echo -e " Policy Agent\t$(docker images --format $format_string $POLICY_AGENT_IMAGE)" >> $docker_tmp_file
606 echo -e " Control Panel\t$(docker images --format $format_string $CONTROL_PANEL_IMAGE)" >> $docker_tmp_file
607 echo -e " RIC Simulator\t$(docker images --format $format_string $RIC_SIM_IMAGE)" >> $docker_tmp_file
608 echo -e " Message Router\t$(docker images --format $format_string $MRSTUB_IMAGE)" >> $docker_tmp_file
609 echo -e " Callback Receiver\t$(docker images --format $format_string $CR_IMAGE)" >> $docker_tmp_file
610 echo -e " Consul\t$(docker images --format $format_string $CONSUL_IMAGE)" >> $docker_tmp_file
611 echo -e " CBS\t$(docker images --format $format_string $CBS_IMAGE)" >> $docker_tmp_file
612 __check_excluded_image 'SDNC'
613 if [ $? -eq 0 ]; then
614 echo -e " SDNC A1 Controller\t$(docker images --format $format_string $SDNC_A1_CONTROLLER_IMAGE)" >> $docker_tmp_file
615 echo -e " SDNC DB\t$(docker images --format $format_string $SDNC_DB_IMAGE)" >> $docker_tmp_file
617 __check_excluded_image 'SDNC_ONAP'
618 if [ $? -eq 0 ]; then
619 echo -e " SDNC ONAP A1 Adapter\t$(docker images --format $format_string $SDNC_ONAP_A1_ADAPTER_IMAGE)" >> $docker_tmp_file
620 echo -e " SDNC ONAP DB\t$(docker images --format $format_string $SDNC_ONAP_DB_IMAGE)" >> $docker_tmp_file
623 column -t -s $'\t' $docker_tmp_file
627 echo -e $BOLD"======================================================="$EBOLD
628 echo -e $BOLD"== Common test setup completed - test script begins =="$EBOLD
629 echo -e $BOLD"======================================================="$EBOLD
632 # Function to print the test result, shall be the last cmd in a test script
634 # (Function for test scripts)
638 duration=$((TCTEST_END-TCTEST_START))
640 echo "-------------------------------------------------------------------------------------------------"
641 echo "------------------------------------- Test case: "$ATC
642 echo "------------------------------------- Ended: "$(date)
643 echo "-------------------------------------------------------------------------------------------------"
644 echo "-- Description: "$TC_ONELINE_DESCR
645 echo "-- Execution time: " $duration " seconds"
646 echo "-------------------------------------------------------------------------------------------------"
647 echo "------------------------------------- RESULTS"
651 if [ $RES_DEVIATION -gt 0 ]; then
652 echo "Test case deviations"
653 echo "===================================="
657 echo "Timer measurement in the test script"
658 echo "===================================="
659 column -t -s $'\t' $TIMER_MEASUREMENTS
662 total=$((RES_PASS+RES_FAIL))
663 if [ $RES_TEST -eq 0 ]; then
664 echo -e "\033[1mNo tests seem to have been executed. Check the script....\033[0m"
665 echo -e "\033[31m\033[1m ___ ___ ___ ___ ___ _____ ___ _ ___ _ _ _ ___ ___ \033[0m"
666 echo -e "\033[31m\033[1m/ __|/ __| _ \_ _| _ \_ _| | __/_\ |_ _| | | | | | _ \ __|\033[0m"
667 echo -e "\033[31m\033[1m\__ \ (__| /| || _/ | | | _/ _ \ | || |_| |_| | / _| \033[0m"
668 echo -e "\033[31m\033[1m|___/\___|_|_\___|_| |_| |_/_/ \_\___|____\___/|_|_\___|\033[0m"
669 elif [ $total != $RES_TEST ]; then
670 echo -e "\033[1mTotal number of tests does not match the sum of passed and failed tests. Check the script....\033[0m"
671 echo -e "\033[31m\033[1m ___ ___ ___ ___ ___ _____ ___ _ ___ _ _ _ ___ ___ \033[0m"
672 echo -e "\033[31m\033[1m/ __|/ __| _ \_ _| _ \_ _| | __/_\ |_ _| | | | | | _ \ __|\033[0m"
673 echo -e "\033[31m\033[1m\__ \ (__| /| || _/ | | | _/ _ \ | || |_| |_| | / _| \033[0m"
674 echo -e "\033[31m\033[1m|___/\___|_|_\___|_| |_| |_/_/ \_\___|____\___/|_|_\___|\033[0m"
675 elif [ $RES_CONF_FAIL -ne 0 ]; then
676 echo -e "\033[1mOne or more configure regest has failed. Check the script log....\033[0m"
677 echo -e "\033[31m\033[1m ___ ___ ___ ___ ___ _____ ___ _ ___ _ _ _ ___ ___ \033[0m"
678 echo -e "\033[31m\033[1m/ __|/ __| _ \_ _| _ \_ _| | __/_\ |_ _| | | | | | _ \ __|\033[0m"
679 echo -e "\033[31m\033[1m\__ \ (__| /| || _/ | | | _/ _ \ | || |_| |_| | / _| \033[0m"
680 echo -e "\033[31m\033[1m|___/\___|_|_\___|_| |_| |_/_/ \_\___|____\___/|_|_\___|\033[0m"
681 elif [ $RES_PASS = $RES_TEST ]; then
682 echo -e "All tests \033[32m\033[1mPASS\033[0m"
683 echo -e "\033[32m\033[1m ___ _ ___ ___ \033[0m"
684 echo -e "\033[32m\033[1m | _ \/_\ / __/ __| \033[0m"
685 echo -e "\033[32m\033[1m | _/ _ \\__ \__ \\ \033[0m"
686 echo -e "\033[32m\033[1m |_|/_/ \_\___/___/ \033[0m"
689 # Update test suite counter
690 if [ -f .tmp_tcsuite_pass_ctr ]; then
691 tmpval=$(< .tmp_tcsuite_pass_ctr)
693 echo $tmpval > .tmp_tcsuite_pass_ctr
695 if [ -f .tmp_tcsuite_pass ]; then
696 echo " - "$ATC " -- "$TC_ONELINE_DESCR" Execution time: "$duration" seconds" >> .tmp_tcsuite_pass
698 #Create file with OK exit code
699 echo "0" > "$PWD/.result$ATC.txt"
701 echo -e "One or more tests with status \033[31m\033[1mFAIL\033[0m "
702 echo -e "\033[31m\033[1m ___ _ ___ _ \033[0m"
703 echo -e "\033[31m\033[1m | __/_\ |_ _| | \033[0m"
704 echo -e "\033[31m\033[1m | _/ _ \ | || |__ \033[0m"
705 echo -e "\033[31m\033[1m |_/_/ \_\___|____|\033[0m"
707 # Update test suite counter
708 if [ -f .tmp_tcsuite_fail_ctr ]; then
709 tmpval=$(< .tmp_tcsuite_fail_ctr)
711 echo $tmpval > .tmp_tcsuite_fail_ctr
713 if [ -f .tmp_tcsuite_fail ]; then
714 echo " - "$ATC " -- "$TC_ONELINE_DESCR" Execution time: "$duration" seconds" >> .tmp_tcsuite_fail
718 echo "++++ Number of tests: "$RES_TEST
719 echo "++++ Number of passed tests: "$RES_PASS
720 echo "++++ Number of failed tests: "$RES_FAIL
722 echo "++++ Number of failed configs: "$RES_CONF_FAIL
724 echo "++++ Number of test case deviations: "$RES_DEVIATION
726 echo "------------------------------------- Test case complete ---------------------------------"
727 echo "-------------------------------------------------------------------------------------------------"
731 #####################################################################
732 ###### Functions for start, configuring, stoping, cleaning etc ######
733 #####################################################################
735 # Start timer for time measurement
736 # args - (any args will be printed though)
738 echo -e $BOLD"INFO(${BASH_LINENO[0]}): "${FUNCNAME[0]}"," $@ $EBOLD
740 echo " Timer started"
743 # Print the value of the time (in seconds)
744 # args - <timer message to print> - timer value and message will be printed both on screen
745 # and in the timer measurement report
747 echo -e $BOLD"INFO(${BASH_LINENO[0]}): "${FUNCNAME[0]}"," $@ $EBOLD
748 if [ $# -lt 1 ]; then
750 __print_err "need 1 or more args, <timer message to print>" $@
753 duration=$(($SECONDS-$TC_TIMER))
754 if [ $duration -eq 0 ]; then
757 duration=$duration" seconds"
759 echo " Timer duration :" $duration
761 echo -e "${@:1} \t $duration" >> $TIMER_MEASUREMENTS
764 # Print the value of the time (in seconds) and reset the timer
765 # args - <timer message to print> - timer value and message will be printed both on screen
766 # and in the timer measurement report
767 print_and_reset_timer() {
768 echo -e $BOLD"INFO(${BASH_LINENO[0]}): "${FUNCNAME[0]}"," $@ $EBOLD
769 if [ $# -lt 1 ]; then
771 __print_err "need 1 or more args, <timer message to print>" $@
774 duration=$(($SECONDS-$TC_TIMER))" seconds"
775 if [ $duration -eq 0 ]; then
778 duration=$duration" seconds"
780 echo " Timer duration :" $duration
784 echo -e "${@:1} \t $duration" >> $TIMER_MEASUREMENTS
787 # Print info about a deviations from intended tests
788 # Each deviation counted is also printed in the testreport
789 # args <deviation message to print>
791 echo -e $BOLD"DEVIATION(${BASH_LINENO[0]}): "${FUNCNAME[0]} $EBOLD
792 if [ $# -lt 1 ]; then
794 __print_err "need 1 or more args, <deviation message to print>" $@
798 echo -e $BOLD$YELLOW" Test case deviation: ${@:1}"$EYELLOW$EBOLD
799 echo "Line: ${BASH_LINENO[0]} - ${@:1}" >> $DEVIATION_FILE
803 # Stop at first FAIL test case and take all logs - only for debugging/trouble shooting
804 __check_stop_at_error() {
805 if [ $STOP_AT_ERROR -eq 1 ]; then
806 echo -e $RED"Test script configured to stop at first FAIL, taking all logs and stops"$ERED
807 store_logs "STOP_AT_ERROR"
813 # Stop and remove all containers
815 # (Function for test scripts)
818 echo -e $BOLD"Stopping and removing all running containers, by container name"$EBOLD
820 CONTAINTER_NAMES=("Policy Agent " $POLICY_AGENT_APP_NAME\
821 "Non-RT RIC Simulator(s)" $RIC_SIM_PREFIX\
822 "Message Router " $MR_APP_NAME\
823 "Callback Receiver " $CR_APP_NAME\
824 "Control Panel " $CONTROL_PANEL_APP_NAME\
825 "SDNC A1 Controller " $SDNC_APP_NAME\
826 "SDNC DB " $SDNC_DB_APP_NAME\
827 "SDNC ONAP A1 Adapter " $SDNC_ONAP_APP_NAME\
828 "SDNC DB " $SDNC_ONAP_DB_APP_NAME\
829 "CBS " $CBS_APP_NAME\
830 "Consul " $CONSUL_APP_NAME)
832 nw=0 # Calc max width of container name, to make a nice table
833 for (( i=1; i<${#CONTAINTER_NAMES[@]} ; i+=2 )) ; do
834 if [ ${#CONTAINTER_NAMES[i]} -gt $nw ]; then
835 nw=${#CONTAINTER_NAMES[i]}
839 for (( i=0; i<${#CONTAINTER_NAMES[@]} ; i+=2 )) ; do
840 APP="${CONTAINTER_NAMES[i]}"
841 CONTR="${CONTAINTER_NAMES[i+1]}"
842 for((w=${#CONTR}; w<$nw; w=w+1)); do
845 echo -ne " $APP: $CONTR - ${GREEN}stopping${EGREEN}${SAMELINE}"
846 docker stop $(docker ps -qa --filter name=${CONTR}) &> /dev/null
847 echo -ne " $APP: $CONTR - ${GREEN}stopped${EGREEN}${SAMELINE}"
848 docker rm --force $(docker ps -qa --filter name=${CONTR}) &> /dev/null
849 echo -e " $APP: $CONTR - ${GREEN}stopped removed${EGREEN}"
854 echo -e $BOLD" Removing docker network"$EBOLD
855 TMP=$(docker network ls -q --filter name=$DOCKER_SIM_NWNAME)
856 if [ "$TMP" == $DOCKER_SIM_NWNAME ]; then
857 docker network rm $DOCKER_SIM_NWNAME
858 if [ $? -ne 0 ]; then
859 echo -e $RED" Cannot remove docker network. Manually remove or disconnect containers from $DOCKER_SIM_NWNAME"$ERED
864 echo -e $BOLD" Removing all unused docker neworks"$EBOLD
865 docker network prune --force #&> /dev/null
867 echo -e $BOLD" Removing all unused docker volumes"$EBOLD
868 docker volume prune --force #&> /dev/null
870 echo -e $BOLD" Removing all dangling/untagged docker images"$EBOLD
871 docker rmi --force $(docker images -q -f dangling=true) &> /dev/null
874 CONTRS=$(docker ps | awk '$1 != "CONTAINER" { n++ }; END { print n+0 }')
875 if [ $? -eq 0 ]; then
876 if [ $CONTRS -ne 0 ]; then
877 echo -e $RED"Containers running, may cause distubance to the test case"$ERED
883 # Function stop and remove all container in the end of the test script, if the arg 'auto-clean' is given at test script start
885 # (Function for test scripts)
886 auto_clean_containers() {
888 if [ "$AUTO_CLEAN" == "auto" ]; then
889 echo -e $BOLD"Initiating automatic cleaning of started containers"$EBOLD
894 # Function to sleep a test case for a numner of seconds. Prints the optional text args as info
895 # args: <sleep-time-in-sec> [any-text-in-quotes-to-be-printed]
896 # (Function for test scripts)
899 echo -e $BOLD"INFO(${BASH_LINENO[0]}): "${FUNCNAME[0]}"," $@ $EBOLD
900 if [ $# -lt 1 ]; then
902 __print_err "need at least one arg, <sleep-time-in-sec> [any-text-to-printed]" $@
905 #echo "---- Sleep for " $1 " seconds ---- "$2
907 duration=$((SECONDS-start))
908 while [ $duration -lt $1 ]; do
909 echo -ne " Slept for ${duration} seconds${SAMELINE}"
911 duration=$((SECONDS-start))
913 echo -ne " Slept for ${duration} seconds${SAMELINE}"
917 # Print error info for the call in the parent script (test case). Arg: <error-message-to-print>
918 # Not to be called from the test script itself.
920 echo -e $RED ${FUNCNAME[1]} " "$1" " ${BASH_SOURCE[2]} " line" ${BASH_LINENO[1]} $ERED
921 if [ $# -gt 1 ]; then
922 echo -e $RED" Got: "${FUNCNAME[1]} ${@:2} $ERED
927 # Helper function to get a the port of a specific ric simulatpor
929 # (Not for test scripts)
931 name=$1" " #Space appended to prevent matching 10 if 1 is desired....
932 cmdstr="docker inspect --format='{{(index (index .NetworkSettings.Ports \"$RIC_SIM_PORT/tcp\") 0).HostPort}}' ${name}"
934 if [[ "$res" =~ ^[0-9]+$ ]]; then
941 # Function to create the docker network for the test
942 # Not to be called from the test script itself.
943 __create_docker_network() {
944 tmp=$(docker network ls --format={{.Name}} --filter name=$DOCKER_SIM_NWNAME)
945 if [ $? -ne 0 ]; then
946 echo -e $RED" Could not check if docker network $DOCKER_SIM_NWNAME exists"$ERED
949 if [ "$tmp" != $DOCKER_SIM_NWNAME ]; then
950 echo -e "Creating docker network:$BOLD $DOCKER_SIM_NWNAME $EBOLD"
951 docker network create $DOCKER_SIM_NWNAME
952 if [ $? -ne 0 ]; then
953 echo -e $RED" Could not create docker network $DOCKER_SIM_NWNAME"$ERED
957 echo -e " Docker network $DOCKER_SIM_NWNAME already exists$GREEN OK $EGREEN"
961 # Check if container is started by calling url on localhost using a port, expects response code 2XX
962 # args: <container-name> <port> <url> https|https
963 # Not to be called from the test script itself.
964 __check_container_start() {
966 if [ $# -ne 4 ]; then
968 elif [ $4 != "http" ] && [ $4 != "https" ]; then
971 if [ $paramError -ne 0 ]; then
973 __print_err "need 3 args, <container-name> <port> <url> https|https" $@
976 echo -ne " Container $BOLD$1$EBOLD starting${SAMELINE}"
980 if [[ $appname != "STANDALONE_"* ]] ; then
983 if [ "$(docker inspect --format '{{ .State.Running }}' $appname)" == "true" ]; then
984 echo -e " Container $BOLD$1$EBOLD$GREEN running$EGREEN on$BOLD image $(docker inspect --format '{{ .Config.Image }}' ${appname}) $EBOLD"
991 if [ $app_started -eq 0 ]; then
994 echo -e $RED" Container $BOLD${appname}$EBOLD could not be started"$ERED
997 if [ $localport -eq 0 ]; then
998 while [ $localport -eq 0 ]; do
999 echo -ne " Waiting for container ${appname} to publish its ports...${SAMELINE}"
1000 localport=$(__find_sim_port $appname)
1002 echo -ne " Waiting for container ${appname} to publish its ports...retrying....${SAMELINE}"
1004 echo -ne " Waiting for container ${appname} to publish its ports...retrying....$GREEN OK $EGREEN"
1010 echo -ne " Waiting for container ${appname} service status...${SAMELINE}"
1012 for i in {1..50}; do
1013 if [ $4 == "https" ]; then
1014 result="$(__do_curl "-k https://localhost:"${localport}${url})"
1016 result="$(__do_curl $LOCALHOST${localport}${url})"
1018 if [ $? -eq 0 ]; then
1019 if [ ${#result} -gt 15 ]; then
1020 #If response is too long, truncate
1021 result="...response text too long, omitted"
1023 echo -ne " Waiting for container $BOLD${appname}$EBOLD service status, result: $result${SAMELINE}"
1024 echo -ne " Container $BOLD${appname}$EBOLD$GREEN is alive$EGREEN, responds to service status:$GREEN $result $EGREEN after $(($SECONDS-$TSTART)) seconds"
1029 while [ $(($TS_TMP+$i)) -gt $SECONDS ]; do
1030 echo -ne " Waiting for container ${appname} service status...retrying in $(($TS_TMP+$i-$SECONDS)) seconds ${SAMELINE}"
1036 if [ "$pa_st" = "false" ]; then
1038 echo -e $RED" Container ${appname} did not respond to service status"$ERED
1047 # Function to start a container and wait until it responds on the given port and url.
1048 #args: <docker-compose-dir> NODOCKERARGS|<docker-compose-arg> <app-name> <port-number> <alive-url> [<app-name> <port-number> <alive-url>]*
1049 __start_container() {
1051 variableArgCount=$(($#-2))
1052 if [ $# -lt 6 ] && [ [ $(($variableArgCount%4)) -ne 0 ]; then
1054 __print_err "need 6 or more args, <docker-compose-dir> NODOCKERARGS|<docker-compose-arg> <app-name> <port-number> <alive-url> http|https [<app-name> <port-number> <alive-url> http|https ]*" $@
1058 __create_docker_network
1064 if [ "$2" == "NODOCKERARGS" ]; then
1065 docker-compose up -d &> .dockererr
1066 if [ $? -ne 0 ]; then
1067 echo -e $RED"Problem to launch container(s) with docker-compose"$ERED
1070 elif [ "$2" == "STANDALONE" ]; then
1071 echo "Skipping docker-compose"
1073 docker-compose up -d $2 &> .dockererr
1074 if [ $? -ne 0 ]; then
1075 echo -e $RED"Problem to launch container(s) with docker-compose"$ERED
1080 if [ "$2" == "STANDALONE" ]; then
1081 app_prefix="STANDALONE_"
1085 while [ $cntr -lt $variableArgCount ]; do
1086 app=$app_prefix$1; shift;
1092 __check_container_start "$app" "$port" "$url" $httpx
1100 # Generate a UUID to use as prefix for policy ids
1102 UUID=$(python3 -c 'import sys,uuid; sys.stdout.write(uuid.uuid4().hex)')
1103 #Reduce length to make space for serial id, us 'a' as marker where the serial id is added
1104 UUID=${UUID:0:${#UUID}-4}"a"
1107 ####################
1108 ### Consul functions
1109 ####################
1111 # Function to load config from a file into consul for the Policy Agent
1112 # arg: <json-config-file>
1113 # (Function for test scripts)
1114 consul_config_app() {
1116 echo -e $BOLD"Configuring Consul"$EBOLD
1118 if [ $# -ne 1 ]; then
1120 __print_err "need one arg, <json-config-file>" $@
1124 echo " Loading config for "$POLICY_AGENT_APP_NAME" from "$1
1126 curl -s $LOCALHOST${CONSUL_EXTERNAL_PORT}/v1/kv/${POLICY_AGENT_APP_NAME}?dc=dc1 -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data-binary "@"$1 >/dev/null
1127 if [ $? -ne 0 ]; then
1128 echo -e $RED" FAIL - json config could not be loaded to consul" $ERED
1132 body="$(__do_curl $LOCALHOST$CBS_EXTERNAL_PORT/service_component_all/$POLICY_AGENT_APP_NAME)"
1133 echo $body > ".output"$1
1135 if [ $? -ne 0 ]; then
1136 echo -e $RED" FAIL - json config could not be loaded from consul/cbs, contents cannot be checked." $ERED
1141 targetJson="{\"config\":"$targetJson"}"
1142 echo "TARGET JSON: $targetJson" >> $HTTPLOG
1143 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1144 if [ $res -ne 0 ]; then
1145 echo -e $RED" FAIL - policy json config read from consul/cbs is not equal to the intended json config...." $ERED
1149 echo -e $GREEN" Config loaded ok to consul"$EGREEN
1157 # Function to perpare the consul configuration according to the current simulator configuration
1158 # args: SDNC|SDNC_ONAP|NOSDNC <output-file>
1159 # (Function for test scripts)
1160 prepare_consul_config() {
1161 echo -e $BOLD"Prepare Consul config"$EBOLD
1163 echo " Writing consul config for "$POLICY_AGENT_APP_NAME" to file: "$2
1165 if [ $# != 2 ]; then
1167 __print_err "need two args, SDNC|SDNC_ONAP|NOSDNC <output-file>" $@
1171 if [ $1 == "SDNC" ]; then
1172 echo -e " Config$BOLD including SDNC$EBOLD configuration"
1173 elif [ $1 == "SDNC_ONAP" ]; then
1174 echo -e " Config$BOLD including SDNC ONAP$EBOLD configuration"
1175 elif [ $1 == "NOSDNC" ]; then
1176 echo -e " Config$BOLD excluding SDNC or SDNC ONAP$EBOLD configuration"
1179 __print_err "need two args, SDNC|SDNC_ONAP|NOSDNC <output-file>" $@
1184 if [ $1 == "SDNC" ]; then
1185 config_json=$config_json"\n \"controller\": ["
1186 config_json=$config_json"\n {"
1187 config_json=$config_json"\n \"name\": \"$SDNC_APP_NAME\","
1188 if [ $AGENT_STAND_ALONE -eq 0 ]; then
1189 config_json=$config_json"\n \"baseUrl\": \"$SDNC_HTTPX://$SDNC_APP_NAME:$SDNC_PORT\","
1191 config_json=$config_json"\n \"baseUrl\": \"$SDNC_HTTPX://localhost:$SDNC_LOCAL_PORT\","
1193 config_json=$config_json"\n \"userName\": \"$SDNC_USER\","
1194 config_json=$config_json"\n \"password\": \"$SDNC_PWD\""
1195 config_json=$config_json"\n }"
1196 config_json=$config_json"\n ],"
1198 if [ $1 == "SDNC_ONAP" ]; then
1199 config_json=$config_json"\n \"controller\": ["
1200 config_json=$config_json"\n {"
1201 config_json=$config_json"\n \"name\": \"$SDNC_ONAP_APP_NAME\","
1202 if [ $AGENT_STAND_ALONE -eq 0 ]; then
1203 config_json=$config_json"\n \"baseUrl\": \"http://$SDNC_ONAP_APP_NAME:$SDNC_ONAP_INTERNAL_PORT\","
1205 config_json=$config_json"\n \"baseUrl\": \"http://localhost:$SDNC_ONAP_EXTERNAL_PORT\","
1207 config_json=$config_json"\n \"userName\": \"$SDNC_ONAP_USER\","
1208 config_json=$config_json"\n \"password\": \"$SDNC_ONAP_PWD\""
1209 config_json=$config_json"\n }"
1210 config_json=$config_json"\n ],"
1214 config_json=$config_json"\n \"streams_publishes\": {"
1215 config_json=$config_json"\n \"dmaap_publisher\": {"
1216 config_json=$config_json"\n \"type\": \"$MR_APP_NAME\","
1217 config_json=$config_json"\n \"dmaap_info\": {"
1218 if [ $AGENT_STAND_ALONE -eq 0 ]; then
1219 config_json=$config_json"\n \"topic_url\": \"$MR_HTTPX://$MR_APP_NAME:$MR_PORT$MR_WRITE_URL\""
1221 config_json=$config_json"\n \"topic_url\": \"$MR_HTTPX://localhost:$MR_LOCAL_PORT$MR_WRITE_URL\""
1223 config_json=$config_json"\n }"
1224 config_json=$config_json"\n }"
1225 config_json=$config_json"\n },"
1226 config_json=$config_json"\n \"streams_subscribes\": {"
1227 config_json=$config_json"\n \"dmaap_subscriber\": {"
1228 config_json=$config_json"\n \"type\": \"$MR_APP_NAME\","
1229 config_json=$config_json"\n \"dmaap_info\": {"
1230 if [ $AGENT_STAND_ALONE -eq 0 ]; then
1231 config_json=$config_json"\n \"topic_url\": \"$MR_HTTPX://$MR_APP_NAME:$MR_PORT$MR_READ_URL\""
1233 config_json=$config_json"\n \"topic_url\": \"$MR_HTTPX://localhost:$MR_LOCAL_PORT$MR_READ_URL\""
1235 config_json=$config_json"\n }"
1236 config_json=$config_json"\n }"
1237 config_json=$config_json"\n },"
1239 config_json=$config_json"\n \"ric\": ["
1241 rics=$(docker ps | grep $RIC_SIM_PREFIX | awk '{print $NF}')
1243 if [ $? -ne 0 ] || [ -z "$rics" ]; then
1244 echo -e $RED" FAIL - the names of the running RIC Simulator cannot be retrieved." $ERED
1250 for ric in $rics; do
1251 if [ $cntr -gt 0 ]; then
1252 config_json=$config_json"\n ,"
1254 config_json=$config_json"\n {"
1255 config_json=$config_json"\n \"name\": \"$ric\","
1256 if [ $AGENT_STAND_ALONE -eq 0 ]; then
1257 config_json=$config_json"\n \"baseUrl\": \"$RIC_SIM_HTTPX://$ric:$RIC_SIM_PORT\","
1259 config_json=$config_json"\n \"baseUrl\": \"$RIC_SIM_HTTPX://localhost:$(__find_sim_port $ric)\","
1261 if [ $1 == "SDNC" ]; then
1262 config_json=$config_json"\n \"controller\": \"$SDNC_APP_NAME\","
1263 elif [ $1 == "SDNC_ONAP" ]; then
1264 config_json=$config_json"\n \"controller\": \"$SDNC_ONAP_APP_NAME\","
1266 config_json=$config_json"\n \"managedElementIds\": ["
1267 config_json=$config_json"\n \"me1_$ric\","
1268 config_json=$config_json"\n \"me2_$ric\""
1269 config_json=$config_json"\n ]"
1270 config_json=$config_json"\n }"
1274 config_json=$config_json"\n ]"
1275 config_json=$config_json"\n}"
1278 printf "$config_json">$2
1284 # Start Consul and CBS
1286 # (Function for test scripts)
1287 start_consul_cbs() {
1289 echo -e $BOLD"Starting Consul and CBS"$EBOLD
1291 __start_container consul_cbs NODOCKERARGS "$CONSUL_APP_NAME" "$CONSUL_EXTERNAL_PORT" "/ui/dc1/kv" "http" \
1292 "$CBS_APP_NAME" "$CBS_EXTERNAL_PORT" "/healthcheck" "http"
1295 ###########################
1296 ### RIC Simulator functions
1297 ###########################
1299 use_simulator_http() {
1300 echo -e "Using unsecure $BOLD http $EBOLD towards the simulators"
1301 export RIC_SIM_HTTPX="http"
1302 export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:"
1303 export RIC_SIM_PORT=$RIC_SIM_INTERNAL_PORT
1307 use_simulator_https() {
1308 echo -e "Using secure $BOLD https $EBOLD towards the simulators"
1309 export RIC_SIM_HTTPX="https"
1310 export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:"
1311 export RIC_SIM_PORT=$RIC_SIM_INTERNAL_SECURE_PORT
1315 # Start one group (ricsim_g1, ricsim_g2 or ricsim_g3) with a number of RIC Simulators using a given A interface
1316 # 'ricsim' may be set on command line to other prefix
1317 # args: ricsim_g1|ricsim_g2|ricsim_g3 <count> <interface-id>
1318 # (Function for test scripts)
1319 start_ric_simulators() {
1321 echo -e $BOLD"Starting RIC Simulators"$EBOLD
1323 RIC1=$RIC_SIM_PREFIX"_g1"
1324 RIC2=$RIC_SIM_PREFIX"_g2"
1325 RIC3=$RIC_SIM_PREFIX"_g3"
1327 if [ $# != 3 ]; then
1329 __print_err "need three args, $RIC1|$RIC2|$RIC3 <count> <interface-id>" $@
1332 echo " $2 simulators using basename: $1 on interface: $3"
1333 #Set env var for simulator count and A1 interface vesion for the given group
1334 if [ $1 == "$RIC1" ]; then
1337 elif [ $1 == "$RIC2" ]; then
1340 elif [ $1 == "$RIC3" ]; then
1345 __print_err "need three args, $RIC1|$RIC2|$RIC3 <count> <interface-id>" $@
1349 # Create .env file to compose project, all ric container will get this prefix
1350 echo "COMPOSE_PROJECT_NAME="$RIC_SIM_PREFIX > $SIM_GROUP/ric/.env
1352 export G1_A1_VERSION
1353 export G2_A1_VERSION
1354 export G3_A1_VERSION
1356 docker_args="--scale g1=$G1_COUNT --scale g2=$G2_COUNT --scale g3=$G3_COUNT"
1359 while [ $cntr -le $2 ]; do
1362 app_data="$app_data $app $port / "$RIC_SIM_HTTPX
1365 __start_container ric "$docker_args" $app_data
1369 ###########################
1370 ### Control Panel functions
1371 ###########################
1373 # Start the Control Panel container
1375 # (Function for test scripts)
1376 start_control_panel() {
1378 echo -e $BOLD"Starting Control Panel"$EBOLD
1380 __start_container control_panel NODOCKERARGS $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_EXTERNAL_PORT "/" "http"
1388 # Start the SDNC A1 Controller
1390 # (Function for test scripts)
1393 echo -e $BOLD"Starting SDNC A1 Controller"$EBOLD
1395 __check_excluded_image 'SDNC'
1396 if [ $? -eq 1 ]; then
1397 echo -e $RED"The image for SDNC and the related DB has not been checked for this test run due to arg to the test script"$ERED
1398 echo -e $RED"SDNC will not be started"$ERED
1402 __start_container sdnc NODOCKERARGS $SDNC_APP_NAME $SDNC_EXTERNAL_PORT $SDNC_ALIVE_URL "http"
1407 echo -e $BOLD"Using http between agent and SDNC"$EBOLD
1408 export SDNC_HTTPX="http"
1409 export SDNC_PORT=$SDNC_INTERNAL_PORT
1410 export SDNC_LOCAL_PORT=$SDNC_EXTERNAL_PORT
1415 echo -e $BOLD"Using https between agent and SDNC"$EBOLD
1416 export SDNC_HTTPX="https"
1417 export SDNC_PORT=$SDNC_INTERNAL_SECURE_PORT
1418 export SDNC_LOCAL_PORT=$SDNC_EXTERNAL_SECURE_PORT
1422 #######################
1423 ### SDNC ONAP functions
1424 #######################
1426 # Start the SDNC ONAP A1 Adapter
1428 # (Function for test scripts)
1431 echo -e $BOLD"Starting SDNC ONAP A1 Adapter"$EBOLD
1433 __check_excluded_image 'SDNC_ONAP'
1434 if [ $? -eq 1 ]; then
1435 echo -e $RED"The image for SDNC ONAP and the related DB has not been checked for this test run due to arg to the test script"$ERED
1436 echo -e $RED"SDNC ONAP will not be started"$ERED
1440 __start_container sdnc_onap NODOCKERARGS $SDNC_ONAP_APP_NAME $SDNC_ONAP_EXTERNAL_PORT $SDNC_ONAP_ALIVE_URL "http"
1444 # Configure the SDNC ONAP A1 Adapter
1446 # (Function for test scripts)
1447 config_sdnc_onap() {
1449 echo -e $BOLD"Configuring SDNC ONAP A1 Adapter"$EBOLD
1451 LOCALFILE=".sdnc_onap.prop"
1452 REMOTEFILE="/tmp/.sdnc_onap.prop"
1454 docker cp $SDNC_ONAP_APP_NAME:$SDNC_ONAP_PROPERTIES_FILE $LOCALFILE
1455 if [ $? -ne 0 ]; then
1456 echo -e $RED"Could not copy $SDNC_ONAP_PROPERTIES_FILE from $SDNC_ONAP_APP_NAME container"$ERED
1461 #Config of the prop file shall be inserted here
1463 #Copy file to /tmp and then to final destination, a trick to get correct permission of the file.
1465 docker cp $LOCALFILE $SDNC_ONAP_APP_NAME:$REMOTEFILE
1466 if [ $? -ne 0 ]; then
1467 echo -e $RED"Could not copy local $LOCALFILE to $REMOTEFILE in $SDNC_ONAP_APP_NAME container"$ERED
1471 docker exec -it $SDNC_ONAP_APP_NAME cp $REMOTEFILE $SDNC_ONAP_PROPERTIES_FILE
1472 if [ $? -ne 0 ]; then
1473 echo -e $RED"Could not copy $REMOTEFILE to $SDNC_ONAP_PROPERTIES_FILE in $SDNC_ONAP_APP_NAME container"$ERED
1478 #####################
1479 ### MR stub functions
1480 #####################
1482 # Start the Message Router stub interface in the simulator group
1484 # (Function for test scripts)
1487 echo -e $BOLD"Starting Message Router 'mrstub'"$EBOLD
1488 export MR_CERT_MOUNT_DIR="./cert"
1489 __start_container mr NODOCKERARGS $MR_APP_NAME $MR_EXTERNAL_PORT "/" "http"
1493 echo -e $BOLD"Using http between agent and MR"$EBOLD
1494 export MR_HTTPX="http"
1495 export MR_PORT=$MR_INTERNAL_PORT
1496 export MR_LOCAL_PORT=$MR_EXTERNAL_PORT
1501 echo -e $BOLD"Using https between agent and MR"$EBOLD
1502 export MR_HTTPX="https"
1503 export MR_PORT=$MR_INTERNAL_SECURE_PORT
1504 export MR_LOCAL_PORT=$MR_EXTERNAL_SECURE_PORT
1513 # Start the Callback reciver in the simulator group
1515 # (Function for test scripts)
1518 echo -e $BOLD"Starting Callback Receiver"$EBOLD
1520 __start_container cr NODOCKERARGS $CR_APP_NAME $CR_EXTERNAL_PORT "/" "http"
1525 echo -e $BOLD"Using http between test script and CR"$EBOLD
1526 export CR_HTTPX="http"
1527 export CR_PORT=$CR_INTERNAL_PORT
1528 export CR_LOCAL_PORT=$CR_EXTERNAL_PORT
1533 echo -e $BOLD"Using https between test script and CR"$EBOLD
1534 export CR_HTTPX="https"
1535 export CR_PORT=$CR_INTERNAL_SECURE_PORT
1536 export CR_LOCAL_PORT=$CR_EXTERNAL_SECURE_PORT
1540 ###########################
1541 ### Policy Agents functions
1542 ###########################
1544 # Use an agent on the local machine instead of container
1545 use_agent_stand_alone() {
1549 # Start the policy agent
1551 # (Function for test scripts)
1552 start_policy_agent() {
1554 echo -e $BOLD"Starting Policy Agent"$EBOLD
1556 if [ $AGENT_STAND_ALONE -eq 0 ]; then
1557 __start_container policy_agent NODOCKERARGS $POLICY_AGENT_APP_NAME $POLICY_AGENT_EXTERNAL_PORT "/status" "http"
1559 echo -e $RED"The consul config produced by this test script (filename '<fullpath-to-autotest-dir>.output<file-name>"$ERED
1560 echo -e $RED"where the file name is the file in the consul_config_app command in this script) must be pointed out by the agent "$ERED
1561 echo -e $RED"application.yaml"$ERED
1562 echo -e $RED"The application jar may need to be built beforefor continuing"$ERED
1563 echo -e $RED"The agent shall now be running on port $POLICY_AGENT_EXTERNAL_PORT for http"$ERED
1565 read -p "<press any key to continue>"
1566 __start_container policy_agent "STANDALONE" $POLICY_AGENT_APP_NAME $POLICY_AGENT_EXTERNAL_PORT "/status" "http"
1571 # All calls to the agent will be directed to the agent REST interface from now on
1573 # (Function for test scripts)
1574 use_agent_rest_http() {
1575 echo -e $BOLD"Using agent REST interface with http"$EBOLD
1576 export ADAPTER=$RESTBASE
1580 # All calls to the agent will be directed to the agent REST interface from now on
1582 # (Function for test scripts)
1583 use_agent_rest_https() {
1584 echo -e $BOLD"Using agent REST interface with https"$EBOLD
1585 export ADAPTER=$RESTBASE_SECURE
1590 # All calls to the agent will be directed to the agent dmaap interface over http from now on
1592 # (Function for test scripts)
1593 use_agent_dmaap_http() {
1594 echo -e $BOLD"Agent using DMAAP http interface"$EBOLD
1595 export ADAPTER=$DMAAPBASE
1600 # All calls to the agent will be directed to the agent dmaap interface over https from now on
1602 # (Function for test scripts)
1603 use_agent_dmaap_https() {
1604 echo -e $BOLD"Agent using DMAAP https interface"$EBOLD
1605 export ADAPTER=$DMAAPBASE_SECURE
1610 # Turn on debug level tracing in the agent
1612 # (Function for test scripts)
1614 echo -e $BOLD"Setting agent debug"$EBOLD
1615 curl $LOCALHOST$POLICY_AGENT_EXTERNAL_PORT/actuator/loggers/org.oransc.policyagent -X POST -H 'Content-Type: application/json' -d '{"configuredLevel":"debug"}' &> /dev/null
1616 if [ $? -ne 0 ]; then
1617 __print_err "could not set debug mode" $@
1624 # Turn on trace level tracing in the agent
1626 # (Function for test scripts)
1628 echo -e $BOLD"Setting agent trace"$EBOLD
1629 curl $LOCALHOST$POLICY_AGENT_EXTERNAL_PORT/actuator/loggers/org.oransc.policyagent -X POST -H 'Content-Type: application/json' -d '{"configuredLevel":"trace"}' &> /dev/null
1630 if [ $? -ne 0 ]; then
1631 __print_err "could not set trace mode" $@
1638 # Perform curl retries when making direct call to the agent for the specified http response codes
1639 # Speace separated list of http response codes
1640 # args: [<response-code>]*
1641 use_agent_retries() {
1642 echo -e $BOLD"Do curl retries to the agent REST inteface for these response codes:$@"$EBOLD
1643 AGENT_RETRY_CODES=$@
1652 # Check the agent logs for WARNINGs and ERRORs
1654 # (Function for test scripts)
1656 check_policy_agent_logs() {
1657 __check_container_logs "Policy Agent" $POLICY_AGENT_APP_NAME $POLICY_AGENT_LOGPATH
1660 check_control_panel_logs() {
1661 __check_container_logs "Control Panel" $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_LOGPATH
1664 __check_container_logs() {
1668 echo -e $BOLD"Checking $dispname container $appname log ($logpath) for WARNINGs and ERRORs"$EBOLD
1670 #tmp=$(docker ps | grep $appname)
1671 tmp=$(docker ps -q --filter name=$appname) #get the container id
1672 if [ -z "$tmp" ]; then #Only check logs for running Policy Agent apps
1673 echo $dispname" is not running, no check made"
1676 foundentries="$(docker exec -it $tmp grep WARN $logpath | wc -l)"
1677 if [ $? -ne 0 ];then
1678 echo " Problem to search $appname log $logpath"
1680 if [ $foundentries -eq 0 ]; then
1681 echo " No WARN entries found in $appname log $logpath"
1683 echo -e " Found \033[1m"$foundentries"\033[0m WARN entries in $appname log $logpath"
1686 foundentries="$(docker exec -it $tmp grep ERR $logpath | wc -l)"
1687 if [ $? -ne 0 ];then
1688 echo " Problem to search $appname log $logpath"
1690 if [ $foundentries -eq 0 ]; then
1691 echo " No ERR entries found in $appname log $logpath"
1693 echo -e $RED" Found \033[1m"$foundentries"\033[0m"$RED" ERR entries in $appname log $logpath"$ERED
1699 # Store all container logs and other logs in the log dir for the script
1700 # Logs are stored with a prefix in case logs should be stored several times during a test
1701 # args: <logfile-prefix>
1702 # (Function for test scripts)
1704 if [ $# != 1 ]; then
1706 __print_err "need one arg, <file-prefix>" $@
1709 echo -e $BOLD"Storing all container logs, Policy Agent app log and consul config using prefix: "$1$EBOLD
1711 docker stats --no-stream > $TESTLOGS/$ATC/$1_docker_stats.log 2>&1
1712 docker logs $CONSUL_APP_NAME > $TESTLOGS/$ATC/$1_consul.log 2>&1
1713 docker logs $CBS_APP_NAME > $TESTLOGS/$ATC/$1_cbs.log 2>&1
1714 docker logs $POLICY_AGENT_APP_NAME > $TESTLOGS/$ATC/$1_policy-agent.log 2>&1
1715 docker logs $CONSUL_APP_NAME > $TESTLOGS/$ATC/$1_control-panel.log 2>&1
1716 docker logs $MR_APP_NAME > $TESTLOGS/$ATC/$1_mr.log 2>&1
1717 docker logs $CR_APP_NAME > $TESTLOGS/$ATC/$1_cr.log 2>&1
1718 cp .httplog_${ATC}.txt $TESTLOGS/$ATC/$1_httplog_${ATC}.txt 2>&1
1720 docker exec -it $SDNC_APP_NAME cat $SDNC_KARAF_LOG> $TESTLOGS/$ATC/$1_SDNC_karaf.log 2>&1
1722 docker exec -it $SDNC_ONAP_APP_NAME cat $SDNC_ONAP_KARAF_LOG > $TESTLOGS/$ATC/$1_SDNC_ONAP_karaf.log 2>&1
1724 rics=$(docker ps -f "name=$RIC_SIM_PREFIX" --format "{{.Names}}")
1725 for ric in $rics; do
1726 docker logs $ric > $TESTLOGS/$ATC/$1_$ric.log 2>&1
1728 body="$(__do_curl $LOCALHOST$CBS_EXTERNAL_PORT/service_component_all/$POLICY_AGENT_APP_NAME)"
1729 echo "$body" > $TESTLOGS/$ATC/$1_consul_config.json 2>&1
1736 # Generic curl function, assumed all 200-codes are ok
1738 # returns: <returned response (without respose code)> or "<no-response-from-server>" or "<not found, <http-code>>""
1739 # returns: The return code is 0 for ok and 1 for not ok
1741 echo ${FUNCNAME[1]} "line: "${BASH_LINENO[1]} >> $HTTPLOG
1742 curlString="curl -skw %{http_code} $1"
1743 echo " CMD: $curlString" >> $HTTPLOG
1745 echo " RESP: $res" >> $HTTPLOG
1746 http_code="${res:${#res}-3}"
1747 if [ ${#res} -eq 3 ]; then
1748 echo "<no-response-from-server>"
1751 if [ $http_code -lt 200 ] || [ $http_code -gt 299 ]; then
1752 echo "<not found, resp:${http_code}>"
1755 if [ $# -eq 2 ]; then
1756 echo "${res:0:${#res}-3}" | xargs
1758 echo "${res:0:${#res}-3}"
1765 #######################################
1766 ### Basic helper function for test cases
1767 #######################################
1769 # Test a simulator container variable value towards target value using an condition operator with an optional timeout.
1770 # Arg: <simulator-name> <host> <variable-name> <condition-operator> <target-value> - This test is done
1771 # immediately and sets pass or fail depending on the result of comparing variable and target using the operator.
1772 # Arg: <simulator-name> <host> <variable-name> <condition-operator> <target-value> <timeout> - This test waits up to the timeout
1773 # before setting pass or fail depending on the result of comparing variable and target using the operator.
1774 # If the <variable-name> has the 'json:' prefix, the the variable will be used as url and the <target-value> will be compared towards the length of the json array in the response.
1775 # Not to be called from test script.
1778 checkjsonarraycount=0
1780 if [ $# -eq 6 ]; then
1781 if [[ $3 == "json:"* ]]; then
1782 checkjsonarraycount=1
1785 echo -e $BOLD"TEST(${BASH_LINENO[1]}): ${1}, ${3} ${4} ${5} within ${6} seconds"$EBOLD
1790 if [ $checkjsonarraycount -eq 0 ]; then
1791 result="$(__do_curl $2$3)"
1793 result=${result//[[:blank:]]/} #Strip blanks
1796 result="$(__do_curl $2$path)"
1798 echo "$result" > .tmp.curl.json
1799 result=$(python3 ../common/count_json_elements.py ".tmp.curl.json")
1801 duration=$((SECONDS-start))
1802 echo -ne " Result=${result} after ${duration} seconds${SAMELINE}"
1804 if [ $retcode -ne 0 ]; then
1805 if [ $duration -gt $6 ]; then
1807 echo -e $RED" FAIL${ERED} - ${3} ${4} ${5} not reached in ${6} seconds, result = ${result}"
1808 __check_stop_at_error
1811 elif [ $4 = "=" ] && [ "$result" -eq $5 ]; then
1813 echo -e " Result=${result} after ${duration} seconds${SAMELINE}"
1814 echo -e $GREEN" PASS${EGREEN} - Result=${result} after ${duration} seconds"
1816 elif [ $4 = ">" ] && [ "$result" -gt $5 ]; then
1818 echo -e " Result=${result} after ${duration} seconds${SAMELINE}"
1819 echo -e $GREEN" PASS${EGREEN} - Result=${result} after ${duration} seconds"
1821 elif [ $4 = "<" ] && [ "$result" -lt $5 ]; then
1823 echo -e " Result=${result} after ${duration} seconds${SAMELINE}"
1824 echo -e $GREEN" PASS${EGREEN} - Result=${result} after ${duration} seconds"
1826 elif [ $4 = "contain_str" ] && [[ $result =~ $5 ]]; then
1828 echo -e " Result=${result} after ${duration} seconds${SAMELINE}"
1829 echo -e $GREEN" PASS${EGREEN} - Result=${result} after ${duration} seconds"
1832 if [ $duration -gt $6 ]; then
1834 echo -e $RED" FAIL${ERED} - ${3} ${4} ${5} not reached in ${6} seconds, result = ${result}"
1835 __check_stop_at_error
1841 elif [ $# -eq 5 ]; then
1842 if [[ $3 == "json:"* ]]; then
1843 checkjsonarraycount=1
1846 echo -e $BOLD"TEST(${BASH_LINENO[1]}): ${1}, ${3} ${4} ${5}"$EBOLD
1848 if [ $checkjsonarraycount -eq 0 ]; then
1849 result="$(__do_curl $2$3)"
1851 result=${result//[[:blank:]]/} #Strip blanks
1854 result="$(__do_curl $2$path)"
1856 echo "$result" > .tmp.curl.json
1857 result=$(python3 ../common/count_json_elements.py ".tmp.curl.json")
1859 if [ $retcode -ne 0 ]; then
1861 echo -e $RED" FAIL ${ERED}- ${3} ${4} ${5} not reached, result = ${result}"
1862 __check_stop_at_error
1863 elif [ $4 = "=" ] && [ "$result" -eq $5 ]; then
1865 echo -e $GREEN" PASS${EGREEN} - Result=${result}"
1866 elif [ $4 = ">" ] && [ "$result" -gt $5 ]; then
1868 echo -e $GREEN" PASS${EGREEN} - Result=${result}"
1869 elif [ $4 = "<" ] && [ "$result" -lt $5 ]; then
1871 echo -e $GREEN" PASS${EGREEN} - Result=${result}"
1872 elif [ $4 = "contain_str" ] && [[ $result =~ $5 ]]; then
1874 echo -e $GREEN" PASS${EGREEN} - Result=${result}"
1877 echo -e $RED" FAIL${ERED} - ${3} ${4} ${5} not reached, result = ${result}"
1878 __check_stop_at_error
1881 echo "Wrong args to __var_test, needs five or six args: <simulator-name> <host> <variable-name> <condition-operator> <target-value> [ <timeout> ]"
1888 ### Generic test cases for varaible checking
1890 # Tests if a variable value in the CR is equal to a target value and and optional timeout.
1891 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
1892 # equal to the target or not.
1893 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
1894 # before setting pass or fail depending on if the variable value becomes equal to the target
1896 # (Function for test scripts)
1898 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
1899 __var_test "CR" "$LOCALHOST$CR_EXTERNAL_PORT/counter/" $1 "=" $2 $3
1902 __print_err "Wrong args to cr_equal, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
1906 # Tests if a variable value in the MR stub is equal to a target value and and optional timeout.
1907 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
1908 # equal to the target or not.
1909 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
1910 # before setting pass or fail depending on if the variable value becomes equal to the target
1912 # (Function for test scripts)
1914 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
1915 __var_test "MR" "$LOCALHOST$MR_EXTERNAL_PORT/counter/" $1 "=" $2 $3
1918 __print_err "Wrong args to mr_equal, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
1922 # Tests if a variable value in the MR stub is greater than a target value and and optional timeout.
1923 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
1924 # greater than the target or not.
1925 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
1926 # before setting pass or fail depending on if the variable value becomes greater than the target
1928 # (Function for test scripts)
1930 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
1931 __var_test "MR" "$LOCALHOST$MR_EXTERNAL_PORT/counter/" $1 ">" $2 $3
1934 __print_err "Wrong args to mr_greater, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
1938 # Read a variable value from MR sim and send to stdout. Arg: <variable-name>
1940 echo "$(__do_curl $LOCALHOST$MR_EXTERNAL_PORT/counter/$1)"
1943 # Print a variable value from the MR stub.
1944 # arg: <variable-name>
1945 # (Function for test scripts)
1947 if [ $# != 1 ]; then
1949 __print_err "need one arg, <mr-param>" $@
1952 echo -e $BOLD"INFO(${BASH_LINENO[0]}): mrstub, $1 = $(__do_curl $LOCALHOST$MR_EXTERNAL_PORT/counter/$1)"$EBOLD