3 # Modifications copyright (C) 2021 Nokia. All rights reserved
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
12 . ../common/test_env.sh
16 echo "Test case started as: ${BASH_SOURCE[$i+1]} "$1 $2
18 # Script containing all functions needed for auto testing of test cases
19 # Arg: local [<image-tag>] ]| remote [<image-tag>] ]| remote-remove [<image-tag>]] | manual-container | manual-app
21 STARTED_DFCS="" #DFC app names added to this var to keep track of started container in the script
26 if [[ "$2" =~ ^1.1.* ]]; then
27 echo "This version of auto-test does not support DFC image version of 1.1.X"
33 if [ $# -lt 1 ] || [ $# -gt 2 ]; then
34 echo "Expected arg: local [<image-tag>] ]| remote [<image-tag>] ]| remote-remove [<image-tag>]] | manual-container | manual-app"
36 elif [ $1 == "local" ]; then
37 if [ -z $DFC_LOCAL_IMAGE ]; then
38 echo "DFC_LOCAL_IMAGE not set in test_env"
41 DFC_IMAGE=$DFC_LOCAL_IMAGE":"$IMAGE_TAG
42 elif [ $1 == "remote" ] || [ $1 == "remote-remove" ]; then
43 if [ -z $DFC_REMOTE_IMAGE ]; then
44 echo "DFC_REMOTE_IMAGE not set in test_env"
47 DFC_IMAGE=$DFC_REMOTE_IMAGE":"$IMAGE_TAG
48 elif [ $1 == "manual-container" ] && [ $# -eq 1 ]; then
49 echo "DFC is expected to be started manually, when prompted, as a container with name 'dfc_app'<index> with and index in the range from 0 to '${DFC_MAX_IDX}'"
50 elif [ $1 == "manual-app" ] && [ $# -eq 1 ]; then
51 echo "DFC is expected to be started manually, when prompted, as a java application"
53 echo "Expected arg: local [<image-tag>] ]| remote [<image-tag>] ]| remote-remove [<image-tag>]] | manual-container | manual-app"
57 # Set a description string for the test case
58 if [ -z "$TC_ONELINE_DESCR" ]; then
59 TC_ONELINE_DESCR="<no-description>"
60 echo "No test case description found, TC_ONELINE_DESCR should be set on in the test script , using "$TC_ONELINE_DESCR
63 # Counter for test suites
64 if [ -f .tmp_tcsuite_ctr ]; then
65 tmpval=$(< .tmp_tcsuite_ctr)
67 echo $tmpval > .tmp_tcsuite_ctr
70 # Create a test case id, ATC (Auto Test Case), from the name of the test case script.
71 # FTC1.sh -> ATC == FTC1
72 ATC=$(basename "${BASH_SOURCE[$i+1]}" .sh)
74 # Create the logs dir if not already created in the current dir
75 if [ ! -d "logs" ]; then
81 # Create a log dir for the test case
82 mkdir -p $TESTLOGS/$ATC
84 # Clear the log dir for the test case
85 rm $TESTLOGS/$ATC/*.log &> /dev/null
87 # Log all output from the test case to a TC log
88 TCLOG=$TESTLOGS/$ATC/TC.log
89 exec &> >(tee ${TCLOG})
91 #Variables for counting tests as well as passed and failed tests
97 echo "-------------------------------------------------------------------------------------------------"
98 echo "----------------------------------- Test case: "$ATC
99 echo "----------------------------------- Started: "$(date)
100 echo "-------------------------------------------------------------------------------------------------"
101 echo "-- Description: "$TC_ONELINE_DESCR
102 echo "-------------------------------------------------------------------------------------------------"
103 echo "----------------------------------- Test case setup -----------------------------------"
105 if [ -z "$SIM_GROUP" ]; then
106 SIM_GROUP=$PWD/../simulator-group
107 if [ ! -d $SIM_GROUP ]; then
108 echo "Trying to set env var SIM_GROUP to dir 'simulator-group' in the integration repo, but failed."
109 echo "Please set the SIM_GROUP manually in the test_env.sh"
112 echo "SIM_GROUP auto set to: " $SIM_GROUP
114 elif [ $SIM_GROUP = *simulator_group ]; then
115 echo "Env var SIM_GROUP does not seem to point to dir 'simulator-group' in the integration repo, check test_env.sh"
121 if [ $1 != "manual-container" ] && [ $1 != "manual-app" ]; then
122 echo -e "DFC image tag set to: \033[1m" $IMAGE_TAG"\033[0m"
123 echo "Configured image for DFC app(s) (${1}): "$DFC_IMAGE
124 tmp_im=$(docker images ${DFC_IMAGE} | grep -v REPOSITORY)
126 if [ $1 == "local" ]; then
127 if [ -z "$tmp_im" ]; then
128 echo "Local image (non nexus) "$DFC_IMAGE" does not exist in local registry, need to be built"
131 echo -e "DFC local image: \033[1m"$tmp_im"\033[0m"
132 echo "If the DFC image seem outdated, rebuild the image and run the test again."
134 elif [ $1 == "remote" ] || [ $1 == "remote-remove" ]; then
136 if [ $1 == "remote-remove" ]; then
137 echo "Attempt to stop dfc_app container(s) if running"
138 docker stop $(docker ps -q --filter name=${DFC_APP_BASE}]) &> /dev/null
139 docker rm $(docker ps -q --filter name=${DFC_APP_BASE}) &> /dev/null
140 docker rmi $DFC_IMAGE &> /dev/null
143 if [ -z "$tmp_im" ]; then
144 echo "Pulling DFC image from nexus: "$DFC_IMAGE
145 docker pull $DFC_IMAGE > /dev/null
146 tmp_im=$(docker images ${DFC_IMAGE} | grep -v REPOSITORY)
147 if [ -z "$tmp_im" ]; then
148 echo "Image could not be pulled"
151 echo -e "DFC image: \033[1m"$tmp_im"\033[0m"
153 echo -e "DFC image: \033[1m"$tmp_im"\033[0m"
154 echo "!! If the dfc image seem outdated, consider removing it from your docker registry and run the test again. Or run the script with 'remote-remove'"
163 echo "Building images for the simulators if needed, MR, DR, DR Redir, FTPES and HTTP simulators"
167 docker build -t drsim_common:latest . &> /dev/null
169 docker build -t mrsim:latest . &> /dev/null
170 cd ../ftpes-sftp-server
171 docker build -t ftpes_vsftpd:latest -f Dockerfile-ftpes . &> /dev/null
172 cd ../http-https-server
173 docker build -t http_https_httpd:latest -f Dockerfile-http-https . &> /dev/null
178 echo "Local registry images for simulators:"
179 echo "MR simulator " $(docker images | grep mrsim)
180 echo "DR simulator: " $(docker images | grep drsim_common)
181 echo "DR redir simulator: " $(docker images | grep drsim_common)
182 echo "SFTP: " $(docker images | grep atmoz/sftp)
183 echo "FTPES: " $(docker images | grep ftpes_vsftpd)
184 echo "HTTP/HTTPS/HTTPS no auth: " $(docker images | grep http_https_httpd)
185 echo "Consul: " $(docker images | grep consul)
186 echo "CBS: " $(docker images | grep platform.configbinding.app)
189 #Configure MR sim to use correct host:port for running dfc as an app or as a container
190 #Configure DR sim with correct address for DR redirect simulator
191 if [ $START_ARG == "manual-app" ]; then
192 export SFTP_SIMS=$SFTP_SIMS_LOCALHOST
193 export FTPES_SIMS=$FTPES_SIMS_LOCALHOST
194 export HTTP_SIMS=$HTTP_SIMS_LOCALHOST
195 export HTTPS_SIMS=$HTTPS_SIMS_LOCALHOST
196 export HTTPS_SIMS_NO_AUTH=HTTPS_SIMS_NO_AUTH_LOCALHOST
197 export DR_REDIR_SIM="localhost"
200 # export SFTP_SIMS=$SFTP_SIMS_CONTAINER
201 # export FTPES_SIMS=$FTPES_SIMS_CONTAINER
202 # export DR_REDIR_SIM="drsim_redir"
205 echo "----------------------------------- Test case steps -----------------------------------"
207 # Print error info for the call in the parent script (test case). Arg: <error-message-to-print>
208 # Not to be called from test script.
210 echo ${FUNCNAME[1]} " "$1" " ${BASH_SOURCE[$i+2]} " line" ${BASH_LINENO[$i+1]}
212 # Execute curl using the host and variable. Arg: <host and variable-name> [ <flag-to-strip-new-line> ]
213 #<flag-to-strip-new-line> may contain any string, it is just a flag
214 # Returns the variable value (if success) and return code 0 or an error message and return code 1
216 res=$(curl -skw "%{http_code}" $1)
217 http_code="${res:${#res}-3}"
218 if [ ${#res} -eq 3 ]; then
219 echo "<no-response-from-server>"
222 if [ $http_code -lt 200 ] && [ $http_code -gt 299 ]; then
223 echo "<not found, resp:${http_code}>"
226 if [ $# -eq 2 ]; then
227 echo "${res:0:${#res}-3}" | xargs
229 echo "${res:0:${#res}-3}"
236 # Test a simulator variable value towards target value using an condition operator with an optional timeout.
237 # Arg: <simulator-name> <host> <variable-name> <condition-operator> <target-value> - This test is done
238 # immediately and sets pass or fail depending on the result of comparing variable and target using the operator.
239 # Arg: <simulator-name> <host> <variable-name> <condition-operator> <target-value> <timeout> - This test waits up to the timeout
240 # before setting pass or fail depending on the result of comparing variable and target using the operator.
241 # Not to be called from test script.
244 if [ $# -eq 6 ]; then
245 echo -e "---- ${1} sim test criteria: \033[1m ${3} \033[0m ${4} ${5} within ${6} seconds ----"
251 result="$(__do_curl $2$3)"
253 result=${result//[[:blank:]]/} #Strip blanks
254 duration=$((SECONDS-start))
255 if [ $((ctr%30)) -eq 0 ]; then
256 echo " Result=${result} after ${duration} seconds"
257 for (( i=0; i<=$DFC_MAX_IDX; i++ )); do
258 if [[ $STARTED_DFCS =~ "_"$DFC_APP_BASE$i"_" ]]; then
259 echo " HB ${DFC_APP_BASE}${i}: $(__do_curl http://127.0.0.1:$(($DFC_PORT+$i))/status strip)"
263 echo -ne " Result=${result} after ${duration} seconds\033[0K\r"
266 if [ $retcode -ne 0 ]; then
267 if [ $duration -gt $6 ]; then
269 echo -e "---- \033[31m\033[1mFAIL\033[0m - Target ${3} ${4} ${5} not reached in ${6} seconds, result = ${result} ----"
272 elif [ $4 = "=" ] && [ "$result" -eq $5 ]; then
274 echo -e " Result=${result} after ${duration} seconds\033[0K\r"
275 echo -e "---- \033[32m\033[1mPASS\033[0m - Test criteria met in ${duration} seconds ----"
277 elif [ $4 = ">" ] && [ "$result" -gt $5 ]; then
279 echo -e " Result=${result} after ${duration} seconds\033[0K\r"
280 echo -e "---- \033[32m\033[1mPASS\033[0m - Test criteria met in ${duration} seconds, result = ${result} ----"
282 elif [ $4 = "<" ] && [ "$result" -lt $5 ]; then
284 echo -e " Result=${result} after ${duration} seconds\033[0K\r"
285 echo -e "---- \033[32m\033[1mPASS\033[0m - Test criteria met in ${duration} seconds, result = ${result} ----"
287 elif [ $4 = "contain_str" ] && [[ $result =~ $5 ]]; then
289 echo -e " Result=${result} after ${duration} seconds\033[0K\r"
290 echo -e "---- \033[32m\033[1mPASS\033[0m - Test criteria met in ${duration} seconds, result = ${result} ----"
293 if [ $duration -gt $6 ]; then
295 echo -e "---- \033[31m\033[1mFAIL\033[0m - Target ${3} ${4} ${5} not reached in ${6} seconds, result = ${result} ----"
301 elif [ $# -eq 5 ]; then
302 echo -e "---- ${1} sim test criteria: \033[1m ${3} \033[0m ${4} ${5} ----"
304 result="$(__do_curl $2$3)"
306 result=${result//[[:blank:]]/} #Strip blanks
307 if [ $retcode -ne 0 ]; then
309 echo -e "---- \033[31m\033[1mFAIL\033[0m - Target ${3} ${4} ${5} not reached, result = ${result} ----"
310 elif [ $4 = "=" ] && [ "$result" -eq $5 ]; then
312 echo -e "---- \033[32m\033[1mPASS\033[0m - Test criteria met"
313 elif [ $4 = ">" ] && [ "$result" -gt $5 ]; then
315 echo -e "---- \033[32m\033[1mPASS\033[0m - Test criteria met, result = ${result} ----"
316 elif [ $4 = "<" ] && [ "$result" -lt $5 ]; then
318 echo -e "---- \033[32m\033[1mPASS\033[0m - Test criteria met, result = ${result} ----"
319 elif [ $4 = "contain_str" ] && [[ $result =~ $5 ]]; then
321 echo -e "---- \033[32m\033[1mPASS\033[0m - Test criteria met, result = ${result} ----"
324 echo -e "---- \033[31m\033[1mFAIL\033[0m - Target ${3} ${4} ${5} not reached, result = ${result} ----"
327 echo "Wrong args to __var_test, needs five or six args: <simulator-name> <host> <variable-name> <condition-operator> <target-value> [ <timeout> ]"
331 # Stops a named container
333 if [ $# -ne 1 ]; then
334 echo "__docker_stop need 1 arg <container-name>"
337 tmp=$(docker stop $1 2>/dev/null)
338 if [ -z $tmp ] || [ $tmp != $1 ]; then
339 echo " ${1} container not stopped or not existing"
341 echo " ${1} container stopped"
345 # Starts a named container (that has previously been stopped)
347 if [ $# -ne 1 ]; then
348 echo "__docker_start need 1 arg <container-name>"
351 tmp=$(docker start $1 2>/dev/null)
352 if [ -z $tmp ] || [ $tmp != $1 ]; then
353 echo " ${1} container not started or not existing"
355 echo " ${1} container started"
359 # Removes a named container
361 if [ $# -ne 1 ]; then
362 echo "__docker_rm need 1 arg <container-name>"
365 tmp=$(docker rm $1 2>/dev/null)
366 if [ -z $tmp ] || [ $tmp != $1 ]; then
367 echo " ${1} container not removed or not existing"
369 echo " ${1} container removed"
373 __start_dfc_image() {
376 __print_err "need tow args, <dfc-instance-name> 0.."$$DFC_MAX_IDX
380 if [ $2 -lt 0 ] || [ $2 -gt $DFC_MAX_IDX ]; then
381 __print_err "need two args, <dfc-instance-name> 0.."$DFC_MAX_IDX
385 localport=$(($DFC_PORT + $2))
386 localport_secure=$(($DFC_PORT_SECURE + $2))
388 echo "Creating docker network "$DOCKER_SIM_NWNAME", if needed"
390 docker network ls| grep "$DOCKER_SIM_NWNAME" > /dev/null || docker network create "$DOCKER_SIM_NWNAME"
392 echo "Starting DFC: " $appname " with ports mapped to " $localport " and " $localport_secure " in docker network "$DOCKER_SIM_NWNAME
393 if [ "$HTTP_TYPE" = "HTTPS" ]
395 mkdir "$SIM_GROUP"/tls/external
396 cp "$SIM_GROUP"/../certservice/generated-certs/dfc-p12/* "$SIM_GROUP"/tls/external/
398 --name oom-certservice-post-processor \
399 --env-file "$SIM_GROUP"/../certservice/merger/merge-certs.env \
400 --mount type=bind,src="$SIM_GROUP"/tls,dst=/opt/app/datafile/etc/cert \
401 nexus3.onap.org:10001/onap/org.onap.oom.platform.cert-service.oom-certservice-post-processor:latest
403 docker run -d --volume $(pwd)/../simulator-group/tls/:/opt/app/datafile/etc/cert/ -p $localport":8100" -p $localport_secure":8433" --network=$DOCKER_SIM_NWNAME -e CONSUL_HOST=$CONSUL_HOST -e CONSUL_PORT=$CONSUL_PORT -e CONFIG_BINDING_SERVICE=$CONFIG_BINDING_SERVICE -e CONFIG_BINDING_SERVICE_SERVICE_PORT=$CONFIG_BINDING_SERVICE_SERVICE_PORT -e HOSTNAME=$appname --name $appname $DFC_IMAGE
408 if [ $(docker inspect --format '{{ .State.Running }}' $appname) ]
410 echo " Image: $(docker inspect --format '{{ .Config.Image }}' ${appname})"
411 echo "DFC container ${appname} running"
418 if ! [ $dfc_started ]; then
419 echo "DFC container ${appname} could not be started"
424 echo "Waiting for DFC ${appname} heartbeat..."
426 result="$(__do_curl http://127.0.0.1:${localport}/heartbeat)"
427 if [ $? -eq 0 ]; then
428 echo "DFC ${appname} responds to heartbeat: " $result
430 result="$(__do_curl http://127.0.0.1:${localport}/actuator/info)"
431 echo "DFC ${appname} image build info: " $result
438 if [ "$dfc_hb" = "false" ]; then
439 echo "DFC ${appname} did not respond to heartbeat"
444 # Function for waiting for named container to be started manually.
445 __wait_for_container() {
448 echo "Need one arg: <container-name> <instance-id>"
451 http=$(($DFC_PORT+$2))
452 https=$((DFC_PORT_SECURE+$2))
453 echo "The container is expected to map its ports (8100/8433) to the following port visibile on the host: http port ${http} and https port ${https}"
454 echo "Waiting for container with name '${1}' to be started manually...."
458 if [ $(docker inspect --format '{{ .State.Running }}' $1 2> /dev/null) ]; then
459 echo "Container running: "$1
462 duration=$((SECONDS-start))
463 echo -ne " Waited ${duration} seconds\033[0K\r"
468 echo "Connecting container "$1" to simulator network "$DOCKER_SIM_NWNAME
469 docker network connect $DOCKER_SIM_NWNAME $1
472 #WFunction for waiting for named container to be stopped manually.
473 __wait_for_container_gone() {
476 echo "Need one arg: <container-name>"
479 echo "Disconnecting container "$1" from simulator network "$DOCKER_SIM_NWNAME
480 docker network disconnect $DOCKER_SIM_NWNAME $1
481 echo "Waiting for container with name '${1}' to be stopped manually...."
485 if [ $(docker inspect --format '{{ .State.Running }}' $1 2> /dev/null) ]; then
486 duration=$((SECONDS-start))
487 echo -ne " Waited ${duration} seconds\033[0K\r"
490 echo "Container stopped: "$1
496 #Function for waiting to dfc to be started manually
498 http=$(($DFC_PORT+$2))
499 https=$((DFC_PORT_SECURE+$2))
500 echo "The app is expected to listen to http port ${http} and https port ${https}"
501 echo "The app shall use 'localhost' and '8500' for CONSUL_HOST and CONSUL_PORT."
502 echo "The app shale use 'config-binding-service-localhost' for CONFIG_BINDING_SERVICE"
503 echo "The app shall use ${1} for HOSTNAME."
504 read -p "Press enter to continue when app mapping to ${1} has been manually started"
507 #Function for waiting to dfc to be stopped manually
508 __wait_for_dfc_gone() {
509 read -p "Press enter to continue when when app mapping to ${1} has been manually stopped"
512 #############################################################
513 ############## Functions for auto test scripts ##############
514 #############################################################
516 # Print the env variables needed for the simulators and their setup
518 echo "Simulator settings"
520 echo "MR_GROUPS= "$MR_GROUPS
521 echo "MR_FILE_PREFIX_MAPPING="$MR_FILE_PREFIX_MAPPING
523 echo "DR_FEEDS= "$DR_FEEDS
524 echo "DR_REDIR_SIM= "$DR_REDIR_SIM
525 echo "DR_REDIR_TC= "$DR_REDIR_TC
526 echo "DR_REDIR_FEEDS= "$DR_REDIR_FEEDS
528 echo "NUM_FTPFILES= "$NUM_FTPFILES
529 echo "NUM_HTTPFILES= "$NUM_HTTPFILES
530 echo "NUM_PNFS= "$NUM_PNFS
531 echo "FILE_SIZE= "$FILE_SIZE
532 echo "FTP_TYPE= "$FTP_TYPE
533 echo "HTTP_TYPE= "$HTTP_TYPE
534 echo "FTP_FILE_PREFIXES= "$FTP_FILE_PREFIXES
535 echo "HTTP_FILE_PREFIXES= "$HTTP_FILE_PREFIXES
536 echo "NUM_FTP_SERVERS= "$NUM_FTP_SERVERS
537 echo "NUM_HTTP_SERVERS= "$NUM_HTTP_SERVERS
538 echo "SFTP_SIMS= "$SFTP_SIMS
539 echo "FTPES_SIMS= "$FTPES_SIMS
540 echo "HTTP_SIMS= "$HTTP_SIMS
541 echo "HTTPS_SIMS= "$HTTPS_SIMS
542 echo "HTTPS_SIMS_NO_AUTH= "$HTTPS_SIMS_NO_AUTH
546 # Stop and remove all containers including dfc app and simulators
548 echo "Stopping all containers, dfc app(s) and simulators with name prefix 'dfc_'"
549 docker stop $(docker ps -q --filter name=dfc_) &> /dev/null
550 echo "Removing all containers, dfc app and simulators with name prefix 'dfc_'"
551 docker rm $(docker ps -a -q --filter name=dfc_) &> /dev/null
552 docker rm -f $(docker ps -a -q --filter name=oom-certservice-post-processor) &> /dev/null
553 echo "Removing unused docker networks with substring 'dfc' in network name"
554 docker network rm $(docker network ls -q --filter name=dfc)
558 # Start all simulators in the simulator group
561 echo "Starting all simulators"
564 export SIM_GROUP=$SIM_GROUP
565 $SIM_GROUP/simulators-start.sh
570 # Start the dfc application
574 __print_err "need one arg, <dfc-instance-id>"
578 if [ $1 -lt 0 ] || [ $1 -gt $DFC_MAX_IDX ]; then
579 __print_err "arg should be 0.."$DFC_MAX_IDX
582 appname=$DFC_APP_BASE$1
583 STARTED_DFCS=$STARTED_DFCS"_"$appname"_"
585 if [ $START_ARG == "local" ] || [ $START_ARG == "remote" ] || [ $START_ARG == "remote-remove" ]; then
586 __start_dfc_image $appname $1
587 elif [ $START_ARG == "manual-container" ]; then
588 __wait_for_container $appname $1
589 elif [ $START_ARG == "manual-app" ]; then
590 __wait_for_dfc $appname $1
594 # Configure consul with dfc config, args <dfc-instance-id> <json-file-path>
595 # Not intended to be called directly by test scripts.
599 __print_err "need two args, <dfc-instance-id> <json-file-path>"
603 if [ $1 -lt 0 ] || [ $1 -gt $DFC_MAX_IDX ]; then
604 __print_err "dfc-instance-id should be 0.."$DFC_MAX_IDX
608 __print_err "json file does not extis: "$2
612 appname=$DFC_APP_BASE$1
614 echo "Configuring consul for " $appname " from " $2
615 curl -s http://127.0.0.1:${CONSUL_PORT}/v1/kv/${appname}?dc=dc1 -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data-binary "@"$2 >/dev/null
618 # Configure consul with dfc app config, args <dfc-instance-id> <json-file-path>
619 consul_config_app() {
620 if [ $START_ARG == "manual-app" ]; then
621 echo "Replacing 'mrsim' with 'localhost' in json app config for consul"
622 sed 's/mrsim/localhost/g' $2 > .tmp_app.json
623 echo "Replacing 'drsim' with 'localhost' in json dmaap config for consul"
624 sed 's/drsim/localhost/g' .tmp_app.json > .app.json
625 __consul_config $1 .app.json
627 __consul_config $1 $2
631 # Stop and remove the dfc app container
635 __print_err "need one arg, <dfc-instance-id>"
639 if [ $1 -lt 0 ] || [ $1 -gt $DFC_MAX_IDX ]; then
640 __print_err "arg should be 0.."$DFC_MAX_IDX
643 appname=$DFC_APP_BASE$1
645 echo "Killing DFC, instance id: "$1
647 if [ $START_ARG == "local" ] || [ $START_ARG == "remote" ] || [ $START_ARG == "remote-remove" ]; then
648 __docker_stop $appname
650 elif [ $START_ARG == "manual-container" ]; then
651 __wait_for_container_gone $appname
652 elif [ $START_ARG == "manual-app" ]; then
653 __wait_for_dfc_gone $appname
657 # Stop and remove the DR simulator container
659 echo "Killing DR sim"
660 __docker_stop dfc_dr-sim
661 __docker_rm dfc_dr-sim
664 # Stop and remove the DR redir simulator container
666 echo "Killing DR redir sim"
667 __docker_stop dfc_dr-redir-sim
668 __docker_rm dfc_dr-redir-sim
671 # Stop and remove the MR simulator container
673 echo "Killing MR sim"
674 __docker_stop dfc_mr-sim
675 __docker_rm dfc_mr-sim
678 # Stop and remove the SFTP container, arg: <sftp-instance-id>
682 __print_err "need one arg, <sftp-instance-id>"
686 if [ $1 -lt 0 ] || [ $1 -gt $FTP_MAX_IDX ]; then
687 __print_err "arg should be 0.."$FTP_MAX_IDX
692 echo "Killing SFTP, instance id: "$1
694 __docker_stop $appname
698 # Stop SFTP container, arg: <sftp-instance-id>
702 __print_err "need one arg, <sftp-instance-id>"
706 if [ $1 -lt 0 ] || [ $1 -gt $FTP_MAX_IDX ]; then
707 __print_err "arg should be 0.."$FTP_MAX_IDX
712 echo "Stopping SFTP, instance id: "$1
714 __docker_stop $appname
717 # Starts a stopped SFTP container, arg: <sftp-instance-id>
721 __print_err "need one arg, <sftp-instance-id>"
725 if [ $1 -lt 0 ] || [ $1 -gt $FTP_MAX_IDX ]; then
726 __print_err "arg should be 0.."$FTP_MAX_IDX
731 echo "Starting SFTP, instance id: "$1
733 __docker_start $appname
736 # Stop and remove the FTPES container, arg: <ftpes-instance-id>
740 __print_err "need one arg, <ftpes-instance-id>"
744 if [ $1 -lt 0 ] || [ $1 -gt $FTP_MAX_IDX ]; then
745 __print_err "arg should be 0.."$FTP_MAX_IDX
748 appname=$FTPES_BASE$1
750 echo "Killing FTPES, instance id: "$1
752 __docker_stop $appname
756 # Stop FTPES container, arg: <ftpes-instance-id>
760 __print_err "need one arg, <ftpes-instance-id>"
764 if [ $1 -lt 0 ] || [ $1 -gt $FTP_MAX_IDX ]; then
765 __print_err "arg should be 0.."$FTP_MAX_IDX
768 appname=$FTPES_BASE$1
770 echo "Stopping FTPES, instance id: "$1
772 __docker_stop $appname
775 # Starts a stopped FTPES container, arg: <ftpes-instance-id>
779 __print_err "need one arg, <ftpes-instance-id>"
783 if [ $1 -lt 0 ] || [ $1 -gt $FTP_MAX_IDX ]; then
784 __print_err "arg should be 0.."$FTP_MAX_IDX
787 appname=$FTPES_BASE$1
789 echo "Starting FTPES, instance id: "$1
791 __docker_start $appname
794 # Stop and remove the HTTP container, arg: <http-instance-id>
798 __print_err "need one arg, <http-instance-id>"
802 if [ $1 -lt 0 ] || [ $1 -gt $HTTP_MAX_IDX ]; then
803 __print_err "arg should be 0.."$HTTP_MAX_IDX
806 appname=$HTTP_HTTPS_BASE$1
808 echo "Killing HTTP/HTTPS, instance id: "$1
810 __docker_stop $appname
814 # Stop HTTP container, arg: <http-instance-id>
818 __print_err "need one arg, <http-instance-id>"
822 if [ $1 -lt 0 ] || [ $1 -gt $HTTP_MAX_IDX ]; then
823 __print_err "arg should be 0.."$HTTP_MAX_IDX
826 appname=$HTTP_HTTPS_BASE$1
828 echo "Stopping HTTP/HTTPS, instance id: "$1
830 __docker_stop $appname
833 # Starts a stopped HTTP container, arg: <http-instance-id>
837 __print_err "need one arg, <http-instance-id>"
841 if [ $1 -lt 0 ] || [ $1 -gt $HTTP_MAX_IDX ]; then
842 __print_err "arg should be 0.."$HTTP_MAX_IDX
845 appname=$HTTP_HTTPS_BASE$1
847 echo "Starting HTTP/HTTPS, instance id: "$1
849 __docker_start $appname
852 # Print a variable value from the MR simulator. Arg: <variable-name>
855 __print_err "need one arg, <sim-param>"
858 echo -e "---- MR sim, \033[1m $1 \033[0m: $(__do_curl http://127.0.0.1:$MR_PORT/$1)"
861 # Print a variable value from the MR https simulator. Arg: <variable-name>
864 __print_err "need one arg, <sim-param>"
867 echo -e "---- MR sim, \033[1m $1 \033[0m: $(__do_curl https://127.0.0.1:$MR_PORT_SECURE/$1)"
870 # Print a variable value from the DR simulator. Arg: <variable-name>
873 __print_err "need one arg, <sim-param>"
876 echo -e "---- DR sim, \033[1m $1 \033[0m: $(__do_curl http://127.0.0.1:$DR_PORT/$1)"
879 # Print a variable value from the DR redir simulator. Arg: <variable-name>
882 __print_err "need one arg, <sim-param>"
885 echo -e "---- DR redir sim, \033[1m $1 \033[0m: $(__do_curl http://127.0.0.1:$DRR_PORT/$1)"
887 # Print a variable value from dfc. Arg: <dfc-instance-id> <variable-name>
890 __print_err "need two args, <dfc-instance-id> <dfc-param>"
893 if [ $1 -lt 0 ] || [ $1 -gt $DFC_MAX_IDX ]; then
894 __print_err "dfc instance id should be in range 0.."DFC_MAX_IDX
897 localport=$(($DFC_PORT + $1))
898 appname=$DFC_APP_BASE$1
899 echo -e "---- DFC $appname, \033[1m $2 \033[0m: $(__do_curl http://127.0.0.1:$localport/$2)"
902 # Read a variable value from MR sim and send to stdout. Arg: <variable-name>
904 echo "$(__do_curl http://127.0.0.1:$MR_PORT/$1)"
907 # Read a variable value from MR https sim and send to stdout. Arg: <variable-name>
909 echo "$(__do_curl https://127.0.0.1:$MR_PORT_SECURE/$1)"
912 # Read a variable value from DR sim and send to stdout. Arg: <variable-name>
914 echo "$(__do_curl http://127.0.0.1:$DR_PORT/$1)"
917 # Read a variable value from DR redir sim and send to stdout. Arg: <variable-name>
919 echo "$(__do_curl http://127.0.0.1:$DRR_PORT/$1)"
923 # Sleep. Arg: <sleep-time-in-sec>
926 __print_err "need one arg, <sleep-time-in-sec>"
929 echo "---- Sleep for " $1 " seconds ----"
931 duration=$((SECONDS-start))
932 while [ $duration -lt $1 ]; do
933 echo -ne " Slept for ${duration} seconds\033[0K\r"
935 duration=$((SECONDS-start))
940 # Sleep and print dfc heartbeat. Arg: <sleep-time-in-sec>
943 __print_err "need one arg, <sleep-time-in-sec>"
946 echo "---- Sleep for " $1 " seconds ----"
949 duration=$((SECONDS-start))
952 while [ $duration -lt $1 ]; do
953 if [ $rows -eq 0 ]; then
957 echo " Slept for ${duration} seconds"
958 if [ $((ctr%30)) -eq 0 ]; then
959 for (( i=0; i<=$DFC_MAX_IDX; i++ )); do
960 if [[ $STARTED_DFCS =~ "_"$DFC_APP_BASE$i"_" ]]; then
962 echo " HB ${DFC_APP_BASE}${i}: $(__do_curl http://127.0.0.1:$(($DFC_PORT+$i))/heartbeat)"
969 duration=$((SECONDS-start))
974 # Tests if a variable value in the MR simulator is equal to a target value and and optional timeout.
975 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
976 # equal to the target or not.
977 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
978 # before setting pass or fail depending on if the variable value becomes equal to the target
981 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
982 __var_test "MR" "http://127.0.0.1:$MR_PORT/" $1 "=" $2 $3
984 __print_err "Wrong args to mr_equal, needs two or three args: <sim-param> <target-value> [ timeout ]"
989 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
990 __var_test "MR" "https://127.0.0.1:$MR_PORT_SECURE/" $1 "=" $2 $3
992 __print_err "Wrong args to mr_secure_equal, needs two or three args: <sim-param> <target-value> [ timeout ]"
996 # Tests if a variable value in the MR simulator is greater than a target value and and optional timeout.
997 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
998 # greater than the target or not.
999 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
1000 # before setting pass or fail depending on if the variable value greater than the target
1003 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
1004 __var_test "MR" "http://127.0.0.1:$MR_PORT/" $1 ">" $2 $3
1006 __print_err "Wrong args to mr_greater, needs two or three args: <sim-param> <target-value> [ timeout ]"
1010 mr_secure_greater() {
1011 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
1012 __var_test "MR" "https://127.0.0.1:$MR_PORT_SECURE/" $1 ">" $2 $3
1014 __print_err "Wrong args to mr_secure_greater, needs two or three args: <sim-param> <target-value> [ timeout ]"
1018 # Tests if a variable value in the MR simulator is less than a target value and and optional timeout.
1019 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
1020 # less than the target or not.
1021 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
1022 # before setting pass or fail depending on if the variable value less than the target
1025 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
1026 __var_test "MR" "http://127.0.0.1:$MR_PORT/" $1 "<" $2 $3
1028 __print_err "Wrong args to mr_less, needs two or three args: <sim-param> <target-value> [ timeout ]"
1032 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
1033 __var_test "MR" "https://127.0.0.1:$MR_PORT_SECURE/" $1 "<" $2 $3
1035 __print_err "Wrong args to mr_secure_less, needs two or three args: <sim-param> <target-value> [ timeout ]"
1039 # Tests if a variable value in the MR simulator contains the target string and and optional timeout.
1040 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable contains
1041 # the target or not.
1042 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
1043 # before setting pass or fail depending on if the variable value contains the target
1046 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
1047 __var_test "MR" "http://127.0.0.1:$MR_PORT/" $1 "contain_str" $2 $3
1049 __print_err "Wrong args to mr_contain_str, needs two or three args: <sim-param> <target-value> [ timeout ]"
1052 mr_secure_contain_str() {
1053 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
1054 __var_test "MR" "https://127.0.0.1:$MR_PORT_SECURE/" $1 "contain_str" $2 $3
1056 __print_err "Wrong args to mr_secure_contain_str, needs two or three args: <sim-param> <target-value> [ timeout ]"
1060 # Tests if a variable value in the DR simulator is equal to a target value and and optional timeout.
1061 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
1062 # equal to the target or not.
1063 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
1064 # before setting pass or fail depending on if the variable value becomes equal to the target
1067 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
1068 __var_test "DR" "http://127.0.0.1:$DR_PORT/" $1 "=" $2 $3
1070 __print_err "Wrong args to dr_equal, needs two or three args: <sim-param> <target-value> [ timeout ]"
1074 # Tests if a variable value in the DR simulator is greater than a target value and and optional timeout.
1075 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
1076 # greater than the target or not.
1077 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
1078 # before setting pass or fail depending on if the variable value greater than the target
1081 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
1082 __var_test "DR" "http://127.0.0.1:$DR_PORT/" $1 ">" $2 $3
1084 __print_err "Wrong args to dr_greater, needs two or three args: <sim-param> <target-value> [ timeout ]"
1088 # Tests if a variable value in the DR simulator is less than a target value and and optional timeout.
1089 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
1090 # less than the target or not.
1091 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
1092 # before setting pass or fail depending on if the variable value less than the target
1095 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
1096 __var_test "DR" "http://127.0.0.1:$DR_PORT/" $1 "<" $2 $3
1098 __print_err "Wrong args to dr_less, needs two or three args: <sim-param> <target-value> [ timeout ]"
1102 # Tests if a variable value in the DR simulator contains the target string and and optional timeout.
1103 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable contains
1104 # the target or not.
1105 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
1106 # before setting pass or fail depending on if the variable value contains the target
1109 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
1110 __var_test "DR" "http://127.0.0.1:$DR_PORT/" $1 "contain_str" $2 $3
1112 __print_err "Wrong args to dr_contain_str, needs two or three args: <sim-param> <target-value> [ timeout ]"
1116 # Tests if a variable value in the DR Redir simulator is equal to a target value and and optional timeout.
1117 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
1118 # equal to the target or not.
1119 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
1120 # before setting pass or fail depending on if the variable value becomes equal to the target
1123 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
1124 __var_test "DR REDIR" "http://127.0.0.1:$DRR_PORT/" $1 "=" $2 $3
1126 __print_err "Wrong args to drr_equal, needs two or three args: <sim-param> <target-value> [ timeout ]"
1131 # Tests if a variable value in the DR Redir simulator is greater a target value and and optional timeout.
1132 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
1133 # greater the target or not.
1134 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
1135 # before setting pass or fail depending on if the variable value greater than the target
1138 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
1139 __var_test "DR REDIR" "http://127.0.0.1:$DRR_PORT/" $1 ">" $2 $3
1141 __print_err "Wrong args to drr_greater, needs two or three args: <sim-param> <target-value> [ timeout ]"
1145 # Tests if a variable value in the DR Redir simulator is less than a target value and and optional timeout.
1146 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
1147 # less than the target or not.
1148 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
1149 # before setting pass or fail depending on if the variable value less than the target
1152 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
1153 __var_test "DR REDIR" "http://127.0.0.1:$DRR_PORT/" $1 "<" $2 $3
1155 __print_err "Wrong args to drr_less, needs two or three args: <sim-param> <target-value> [ timeout ]"
1159 # Tests if a variable value in the DR redir simulator contains the target string and and optional timeout.
1160 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable contains
1161 # the target or not.
1162 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
1163 # before setting pass or fail depending on if the variable value contains the target
1166 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
1167 __var_test "DR REDIR" "http://127.0.0.1:$DRR_PORT/" $1 "contain_str" $2 $3
1169 __print_err "Wrong args to drr_contain_str, needs two or three args: <sim-param> <target-value> [ timeout ]"
1173 #Test if a variable in the DFC contains a substring. Arg: <dfc-index> <variable-name> <substring-in-quotes>
1175 if [ $# -eq 3 ]; then
1176 if [ $1 -lt 0 ] || [ $1 -gt $DFC_MAX_IDX ]; then
1177 __print_err "arg should be 0.."$DFC_MAX_IDX
1180 appname=$DFC_APP_BASE$1
1181 localport=$(($DFC_PORT + $1))
1182 echo -e "---- DFC test criteria: $appname \033[1m ${2} \033[0m contains: ${3} ----"
1184 result="$(__do_curl http://127.0.0.1:$localport/${2})"
1185 if [[ $result =~ $3 ]]; then
1187 echo -e "---- \033[32m\033[1mPASS\033[0m - Test criteria met"
1190 echo -e "---- \033[31m\033[1mFAIL\033[0m - Target '${3}' not reached, result = ${result} ----"
1193 echo "Wrong args to dfc_contain_str, needs three arg: <dfc-index> <dfc-variable> <str>"
1198 # Store all dfc app and simulators log to the test case log dir. All logs gets a prefix to
1199 # separate logs stored at different steps in the test script. Arg: <tc-id> <log-prefix>
1201 if [ $# != 1 ]; then
1202 __print_err "need one arg, <file-prefix>"
1205 echo "Storing all container logs and dfc app log using prefix: "$1
1206 if ! [ $START_ARG == "manual-app" ]; then
1207 for (( i=0; i<=$DFC_MAX_IDX; i++ )); do
1208 appname=$DFC_APP_BASE$i
1209 tmp=$(docker ps | grep $appname)
1210 if ! [ -z "$tmp" ]; then #Only stored logs from running DFC apps
1211 docker cp $appname:/var/log/ONAP/application.log $TESTLOGS/$ATC/${1}_${appname}_application.log
1212 docker logs $appname > $TESTLOGS/$ATC/$1_$appname-docker.log 2>&1
1216 docker logs dfc_mr-sim > $TESTLOGS/$ATC/$1_dfc_mr-sim-docker.log 2>&1
1217 docker logs dfc_dr-sim > $TESTLOGS/$ATC/$1_dfc_dr-sim-docker.log 2>&1
1218 docker logs dfc_dr-redir-sim > $TESTLOGS/$ATC/$1_dfc_dr-redir-sim-docker.log 2>&1
1220 for (( i=0; i<=$FTP_MAX_IDX; i++ )); do
1221 appname=$SFTP_BASE$i
1222 docker logs $appname > $TESTLOGS/$ATC/${1}_${appname}.log 2>&1
1223 appname=$FTPES_BASE$i
1224 docker logs $appname > $TESTLOGS/$ATC/${1}_${appname}.log 2>&1
1227 for (( i=0; i<=$HTTP_MAX_IDX; i++ )); do
1228 appname=$HTTP_HTTPS_BASE$i
1229 docker logs $appname > $TESTLOGS/$ATC/${1}_${appname}.log 2>&1
1232 docker logs dfc_consul > $TESTLOGS/$ATC/$1_consul.log 2>&1
1233 docker logs dfc_cbs > $TESTLOGS/$ATC/$1_cbs.log 2>&1
1235 # Check the dfc application log, for all dfc instances, for WARN and ERR messages and print the count.
1237 for (( i=0; i<=$DFC_MAX_IDX; i++ )); do
1238 appname=$DFC_APP_BASE$i
1239 tmp=$(docker ps | grep $appname)
1240 if ! [ -z "$tmp" ]; then #Only check logs for running dfc_apps
1241 _check_dfc_log $appname
1246 # Check dfc app log for one dfc instance, arg <dfc-app-name>
1248 echo "Checking $1 log $DFC_LOGPATH for WARNINGs and ERRORs"
1249 foundentries=$(docker exec -it $1 grep WARN /var/log/ONAP/application.log | wc -l)
1250 if [ $? -ne 0 ];then
1251 echo " Problem to search $1 log $DFC_LOGPATH"
1253 if [ $foundentries -eq 0 ]; then
1254 echo " No WARN entries found in $1 log $DFC_LOGPATH"
1256 echo -e " Found \033[1m"$foundentries"\033[0m WARN entries in $1 log $DFC_LOGPATH"
1259 foundentries=$(docker exec -it $1 grep ERR $DFC_LOGPATH | wc -l)
1260 if [ $? -ne 0 ];then
1261 echo " Problem to search $1 log $DFC_LOGPATH"
1263 if [ $foundentries -eq 0 ]; then
1264 echo " No ERR entries found in $1 log $DFC_LOGPATH"
1266 echo -e " Found \033[1m"$foundentries"\033[0m ERR entries in $1 log $DFC_LOGPATH"
1273 echo "---- DFC and all sim variables"
1275 for (( i=0; i<=$DFC_MAX_IDX; i++ )); do
1276 appname=$DFC_APP_BASE$i
1277 tmp=$(docker ps | grep $appname)
1278 if ! [ -z "$tmp" ]; then #Only check running dfc_apps
1286 mr_print execution_time
1289 mr_print fileprefixes
1290 mr_print exe_time_first_poll
1291 mr_print groups/exe_time_first_poll
1292 mr_print ctr_requests
1293 mr_print groups/ctr_requests
1294 mr_print ctr_responses
1295 mr_print groups/ctr_responses
1297 mr_print groups/ctr_files
1298 mr_print ctr_unique_files
1299 mr_print groups/ctr_unique_files
1300 mr_print groups/ctr_events
1302 mr_print ctr_unique_PNFs
1303 mr_print groups/ctr_unique_PNFs
1306 dr_print execution_time
1308 dr_print ctr_publish_query
1309 dr_print feeds/ctr_publish_query
1310 dr_print ctr_publish_query_bad_file_prefix
1311 dr_print feeds/ctr_publish_query_bad_file_prefix
1312 dr_print ctr_publish_query_published
1313 dr_print feeds/ctr_publish_query_published
1314 dr_print ctr_publish_query_not_published
1315 dr_print feeds/ctr_publish_query_not_published
1316 dr_print ctr_publish_req
1317 dr_print feeds/ctr_publish_req
1318 dr_print ctr_publish_req_bad_file_prefix
1319 dr_print feeds/ctr_publish_req_bad_file_prefix
1320 dr_print ctr_publish_req_redirect
1321 dr_print feeds/ctr_publish_req_redirect
1322 dr_print ctr_publish_req_published
1323 dr_print feeds/ctr_publish_req_published
1324 dr_print ctr_published_files
1325 dr_print feeds/ctr_published_files
1326 dr_print ctr_double_publish
1327 dr_print feeds/ctr_double_publish
1330 drr_print execution_time
1332 drr_print ctr_publish_requests
1333 drr_print feeds/ctr_publish_requests
1334 drr_print ctr_publish_requests_bad_file_prefix
1335 drr_print feeds/ctr_publish_requests_bad_file_prefix
1336 drr_print ctr_publish_responses
1337 drr_print feeds/ctr_publish_responses
1338 drr_print dwl_volume
1339 drr_print feeds/dwl_volume
1340 drr_print time_lastpublish
1341 drr_print feeds/time_lastpublish
1344 # Print the test result
1348 duration=$((TCTEST_END-TCTEST_START))
1350 echo "-------------------------------------------------------------------------------------------------"
1351 echo "------------------------------------- Test case: "$ATC
1352 echo "------------------------------------- Ended: "$(date)
1353 echo "-------------------------------------------------------------------------------------------------"
1354 echo "-- Description: "$TC_ONELINE_DESCR
1355 echo "-- Execution time: " $duration " seconds"
1356 echo "-------------------------------------------------------------------------------------------------"
1357 echo "------------------------------------- RESULTS"
1361 total=$((RES_PASS+RES_FAIL))
1362 if [ $RES_TEST -eq 0 ]; then
1363 echo -e "\033[1mNo tests seem to have executed. Check the script....\033[0m"
1364 echo -e "\033[31m\033[1m ___ ___ ___ ___ ___ _____ ___ _ ___ _ _ _ ___ ___ \033[0m"
1365 echo -e "\033[31m\033[1m/ __|/ __| _ \_ _| _ \_ _| | __/_\ |_ _| | | | | | _ \ __|\033[0m"
1366 echo -e "\033[31m\033[1m\__ \ (__| /| || _/ | | | _/ _ \ | || |_| |_| | / _| \033[0m"
1367 echo -e "\033[31m\033[1m|___/\___|_|_\___|_| |_| |_/_/ \_\___|____\___/|_|_\___|\033[0m"
1368 elif [ $total != $RES_TEST ]; then
1369 echo -e "\033[1mTotal number of tests does not match the sum of passed and failed tests. Check the script....\033[0m"
1370 echo -e "\033[31m\033[1m ___ ___ ___ ___ ___ _____ ___ _ ___ _ _ _ ___ ___ \033[0m"
1371 echo -e "\033[31m\033[1m/ __|/ __| _ \_ _| _ \_ _| | __/_\ |_ _| | | | | | _ \ __|\033[0m"
1372 echo -e "\033[31m\033[1m\__ \ (__| /| || _/ | | | _/ _ \ | || |_| |_| | / _| \033[0m"
1373 echo -e "\033[31m\033[1m|___/\___|_|_\___|_| |_| |_/_/ \_\___|____\___/|_|_\___|\033[0m"
1374 elif [ $RES_PASS = $RES_TEST ]; then
1375 echo -e "All tests \033[32m\033[1mPASS\033[0m"
1376 echo -e "\033[32m\033[1m ___ _ ___ ___ \033[0m"
1377 echo -e "\033[32m\033[1m | _ \/_\ / __/ __| \033[0m"
1378 echo -e "\033[32m\033[1m | _/ _ \\__ \__ \\ \033[0m"
1379 echo -e "\033[32m\033[1m |_|/_/ \_\___/___/ \033[0m"
1382 # Update test suite counter
1383 if [ -f .tmp_tcsuite_pass_ctr ]; then
1384 tmpval=$(< .tmp_tcsuite_pass_ctr)
1386 echo $tmpval > .tmp_tcsuite_pass_ctr
1388 if [ -f .tmp_tcsuite_pass ]; then
1389 echo " - "$ATC " -- "$TC_ONELINE_DESCR" Execution time: "$duration" seconds" >> .tmp_tcsuite_pass
1392 echo -e "One or more tests with status \033[31m\033[1mFAIL\033[0m "
1393 echo -e "\033[31m\033[1m ___ _ ___ _ \033[0m"
1394 echo -e "\033[31m\033[1m | __/_\ |_ _| | \033[0m"
1395 echo -e "\033[31m\033[1m | _/ _ \ | || |__ \033[0m"
1396 echo -e "\033[31m\033[1m |_/_/ \_\___|____|\033[0m"
1398 # Update test suite counter
1399 if [ -f .tmp_tcsuite_fail_ctr ]; then
1400 tmpval=$(< .tmp_tcsuite_fail_ctr)
1402 echo $tmpval > .tmp_tcsuite_fail_ctr
1404 if [ -f .tmp_tcsuite_fail ]; then
1405 echo " - "$ATC " -- "$TC_ONELINE_DESCR" Execution time: "$duration" seconds" >> .tmp_tcsuite_fail
1409 echo "++++ Number of tests: "$RES_TEST
1410 echo "++++ Number of passed tests: "$RES_PASS
1411 echo "++++ Number of failed tests: "$RES_FAIL
1412 echo "------------------------------------- Test case complete ---------------------------------"
1413 echo "-------------------------------------------------------------------------------------------------"