Added r-app catalogue to demo test case
[nonrtric.git] / test / common / testcase_common.sh
index a90700a..f2783f3 100755 (executable)
@@ -61,7 +61,7 @@ fi
 echo -ne $EBOLD
 
 # default test environment variables
-TEST_ENV_VAR_FILE="../common/test_env.sh"
+TEST_ENV_VAR_FILE=""
 
 echo "Test case started as: ${BASH_SOURCE[$i+1]} "$@
 
@@ -84,7 +84,7 @@ AUTO_CLEAN=""
 USE_LOCAL_IMAGES=""
 
 # List of available apps to override with local image
-AVAILABLE_LOCAL_IMAGES_OVERRIDE="PA ECS CP SDNC RICSIM"
+AVAILABLE_LOCAL_IMAGES_OVERRIDE="PA ECS CP SDNC RICSIM RC"
 
 # 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
 STOP_AT_ERROR=0
@@ -114,6 +114,12 @@ if [ ! -d "logs" ]; then
 fi
 TESTLOGS=$PWD/logs
 
+# Create the tmp dir for temporary files that is not needed after the test
+# hidden files for the test env is still stored in the current dir
+if [ ! -d "tmp" ]; then
+    mkdir tmp
+fi
+
 # Create a http message log for this testcase
 HTTPLOG=$PWD"/.httplog_"$ATC".txt"
 echo "" > $HTTPLOG
@@ -122,6 +128,17 @@ echo "" > $HTTPLOG
 # Create a log dir for the test case
 mkdir -p $TESTLOGS/$ATC
 
+# Save create for current logs
+mkdir -p $TESTLOGS/$ATC/previous
+
+rm $TESTLOGS/$ATC/previous/*.log &> /dev/null
+rm $TESTLOGS/$ATC/previous/*.txt &> /dev/null
+rm $TESTLOGS/$ATC/previous/*.json &> /dev/null
+
+mv  $TESTLOGS/$ATC/*.log $TESTLOGS/$ATC/previous &> /dev/null
+mv  $TESTLOGS/$ATC/*.txt $TESTLOGS/$ATC/previous &> /dev/null
+mv  $TESTLOGS/$ATC/*.txt $TESTLOGS/$ATC/previous &> /dev/null
+
 # Clear the log dir for the test case
 rm $TESTLOGS/$ATC/*.log &> /dev/null
 rm $TESTLOGS/$ATC/*.txt &> /dev/null
@@ -142,6 +159,94 @@ RES_DEVIATION=0
 DEVIATION_FILE=".tmp_deviations"
 rm $DEVIATION_FILE &> /dev/null
 
+
+# Trap "command not found" and make the script fail
+trap_fnc() {
+
+       if [ $? -eq 127 ]; then
+               echo -e $RED"Function not found, setting script to FAIL"$ERED
+               ((RES_CONF_FAIL++))
+       fi
+}
+trap trap_fnc ERR
+
+# Counter for tests
+TEST_SEQUENCE_NR=1
+
+__log_test_start() {
+       TIMESTAMP=$(date "+%Y-%m-%d %H:%M:%S")
+       echo -e $BOLD"TEST $TEST_SEQUENCE_NR (${BASH_LINENO[1]}): ${FUNCNAME[1]}" $@ $EBOLD
+    echo "TEST $TEST_SEQUENCE_NR - ${TIMESTAMP}: (${BASH_LINENO[1]}): ${FUNCNAME[1]}" $@ >> $HTTPLOG
+       ((RES_TEST++))
+       ((TEST_SEQUENCE_NR++))
+}
+
+__log_test_fail_general() {
+       echo -e $RED" FAIL."$1 $ERED
+       ((RES_FAIL++))
+       __check_stop_at_error
+}
+
+__log_test_fail_status_code() {
+       echo -e $RED" FAIL. Exepected status "$1", got "$2 $3 $ERED
+       ((RES_FAIL++))
+       __check_stop_at_error
+}
+
+__log_test_fail_body() {
+       echo -e $RED" FAIL, returned body not correct"$ERED
+       ((RES_FAIL++))
+       __check_stop_at_error
+}
+
+__log_test_fail_not_supported() {
+       echo -e $RED" FAIL, function not supported"$ERED
+       ((RES_FAIL++))
+       __check_stop_at_error
+}
+
+__log_test_pass() {
+       if [ $# -gt 0 ]; then
+               echo $@
+       fi
+       ((RES_PASS++))
+       echo -e $GREEN" PASS"$EGREEN
+}
+
+#Counter for configurations
+CONF_SEQUENCE_NR=1
+__log_conf_start() {
+       TIMESTAMP=$(date "+%Y-%m-%d %H:%M:%S")
+       echo -e $BOLD"CONF $CONF_SEQUENCE_NR (${BASH_LINENO[1]}): "${FUNCNAME[1]} $@ $EBOLD
+       echo "CONF $CONF_SEQUENCE_NR - ${TIMESTAMP}: (${BASH_LINENO[1]}): "${FUNCNAME[1]} $@  >> $HTTPLOG
+       ((CONF_SEQUENCE_NR++))
+}
+
+__log_conf_fail_general() {
+       echo -e $RED" FAIL."$1 $ERED
+       ((RES_CONF_FAIL++))
+       __check_stop_at_error
+}
+
+__log_conf_fail_status_code() {
+       echo -e $RED" FAIL. Exepected status "$1", got "$2 $3 $ERED
+       ((RES_CONF_FAIL++))
+       __check_stop_at_error
+}
+
+__log_conf_fail_body() {
+       echo -e $RED" FAIL, returned body not correct"$ERED
+       ((RES_CONF_FAIL++))
+       __check_stop_at_error
+}
+
+__log_conf_ok() {
+       if [ $# -gt 0 ]; then
+               echo $@
+       fi
+       echo -e $GREEN" OK"$EGREEN
+}
+
 #Var for measuring execution time
 TCTEST_START=$SECONDS
 
@@ -209,7 +314,7 @@ while [ $paramerror -eq 0 ] && [ $foundparm -eq 0 ]; do
                        if [ -z "$1" ]; then
                                paramerror=1
                        else
-                               echo "Option set - Overriding test_env.sh with: "$1
+                               echo "Option set - Reading test env from: "$1
                                shift;
                                foundparm=0
                        fi
@@ -251,8 +356,23 @@ fi
 if [ -f "$TEST_ENV_VAR_FILE" ]; then
        echo -e $BOLD"Sourcing env vars from: "$TEST_ENV_VAR_FILE$EBOLD
        . $TEST_ENV_VAR_FILE
+
+       if [ -z "$TEST_ENV_PROFILE" ] || [ -z "$SUPPORTED_PROFILES" ]; then
+               echo -e $YELLOW"This test case may no work with selected test env file. TEST_ENV_PROFILE is missing in test_env file or SUPPORTED_PROFILES is missing in test case file"$EYELLOW
+       else
+               if [[ "$SUPPORTED_PROFILES" == *"$TEST_ENV_PROFILE"* ]]; then
+                       echo -e $GREEN"Test case support the selected test env file"$EGREEN
+               else
+                       echo -e $RED"Test case does not support the selected test env file"$ERED
+                       echo -e $RED"Exiting...."$ERED
+                       exit 1
+               fi
+       fi
 else
        echo -e $RED"Selected env var file does not exist: "$TEST_ENV_VAR_FILE$ERED
+       echo " Select one of following env var file matching the intended target of the test"
+       echo " Restart the test using the flag '--env-file <path-to-env-file>"
+       ls ../common/test_env* | indent1
        exit 1
 fi
 
@@ -260,9 +380,13 @@ fi
 G1_A1_VERSION=""
 G2_A1_VERSION=""
 G3_A1_VERSION=""
+G4_A1_VERSION=""
+G5_A1_VERSION=""
 G1_COUNT=0
 G2_COUNT=0
 G3_COUNT=0
+G4_COUNT=0
+G5_COUNT=0
 
 # Vars to switch between http and https. Extra curl flag needed for https
 export RIC_SIM_HTTPX="http"
@@ -277,17 +401,27 @@ export MR_LOCAL_PORT=$MR_EXTERNAL_PORT #When agent is running outside the docker
 export CR_HTTPX="http"
 export CR_PORT=$CR_INTERNAL_PORT
 export CR_LOCAL_PORT=$CR_EXTERNAL_PORT #When CR is running outside the docker net
+export CR_PATH="$CR_HTTPX://$CR_APP_NAME:$CR_PORT$CR_APP_CALLBACK"
+
+export PROD_STUB_HTTPX="http"
+export PROD_STUB_PORT=$PROD_STUB_INTERNAL_PORT
+export PROD_STUB_LOCAL_PORT=$PROD_STUB_EXTERNAL_PORT #When Prodstub is running outside the docker net
+export PROD_STUB_LOCALHOST=$PROD_STUB_HTTPX"://localhost:"$PROD_STUB_LOCAL_PORT
 
 export SDNC_HTTPX="http"
 export SDNC_PORT=$SDNC_INTERNAL_PORT
 export SDNC_LOCAL_PORT=$SDNC_EXTERNAL_PORT #When agent is running outside the docker net
 
+export RAPP_CAT_HTTPX="http"
+export RAPP_CAT_PORT=$RAPP_CAT_INTERNAL_PORT
+export RAPP_CAT_LOCAL_PORT=$RAPP_CAT_EXTERNAL_PORT #When Rapp catalogue is running outside the docker net
+
 echo -e $BOLD"Checking configured image setting for this test case"$EBOLD
 
 #Temp var to check for image variable name errors
 IMAGE_ERR=0
 #Create a file with image info for later printing as a table
-image_list_file=".image-list"
+image_list_file="./tmp/.image-list"
 echo -e " Container\tImage\ttag" > $image_list_file
 
 # Check if image env var is set and if so export the env var with image to use (used by docker compose files)
@@ -298,7 +432,7 @@ __check_image_var() {
                ((IMAGE_ERR++))
                return
        fi
-       __check_excluded_image $6
+       __check_included_image $6
        if [ $? -ne 0 ]; then
                echo -e "$1\t<image-excluded>\t<no-tag>"  >> $image_list_file
                # Image is excluded since the corresponding app is not used in this test
@@ -310,7 +444,7 @@ __check_image_var() {
        tag="${!5}"
 
        if [ -z $image ]; then
-               echo -e $RED"\$"$4" not set in test_env"$ERED
+               echo -e $RED"\$"$4" not set in $TEST_ENV_VAR_FILE"$ERED
                ((IMAGE_ERR++))
                echo ""
                tmp=$tmp"<no-image>\t"
@@ -318,7 +452,7 @@ __check_image_var() {
                tmp=$tmp$image"\t"
        fi
        if [ -z $tag ]; then
-               echo -e $RED"\$"$5" not set in test_env"$ERED
+               echo -e $RED"\$"$5" not set in $TEST_ENV_VAR_FILE"$ERED
                ((IMAGE_ERR++))
                echo ""
                tmp=$tmp"<no-tag>\t"
@@ -344,15 +478,16 @@ __check_image_local_override() {
        return 0
 }
 
-#Check if app uses image excluded from this test run
-# Possible IDs for image exclusion: PA, CP, SDNC, RICSIM, MR, CR, CBS, CONSUL, ECS
-__check_excluded_image() {
-       for im in $EXCLUDED_IMAGES; do
+# Check if app uses image included in this test run
+# Returns 0 if image is included, 1 if not
+# Possible IDs for image inclusion: CBS, CONSUL, CP, CR, ECS, MR, PA, PRODSTUB, RICSIM, SDNC
+__check_included_image() {
+       for im in $INCLUDED_IMAGES; do
                if [ "$1" == "$im" ]; then
-                       return 1
+                       return 0
                fi
        done
-       return 0
+       return 1
 }
 
 # Check that image env setting are available
@@ -419,6 +554,15 @@ elif [ $START_ARG == "remote" ] || [ $START_ARG == "remote-remove" ]; then
                __check_image_var " ECS" $START_ARG "ECS_IMAGE" "ECS_LOCAL_IMAGE" "ECS_LOCAL_IMAGE_TAG" ECS
        fi
 
+               __check_image_local_override 'RC'
+       if [ $? -eq 0 ]; then
+               #Remote ecs image
+               __check_image_var " RC" $START_ARG "RAPP_CAT_IMAGE" "RAPP_CAT_REMOTE_IMAGE" "RAPP_CAT_REMOTE_IMAGE_TAG" RC
+       else
+               #Local ecs image
+               __check_image_var " RC" $START_ARG "RAPP_CAT_IMAGE" "RAPP_CAT_LOCAL_IMAGE" "RAPP_CAT_LOCAL_IMAGE_TAG" RC
+       fi
+
 else
        #Should never get here....
        echo "Unknow args: "$@
@@ -429,6 +573,7 @@ fi
 # These images are not built as part of this project official images, just check that env vars are set correctly
 __check_image_var " Message Router" $START_ARG "MRSTUB_IMAGE" "MRSTUB_LOCAL_IMAGE" "MRSTUB_LOCAL_IMAGE_TAG" MR
 __check_image_var " Callback Receiver" $START_ARG "CR_IMAGE" "CR_LOCAL_IMAGE" "CR_LOCAL_IMAGE_TAG" CR
+__check_image_var " Producer stub" $START_ARG "PROD_STUB_IMAGE" "PROD_STUB_LOCAL_IMAGE" "PROD_STUB_LOCAL_IMAGE_TAG" PRODSTUB
 __check_image_var " Consul" $START_ARG "CONSUL_IMAGE" "CONSUL_REMOTE_IMAGE" "CONSUL_REMOTE_IMAGE_TAG" CONSUL
 __check_image_var " CBS" $START_ARG "CBS_IMAGE" "CBS_REMOTE_IMAGE" "CBS_REMOTE_IMAGE_TAG" CBS
 __check_image_var " SDNC DB" $START_ARG "SDNC_DB_IMAGE" "SDNC_DB_REMOTE_IMAGE" "SDNC_DB_REMOTE_IMAGE_TAG" SDNC #Uses sdnc app name
@@ -451,13 +596,13 @@ if [ -z "$SIM_GROUP" ]; then
        SIM_GROUP=$PWD/../simulator-group
        if [ ! -d  $SIM_GROUP ]; then
                echo "Trying to set env var SIM_GROUP to dir 'simulator-group' in the nontrtric repo, but failed."
-               echo -e $RED"Please set the SIM_GROUP manually in the test_env.sh"$ERED
+               echo -e $RED"Please set the SIM_GROUP manually in the applicable $TEST_ENV_VAR_FILE"$ERED
                exit 1
        else
                echo " SIM_GROUP auto set to: " $SIM_GROUP
        fi
 elif [ $SIM_GROUP = *simulator_group ]; then
-       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
+       echo -e $RED"Env var SIM_GROUP does not seem to point to dir 'simulator-group' in the repo, check $TEST_ENV_VAR_FILE"$ERED
        exit 1
 else
        echo " SIM_GROUP env var already set to: " $SIM_GROUP
@@ -489,24 +634,24 @@ __check_and_pull_image() {
                        echo -ne "  Attempt to stop and remove container(s), if running - ${SAMELINE}"
                        tmp="$(docker ps -aq --filter name=${3})"
                        if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then
-                               docker stop $tmp &> .dockererr
+                               docker stop $tmp &> ./tmp/.dockererr
                                if [ $? -ne 0 ]; then
                                        ((IMAGE_ERR++))
                                        echo ""
                                        echo -e $RED"  Container(s) could not be stopped - try manual stopping the container(s)"$ERED
-                                       cat .dockererr
+                                       cat ./tmp/.dockererr
                                        return 1
                                fi
                        fi
                        echo -ne "  Attempt to stop and remove container(s), if running - "$GREEN"stopped"$EGREEN"${SAMELINE}"
                        tmp="$(docker ps -aq --filter name=${3})" &> /dev/null
                        if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then
-                               docker rm $tmp &> .dockererr
+                               docker rm $tmp &> ./tmp/.dockererr
                                if [ $? -ne 0 ]; then
                                        ((IMAGE_ERR++))
                                        echo ""
                                        echo -e $RED"  Container(s) could not be removed - try manual removal of the container(s)"$ERED
-                                       cat .dockererr
+                                       cat ./tmp/.dockererr
                                        return 1
                                fi
                        fi
@@ -514,12 +659,12 @@ __check_and_pull_image() {
                        echo -ne "  Removing image - ${SAMELINE}"
                        tmp="$(docker images -q ${4})" &> /dev/null
                        if [ $? -eq 0 ] && [ ! -z "$tmp" ]; then
-                               docker rmi --force $4 &> .dockererr
+                               docker rmi --force $4 &> ./tmp/.dockererr
                                if [ $? -ne 0 ]; then
                                        ((IMAGE_ERR++))
                                        echo ""
                                        echo -e $RED"  Image could not be removed - try manual removal of the image"$ERED
-                                       cat .dockererr
+                                       cat ./tmp/.dockererr
                                        return 1
                                fi
                                echo -e "  Removing image - "$GREEN"removed"$EGREEN
@@ -530,13 +675,13 @@ __check_and_pull_image() {
                fi
                if [ -z "$tmp_im" ]; then
                        echo -ne "  Pulling image${SAMELINE}"
-                       docker pull $4  &> .dockererr
+                       docker pull $4  &> ./tmp/.dockererr
                        tmp_im=$(docker images ${4} | grep -v REPOSITORY)
                        if [ -z "$tmp_im" ]; then
                                echo ""
                                echo -e "  Pulling image -$RED could not be pulled"$ERED
                                ((IMAGE_ERR++))
-                               cat .dockererr
+                               cat ./tmp/.dockererr
                                return 1
                        fi
                        echo -e "  Pulling image -$GREEN Pulled $EGREEN"
@@ -550,7 +695,7 @@ __check_and_pull_image() {
 
 echo -e $BOLD"Pulling configured images, if needed"$EBOLD
 
-__check_excluded_image 'PA'
+__check_included_image 'PA'
 if [ $? -eq 0 ]; then
        START_ARG_MOD=$START_ARG
        __check_image_local_override 'PA'
@@ -562,7 +707,7 @@ else
        echo -e $YELLOW" Excluding PA image from image check/pull"$EYELLOW
 fi
 
-__check_excluded_image 'ECS'
+__check_included_image 'ECS'
 if [ $? -eq 0 ]; then
        START_ARG_MOD=$START_ARG
        __check_image_local_override 'ECS'
@@ -574,7 +719,7 @@ else
        echo -e $YELLOW" Excluding ECS image from image check/pull"$EYELLOW
 fi
 
-__check_excluded_image 'CP'
+__check_included_image 'CP'
 if [ $? -eq 0 ]; then
        START_ARG_MOD=$START_ARG
        __check_image_local_override 'CP'
@@ -586,7 +731,19 @@ else
        echo -e $YELLOW" Excluding Non-RT RIC Control Panel image from image check/pull"$EYELLOW
 fi
 
-__check_excluded_image 'RICSIM'
+__check_included_image 'RC'
+if [ $? -eq 0 ]; then
+       START_ARG_MOD=$START_ARG
+       __check_image_local_override 'RC'
+       if [ $? -eq 1 ]; then
+               START_ARG_MOD="local"
+       fi
+       app="RAPP Catalogue"; __check_and_pull_image $START_ARG_MOD "$app" $RAPP_CAT_APP_NAME $RAPP_CAT_IMAGE
+else
+       echo -e $YELLOW" Excluding RAPP Catalogue image from image check/pull"$EYELLOW
+fi
+
+__check_included_image 'RICSIM'
 if [ $? -eq 0 ]; then
        START_ARG_MOD=$START_ARG
        __check_image_local_override 'RICSIM'
@@ -599,21 +756,21 @@ else
 fi
 
 
-__check_excluded_image 'CONSUL'
+__check_included_image 'CONSUL'
 if [ $? -eq 0 ]; then
        app="Consul";                   __check_and_pull_image $START_ARG "$app" $CONSUL_APP_NAME $CONSUL_IMAGE
 else
        echo -e $YELLOW" Excluding Consul image from image check/pull"$EYELLOW
 fi
 
-__check_excluded_image 'CBS'
+__check_included_image 'CBS'
 if [ $? -eq 0 ]; then
        app="CBS";                      __check_and_pull_image $START_ARG "$app" $CBS_APP_NAME $CBS_IMAGE
 else
        echo -e $YELLOW" Excluding CBS image from image check/pull"$EYELLOW
 fi
 
-__check_excluded_image 'SDNC'
+__check_included_image 'SDNC'
 if [ $? -eq 0 ]; then
        START_ARG_MOD=$START_ARG
        __check_image_local_override 'SDNC'
@@ -642,82 +799,113 @@ echo ""
 echo -e $BOLD"Building images needed for test"$EBOLD
 
 curdir=$PWD
-__check_excluded_image 'MR'
+__check_included_image 'MR'
 if [ $? -eq 0 ]; then
        cd $curdir
        cd ../mrstub
-       echo " Building mrstub image: mrstub:latest"
-       docker build -t mrstub . &> .dockererr
+       echo " Building mrstub image: $MRSTUB_LOCAL_IMAGE:$MRSTUB_LOCAL_IMAGE_TAG"
+       docker build  --build-arg NEXUS_PROXY_REPO=$NEXUS_PROXY_REPO -t $MRSTUB_LOCAL_IMAGE . &> .dockererr
        if [ $? -eq 0 ]; then
                echo -e  $GREEN" Build Ok"$EGREEN
        else
                echo -e $RED" Build Failed"$ERED
                ((RES_CONF_FAIL++))
                cat .dockererr
+               echo -e $RED"Exiting...."$ERED
+               exit 1
        fi
        cd $curdir
 else
        echo -e $YELLOW" Excluding mrstub from image build"$EYELLOW
 fi
 
-__check_excluded_image 'CR'
+__check_included_image 'CR'
 if [ $? -eq 0 ]; then
        cd ../cr
-       echo " Building Callback Receiver image: callback-receiver:latest"
-       docker build -t callback-receiver . &> .dockererr
+       echo " Building Callback Receiver image: $CR_LOCAL_IMAGE:$CR_IMAGE_TAG"
+       docker build  --build-arg NEXUS_PROXY_REPO=$NEXUS_PROXY_REPO -t $CR_LOCAL_IMAGE . &> .dockererr
        if [ $? -eq 0 ]; then
                echo -e  $GREEN" Build Ok"$EGREEN
        else
                echo -e $RED" Build Failed"$ERED
                ((RES_CONF_FAIL++))
                cat .dockererr
+               echo -e $RED"Exiting...."$ERED
+               exit 1
        fi
        cd $curdir
 else
        echo -e $YELLOW" Excluding Callback Receiver from image build"$EYELLOW
 fi
 
+__check_included_image 'PRODSTUB'
+if [ $? -eq 0 ]; then
+       cd ../prodstub
+       echo " Building Producer stub image: $PROD_STUB_LOCAL_IMAGE:$PROD_STUB_LOCAL_IMAGE_TAG"
+       docker build  --build-arg NEXUS_PROXY_REPO=$NEXUS_PROXY_REPO -t $PROD_STUB_LOCAL_IMAGE . &> .dockererr
+       if [ $? -eq 0 ]; then
+               echo -e  $GREEN" Build Ok"$EGREEN
+       else
+               echo -e $RED" Build Failed"$ERED
+               ((RES_CONF_FAIL++))
+               cat .dockererr
+               echo -e $RED"Exiting...."$ERED
+               exit 1
+       fi
+       cd $curdir
+else
+       echo -e $YELLOW" Excluding Producer stub from image build"$EYELLOW
+fi
+
 echo ""
 
 # Create a table of the images used in the script
 echo -e $BOLD"Local docker registry images used in the this test script"$EBOLD
 
-docker_tmp_file=.docker-images-table
+docker_tmp_file=./tmp/.docker-images-table
 format_string="{{.Repository}}\\t{{.Tag}}\\t{{.CreatedSince}}\\t{{.Size}}\\t{{.CreatedAt}}"
 echo -e " Application\tRepository\tTag\tCreated since\tSize\tCreated at" > $docker_tmp_file
-__check_excluded_image 'PA'
+__check_included_image 'PA'
 if [ $? -eq 0 ]; then
        echo -e " Policy Agent\t$(docker images --format $format_string $POLICY_AGENT_IMAGE)" >>   $docker_tmp_file
 fi
-__check_excluded_image 'ECS'
+__check_included_image 'ECS'
 if [ $? -eq 0 ]; then
        echo -e " ECS\t$(docker images --format $format_string $ECS_IMAGE)" >>   $docker_tmp_file
 fi
-__check_excluded_image 'CP'
+__check_included_image 'CP'
 if [ $? -eq 0 ]; then
        echo -e " Control Panel\t$(docker images --format $format_string $CONTROL_PANEL_IMAGE)" >>   $docker_tmp_file
 fi
-__check_excluded_image 'RICSIM'
+__check_included_image 'RICSIM'
 if [ $? -eq 0 ]; then
        echo -e " RIC Simulator\t$(docker images --format $format_string $RIC_SIM_IMAGE)" >>   $docker_tmp_file
 fi
-__check_excluded_image 'MR'
+__check_included_image 'RC'
+if [ $? -eq 0 ]; then
+       echo -e " RAPP Catalogue\t$(docker images --format $format_string $RAPP_CAT_IMAGE)" >>   $docker_tmp_file
+fi
+__check_included_image 'MR'
 if [ $? -eq 0 ]; then
        echo -e " Message Router\t$(docker images --format $format_string $MRSTUB_IMAGE)" >>   $docker_tmp_file
 fi
-__check_excluded_image 'CR'
+__check_included_image 'CR'
 if [ $? -eq 0 ]; then
        echo -e " Callback Receiver\t$(docker images --format $format_string $CR_IMAGE)" >>   $docker_tmp_file
 fi
-__check_excluded_image 'CONSUL'
+__check_included_image 'PRODSTUB'
+if [ $? -eq 0 ]; then
+       echo -e " Produccer stub\t$(docker images --format $format_string $PROD_STUB_IMAGE)" >>   $docker_tmp_file
+fi
+__check_included_image 'CONSUL'
 if [ $? -eq 0 ]; then
        echo -e " Consul\t$(docker images --format $format_string $CONSUL_IMAGE)" >>   $docker_tmp_file
 fi
-__check_excluded_image 'CBS'
+__check_included_image 'CBS'
 if [ $? -eq 0 ]; then
        echo -e " CBS\t$(docker images --format $format_string $CBS_IMAGE)" >>   $docker_tmp_file
 fi
-__check_excluded_image 'SDNC'
+__check_included_image 'SDNC'
 if [ $? -eq 0 ]; then
        echo -e " SDNC A1 Controller\t$(docker images --format $format_string $SDNC_A1_CONTROLLER_IMAGE)" >>   $docker_tmp_file
        echo -e " SDNC DB\t$(docker images --format $format_string $SDNC_DB_IMAGE)" >>   $docker_tmp_file
@@ -746,6 +934,7 @@ print_result() {
        echo "-------------------------------------------------------------------------------------------------"
        echo "-- Description: "$TC_ONELINE_DESCR
        echo "-- Execution time: " $duration " seconds"
+       echo "-- Used env file: "$TEST_ENV_VAR_FILE
        echo "-------------------------------------------------------------------------------------------------"
        echo "-------------------------------------     RESULTS"
        echo ""
@@ -931,9 +1120,11 @@ clean_containers() {
 
        CONTAINTER_NAMES=("Policy Agent           " $(__check_app_name $POLICY_AGENT_APP_NAME)\
                                          "ECS                    " $(__check_app_name $ECS_APP_NAME)\
+                                         "RAPP Catalogue         " $(__check_app_name $RAPP_CAT_APP_NAME)\
                                          "Non-RT RIC Simulator(s)" $(__check_app_name $RIC_SIM_PREFIX)\
                                          "Message Router         " $(__check_app_name $MR_APP_NAME)\
                                          "Callback Receiver      " $(__check_app_name $CR_APP_NAME)\
+                                         "Producer stub          " $(__check_app_name $PROD_STUB_APP_NAME)\
                                          "Control Panel          " $(__check_app_name $CONTROL_PANEL_APP_NAME)\
                                          "SDNC A1 Controller     " $(__check_app_name $SDNC_APP_NAME)\
                                          "SDNC DB                " $(__check_app_name $SDNC_DB_APP_NAME)\
@@ -975,21 +1166,17 @@ clean_containers() {
                fi
        fi
        echo -e "$GREEN  Done$EGREEN"
-       echo ""
 
        echo -e $BOLD" Removing all unused docker neworks"$EBOLD
        docker network prune --force | indent2
        echo -e "$GREEN  Done$EGREEN"
-       echo ""
 
        echo -e $BOLD" Removing all unused docker volumes"$EBOLD
        docker volume prune --force | indent2
        echo -e "$GREEN  Done$EGREEN"
-       echo ""
 
        echo -e $BOLD" Removing all dangling/untagged docker images"$EBOLD
     docker rmi --force $(docker images -q -f dangling=true) &> /dev/null
-       echo ""
        echo -e "$GREEN  Done$EGREEN"
        echo ""
 
@@ -997,7 +1184,8 @@ clean_containers() {
        if [ $? -eq 0 ]; then
                if [ $CONTRS -ne 0 ]; then
                        echo -e $RED"Containers running, may cause distubance to the test case"$ERED
-                       docker ps -a
+                       docker ps -a | indent1
+                       echo ""
                fi
        fi
 }
@@ -1043,6 +1231,7 @@ __print_err() {
        if [ $# -gt 1 ]; then
                echo -e $RED" Got: "${FUNCNAME[1]} ${@:2} $ERED
        fi
+       ((RES_CONF_FAIL++))
 }
 
 
@@ -1116,7 +1305,8 @@ __check_container_start() {
                        ((RES_CONF_FAIL++))
                        echo ""
                        echo -e $RED" Container $BOLD${appname}$EBOLD could not be started"$ERED
-                       return 1
+                       echo -e $RED" Stopping script..."$ERED
+                       exit 1
                fi
                if [ $localport -eq 0 ]; then
                        while [ $localport -eq 0 ]; do
@@ -1151,7 +1341,7 @@ __check_container_start() {
                else
                        TS_TMP=$SECONDS
                        while [ $(($TS_TMP+$i)) -gt $SECONDS ]; do
-                               echo -ne " Waiting for container ${appname} service status...retrying in $(($TS_TMP+$i-$SECONDS)) seconds   ${SAMELINE}"
+                               echo -ne " Waiting for container ${appname} service status...$(($SECONDS-$TSTART)) seconds, retrying in $(($TS_TMP+$i-$SECONDS)) seconds   ${SAMELINE}"
                                sleep 1
                        done
                fi
@@ -1159,7 +1349,7 @@ __check_container_start() {
 
        if [ "$pa_st" = "false"  ]; then
                ((RES_CONF_FAIL++))
-               echo -e $RED" Container ${appname} did not respond to service status"$ERED
+               echo -e $RED" Container ${appname} did not respond to service status in $(($SECONDS-$TSTART)) seconds"$ERED
                return 0
        fi
 
@@ -1190,6 +1380,8 @@ __start_container() {
                if [ $? -ne 0 ]; then
                        echo -e $RED"Problem to launch container(s) with docker-compose"$ERED
                        cat .dockererr
+                       echo -e $RED"Stopping script...."$ERED
+                       exit 1
                fi
        elif [ "$2" == "STANDALONE" ]; then
                echo "Skipping docker-compose"
@@ -1198,6 +1390,8 @@ __start_container() {
                if [ $? -ne 0 ]; then
                        echo -e $RED"Problem to launch container(s) with docker-compose"$ERED
                        cat .dockererr
+                       echo -e $RED"Stopping script...."$ERED
+                       exit 1
                fi
        fi
        app_prefix=""
@@ -1247,14 +1441,15 @@ consul_config_app() {
 
        echo " Loading config for "$POLICY_AGENT_APP_NAME" from "$1
 
-       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
+       curlString="$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
+       result=$(__do_curl "$curlString")
        if [ $? -ne 0 ]; then
                echo -e $RED" FAIL - json config could not be loaded to consul" $ERED
                ((RES_CONF_FAIL++))
                return 1
        fi
        body="$(__do_curl $LOCALHOST$CBS_EXTERNAL_PORT/service_component_all/$POLICY_AGENT_APP_NAME)"
-       echo $body > ".output"$1
+       echo $body > "./tmp/.output"$1
 
        if [ $? -ne 0 ]; then
                echo -e $RED" FAIL - json config could not be loaded from consul/cbs, contents cannot be checked." $ERED
@@ -1392,7 +1587,7 @@ prepare_consul_config() {
 start_consul_cbs() {
 
        echo -e $BOLD"Starting Consul and CBS"$EBOLD
-       __check_excluded_image 'CONSUL'
+       __check_included_image 'CONSUL'
        if [ $? -eq 1 ]; then
                echo -e $RED"The Consul image has not been checked for this test run due to arg to the test script"$ERED
                echo -e $RED"Consul will not be started"$ERED
@@ -1407,7 +1602,8 @@ start_consul_cbs() {
 ###########################
 
 use_simulator_http() {
-       echo -e "Using $BOLD http $EBOLD towards the simulators"
+       echo -e $BOLD"RICSIM protocol setting"$EBOLD
+       echo -e " Using $BOLD http $EBOLD towards the simulators"
        export RIC_SIM_HTTPX="http"
        export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:"
        export RIC_SIM_PORT=$RIC_SIM_INTERNAL_PORT
@@ -1415,22 +1611,23 @@ use_simulator_http() {
 }
 
 use_simulator_https() {
-       echo -e "Using $BOLD https $EBOLD towards the simulators"
+       echo -e $BOLD"RICSIM protocol setting"$EBOLD
+       echo -e " Using $BOLD https $EBOLD towards the simulators"
        export RIC_SIM_HTTPX="https"
        export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:"
        export RIC_SIM_PORT=$RIC_SIM_INTERNAL_SECURE_PORT
        echo ""
 }
 
-# Start one group (ricsim_g1, ricsim_g2 or ricsim_g3) with a number of RIC Simulators using a given A interface
+# Start one group (ricsim_g1, ricsim_g2 .. ricsim_g5) with a number of RIC Simulators using a given A interface
 # 'ricsim' may be set on command line to other prefix
-# args:  ricsim_g1|ricsim_g2|ricsim_g3 <count> <interface-id>
+# args:  ricsim_g1|ricsim_g2|ricsim_g3|ricsim_g4|ricsim_g5 <count> <interface-id>
 # (Function for test scripts)
 start_ric_simulators() {
 
        echo -e $BOLD"Starting RIC Simulators"$EBOLD
 
-       __check_excluded_image 'RICSIM'
+       __check_included_image 'RICSIM'
        if [ $? -eq 1 ]; then
                echo -e $RED"The Near-RT RIC Simulator image has not been checked for this test run due to arg to the test script"$ERED
                echo -e $RED"The Near-RT RIC Simulartor(s) will not be started"$ERED
@@ -1440,10 +1637,12 @@ start_ric_simulators() {
        RIC1=$RIC_SIM_PREFIX"_g1"
        RIC2=$RIC_SIM_PREFIX"_g2"
        RIC3=$RIC_SIM_PREFIX"_g3"
+       RIC4=$RIC_SIM_PREFIX"_g4"
+       RIC5=$RIC_SIM_PREFIX"_g5"
 
        if [ $# != 3 ]; then
                ((RES_CONF_FAIL++))
-       __print_err "need three args,  $RIC1|$RIC2|$RIC3 <count> <interface-id>" $@
+       __print_err "need three args,  $RIC1|$RIC2|$RIC3|$RIC4|$RIC5 <count> <interface-id>" $@
                exit 1
        fi
        echo " $2 simulators using basename: $1 on interface: $3"
@@ -1457,9 +1656,15 @@ start_ric_simulators() {
        elif [ $1 == "$RIC3" ]; then
                G3_COUNT=$2
                G3_A1_VERSION=$3
+       elif [ $1 == "$RIC4" ]; then
+               G4_COUNT=$2
+               G4_A1_VERSION=$3
+       elif [ $1 == "$RIC5" ]; then
+               G5_COUNT=$2
+               G5_A1_VERSION=$3
        else
                ((RES_CONF_FAIL++))
-       __print_err "need three args, $RIC1|$RIC2|$RIC3 <count> <interface-id>" $@
+       __print_err "need three args, $RIC1|$RIC2|$RIC3|$RIC4|$RIC5 <count> <interface-id>" $@
                exit 1
        fi
 
@@ -1469,8 +1674,10 @@ start_ric_simulators() {
        export G1_A1_VERSION
        export G2_A1_VERSION
        export G3_A1_VERSION
+       export G4_A1_VERSION
+       export G5_A1_VERSION
 
-       docker_args="--scale g1=$G1_COUNT --scale g2=$G2_COUNT --scale g3=$G3_COUNT"
+       docker_args="--scale g1=$G1_COUNT --scale g2=$G2_COUNT --scale g3=$G3_COUNT --scale g4=$G4_COUNT --scale g5=$G5_COUNT"
        app_data=""
        cntr=1
        while [ $cntr -le $2 ]; do
@@ -1493,7 +1700,7 @@ start_ric_simulators() {
 start_control_panel() {
 
        echo -e $BOLD"Starting Control Panel"$EBOLD
-       __check_excluded_image 'CP'
+       __check_included_image 'CP'
        if [ $? -eq 1 ]; then
                echo -e $RED"The Control Panel image has not been checked for this test run due to arg to the test script"$ERED
                echo -e $RED"The Control Panel will not be started"$ERED
@@ -1503,6 +1710,44 @@ start_control_panel() {
 
 }
 
+###########################
+### RAPP Catalogue
+###########################
+
+# Start the RAPP Catalogue container
+# args: -
+# (Function for test scripts)
+start_rapp_catalogue() {
+
+       echo -e $BOLD"Starting RAPP Catalogue"$EBOLD
+
+       __check_included_image 'RC'
+       if [ $? -eq 1 ]; then
+               echo -e $RED"The RAPP Catalogue image has not been checked for this test run due to arg to the test script"$ERED
+               echo -e $RED"The RAPP Catalogue will not be started"$ERED
+               exit
+       fi
+       __start_container rapp_catalogue NODOCKERARGS $RAPP_CAT_APP_NAME $RAPP_CAT_EXTERNAL_PORT "/services" "http"
+}
+
+use_rapp_catalogue_http() {
+       echo -e $BOLD"RAPP Catalogue protocol setting"$EBOLD
+       echo -e " Using $BOLD http $EBOLD towards the RAPP Catalogue"
+       export RAPP_CAT_HTTPX="http"
+       export RAPP_CAT_PORT=$RAPP_CAT_INTERNAL_PORT
+       export RAPP_CAT_LOCAL_PORT=$RAPP_CAT_EXTERNAL_PORT
+       echo ""
+}
+
+use_rapp_catalogue_https() {
+       echo -e $BOLD"RAPP Catalogue protocol setting"$EBOLD
+       echo -e " Using $BOLD https $EBOLD towards the RAPP Catalogue"
+       export RAPP_CAT_HTTPX="https"
+       export RAPP_CAT_PORT=$RAPP_CAT_INTERNAL_PORT
+       export RAPP_CAT_LOCAL_PORT=$RAPP_CAT_EXTERNAL_PORT
+       echo ""
+}
+
 ##################
 ### SDNC functions
 ##################
@@ -1514,7 +1759,7 @@ start_sdnc() {
 
        echo -e $BOLD"Starting SDNC A1 Controller"$EBOLD
 
-       __check_excluded_image 'SDNC'
+       __check_included_image 'SDNC'
        if [ $? -eq 1 ]; then
                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
                echo -e $RED"SDNC will not be started"$ERED
@@ -1526,7 +1771,8 @@ start_sdnc() {
 }
 
 use_sdnc_http() {
-       echo -e "Using $BOLD http $EBOLD towards SDNC"
+       echo -e $BOLD"SDNC protocol setting"$EBOLD
+       echo -e " Using $BOLD http $EBOLD towards SDNC"
        export SDNC_HTTPX="http"
        export SDNC_PORT=$SDNC_INTERNAL_PORT
        export SDNC_LOCAL_PORT=$SDNC_EXTERNAL_PORT
@@ -1534,7 +1780,8 @@ use_sdnc_http() {
 }
 
 use_sdnc_https() {
-       echo -e "Using $BOLD https $EBOLD towards SDNC"
+       echo -e $BOLD"SDNC protocol setting"$EBOLD
+       echo -e " Using $BOLD https $EBOLD towards SDNC"
        export SDNC_HTTPX="https"
        export SDNC_PORT=$SDNC_INTERNAL_SECURE_PORT
        export SDNC_LOCAL_PORT=$SDNC_EXTERNAL_SECURE_PORT
@@ -1551,7 +1798,7 @@ use_sdnc_https() {
 start_mr() {
 
        echo -e $BOLD"Starting Message Router 'mrstub'"$EBOLD
-       __check_excluded_image 'MR'
+       __check_included_image 'MR'
        if [ $? -eq 1 ]; then
                echo -e $RED"The Message Router image has not been checked for this test run due to arg to the test script"$ERED
                echo -e $RED"The Message Router will not be started"$ERED
@@ -1562,7 +1809,8 @@ start_mr() {
 }
 
 use_mr_http() {
-       echo -e "Using $BOLD http $EBOLD towards MR"
+       echo -e $BOLD"MR protocol setting"$EBOLD
+       echo -e " Using $BOLD http $EBOLD towards MR"
        export MR_HTTPX="http"
        export MR_PORT=$MR_INTERNAL_PORT
        export MR_LOCAL_PORT=$MR_EXTERNAL_PORT
@@ -1570,7 +1818,8 @@ use_mr_http() {
 }
 
 use_mr_https() {
-       echo -e "Using $BOLD https $EBOLD towards MR"
+       echo -e $BOLD"MR protocol setting"$EBOLD
+       echo -e " Using $BOLD https $EBOLD towards MR"
        export MR_HTTPX="https"
        export MR_PORT=$MR_INTERNAL_SECURE_PORT
        export MR_LOCAL_PORT=$MR_EXTERNAL_SECURE_PORT
@@ -1588,7 +1837,7 @@ use_mr_https() {
 start_cr() {
 
        echo -e $BOLD"Starting Callback Receiver"$EBOLD
-       __check_excluded_image 'CR'
+       __check_included_image 'CR'
        if [ $? -eq 1 ]; then
                echo -e $RED"The Callback Receiver image has not been checked for this test run due to arg to the test script"$ERED
                echo -e $RED"The Callback Receiver will not be started"$ERED
@@ -1599,18 +1848,62 @@ start_cr() {
 }
 
 use_cr_http() {
-       echo -e "Using $BOLD http $EBOLD towards CR"
+       echo -e $BOLD"CR protocol setting"$EBOLD
+       echo -e " Using $BOLD http $EBOLD towards CR"
        export CR_HTTPX="http"
        export CR_PORT=$CR_INTERNAL_PORT
        export CR_LOCAL_PORT=$CR_EXTERNAL_PORT
+       export CR_PATH="$CR_HTTPX://$CR_APP_NAME:$CR_PORT$CR_APP_CALLBACK"
        echo ""
 }
 
 use_cr_https() {
-       echo -e "Using $BOLD https $EBOLD towards CR"
+       echo -e $BOLD"CR protocol setting"$EBOLD
+       echo -e " Using $BOLD https $EBOLD towards CR"
        export CR_HTTPX="https"
        export CR_PORT=$CR_INTERNAL_SECURE_PORT
        export CR_LOCAL_PORT=$CR_EXTERNAL_SECURE_PORT
+       export CR_PATH="$CR_HTTPX://$CR_APP_NAME:$CR_PORT$CR_APP_CALLBACK"
+       echo ""
+}
+
+###########################
+### Producer stub functions
+###########################
+
+# Start the Producer stub in the simulator group
+# args: -
+# (Function for test scripts)
+start_prod_stub() {
+
+       echo -e $BOLD"Starting Producer stub"$EBOLD
+       __check_included_image 'PRODSTUB'
+       if [ $? -eq 1 ]; then
+               echo -e $RED"The Producer stub image has not been checked for this test run due to arg to the test script"$ERED
+               echo -e $RED"The Producer stub will not be started"$ERED
+               exit
+       fi
+       __start_container prodstub NODOCKERARGS $PROD_STUB_APP_NAME $PROD_STUB_EXTERNAL_PORT "/" "http"
+
+}
+
+use_prod_stub_http() {
+       echo -e $BOLD"Producer stub protocol setting"$EBOLD
+       echo -e " Using $BOLD http $EBOLD towards Producer stub"
+       export PROD_STUB_HTTPX="http"
+       export PROD_STUB_PORT=$PROD_STUB_INTERNAL_PORT
+       export PROD_STUB_LOCAL_PORT=$PROD_STUB_EXTERNAL_PORT
+       export PROD_STUB_LOCALHOST=$PROD_STUB_HTTPX"://localhost:"$PROD_STUB_LOCAL_PORT
+       echo ""
+}
+
+use_prod_stub_https() {
+       echo -e $BOLD"Producer stub protocol setting"$EBOLD
+       echo -e " Using $BOLD https $EBOLD towards Producer stub"
+       export PROD_STUB_HTTPX="https"
+       export PROD_STUB_PORT=$PROD_STUB_INTERNAL_SECURE_PORT
+       export PROD_STUB_LOCAL_PORT=$PROD_STUB_EXTERNAL_SECURE_PORT
+       export PROD_STUB_LOCALHOST=$PROD_STUB_HTTPX"://localhost:"$PROD_STUB_LOCAL_PORT
        echo ""
 }
 
@@ -1631,7 +1924,7 @@ start_policy_agent() {
        echo -e $BOLD"Starting Policy Agent"$EBOLD
 
        if [ $AGENT_STAND_ALONE -eq 0 ]; then
-               __check_excluded_image 'PA'
+               __check_included_image 'PA'
                if [ $? -eq 1 ]; then
                        echo -e $RED"The Policy Agent image has not been checked for this test run due to arg to the test script"$ERED
                        echo -e $RED"The Policy Agent will not be started"$ERED
@@ -1655,7 +1948,8 @@ start_policy_agent() {
 # args: -
 # (Function for test scripts)
 use_agent_rest_http() {
-       echo -e "Using $BOLD http $EBOLD and $BOLD REST $EBOLD towards the agent"
+       echo -e $BOLD"Agent protocol setting"$EBOLD
+       echo -e " Using $BOLD http $EBOLD and $BOLD REST $EBOLD towards the agent"
        export ADAPTER=$RESTBASE
        echo ""
 }
@@ -1664,7 +1958,8 @@ use_agent_rest_http() {
 # args: -
 # (Function for test scripts)
 use_agent_rest_https() {
-       echo -e "Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards the agent"
+       echo -e $BOLD"Agent protocol setting"$EBOLD
+       echo -e " Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards the agent"
        export ADAPTER=$RESTBASE_SECURE
        echo ""
        return 0
@@ -1674,7 +1969,8 @@ use_agent_rest_https() {
 # args: -
 # (Function for test scripts)
 use_agent_dmaap_http() {
-       echo -e "Using $BOLD http $EBOLD and $BOLD DMAAP $EBOLD towards the agent"
+       echo -e $BOLD"Agent dmaap protocol setting"$EBOLD
+       echo -e " Using $BOLD http $EBOLD and $BOLD DMAAP $EBOLD towards the agent"
        export ADAPTER=$DMAAPBASE
        echo ""
        return 0
@@ -1684,7 +1980,8 @@ use_agent_dmaap_http() {
 # args: -
 # (Function for test scripts)
 use_agent_dmaap_https() {
-       echo -e "Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards the agent"
+       echo -e $BOLD"Agent dmaap protocol setting"$EBOLD
+       echo -e " Using $BOLD https $EBOLD and $BOLD DMAAP $EBOLD towards the agent"
        export ADAPTER=$DMAAPBASE_SECURE
        echo ""
        return 0
@@ -1694,10 +1991,16 @@ use_agent_dmaap_https() {
 # args: -
 # (Function for test scripts)
 set_agent_debug() {
-       echo -e $BOLD"Setting agent debug"$EBOLD
-       curl $LOCALHOST$POLICY_AGENT_EXTERNAL_PORT/actuator/loggers/org.oransc.policyagent -X POST  -H 'Content-Type: application/json' -d '{"configuredLevel":"debug"}' &> /dev/null
+       echo -e $BOLD"Setting agent debug logging"$EBOLD
+       actuator="/actuator/loggers/org.oransc.policyagent"
+       if [[ $POLICY_AGENT_IMAGE = *"onap"* ]]; then
+               actuator="/actuator/loggers/org.onap.ccsdk.oran.a1policymanagementservice"
+       fi
+       curlString="$LOCALHOST$POLICY_AGENT_EXTERNAL_PORT$actuator -X POST  -H Content-Type:application/json -d {\"configuredLevel\":\"debug\"}"
+       result=$(__do_curl "$curlString")
        if [ $? -ne 0 ]; then
                __print_err "could not set debug mode" $@
+               ((RES_CONF_FAIL++))
                return 1
        fi
        echo ""
@@ -1708,10 +2011,16 @@ set_agent_debug() {
 # args: -
 # (Function for test scripts)
 set_agent_trace() {
-       echo -e $BOLD"Setting agent trace"$EBOLD
-       curl $LOCALHOST$POLICY_AGENT_EXTERNAL_PORT/actuator/loggers/org.oransc.policyagent -X POST  -H 'Content-Type: application/json' -d '{"configuredLevel":"trace"}' &> /dev/null
+       echo -e $BOLD"Setting agent trace logging"$EBOLD
+       actuator="/actuator/loggers/org.oransc.policyagent"
+       if [[ $POLICY_AGENT_IMAGE = *"onap"* ]]; then
+               actuator="/actuator/loggers/org.onap.ccsdk.oran.a1policymanagementservice"
+       fi
+       curlString="$LOCALHOST$POLICY_AGENT_EXTERNAL_PORT$actuator -X POST  -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}"
+       result=$(__do_curl "$curlString")
        if [ $? -ne 0 ]; then
                __print_err "could not set trace mode" $@
+               ((RES_CONF_FAIL++))
                return 1
        fi
        echo ""
@@ -1738,21 +2047,59 @@ use_agent_retries() {
 start_ecs() {
 
        echo -e $BOLD"Starting ECS"$EBOLD
-       __check_excluded_image 'ECS'
+
+       curdir=$PWD
+       cd $SIM_GROUP
+       cd ecs
+       cd $ECS_HOST_MNT_DIR
+       if [ -d database ]; then
+               if [ "$(ls -A $DIR)" ]; then
+                       echo -e $BOLD" Cleaning files in mounted dir: $PWD/database"$EBOLD
+                       rm -rf database/*  &> /dev/null
+                       if [ $? -ne 0 ]; then
+                               echo -e $RED" Cannot remove database files in: $PWD"$ERED
+                               exit 1
+                       fi
+               fi
+       else
+               echo " No files in mounted dir or dir does not exists"
+       fi
+       cd $curdir
+
+       __check_included_image 'ECS'
        if [ $? -eq 1 ]; then
                echo -e $RED"The ECS image has not been checked for this test run due to arg to the test script"$ERED
                echo -e $RED"ECS will not be started"$ERED
                exit
        fi
        export ECS_CERT_MOUNT_DIR="./cert"
-       __start_container ecs NODOCKERARGS $ECS_APP_NAME $ECS_EXTERNAL_PORT "/ei-producer/v1/eiproducers" "http"
+       __start_container ecs NODOCKERARGS $ECS_APP_NAME $ECS_EXTERNAL_PORT "/status" "http"
+}
+
+# Restart ECS
+# args: -
+# (Function for test scripts)
+restart_ecs() {
+       echo -e $BOLD"Re-starting ECS"$EBOLD
+       docker restart $ECS_APP_NAME &> ./tmp/.dockererr
+       if [ $? -ne 0 ]; then
+               __print_err "Could restart $ECS_APP_NAME" $@
+               cat ./tmp/.dockererr
+               ((RES_CONF_FAIL++))
+               return 1
+       fi
+
+       __check_container_start $ECS_APP_NAME $ECS_EXTERNAL_PORT "/status" "http"
+       echo ""
+       return 0
 }
 
 # All calls to ECS will be directed to the ECS REST interface from now on
 # args: -
 # (Function for test scripts)
 use_ecs_rest_http() {
-       echo -e "Using $BOLD http $EBOLD and $BOLD REST $EBOLD towards ECS"
+       echo -e $BOLD"ECS protocol setting"$EBOLD
+       echo -e " Using $BOLD http $EBOLD and $BOLD REST $EBOLD towards ECS"
        export ECS_ADAPTER=$ECS_RESTBASE
        echo ""
 }
@@ -1761,7 +2108,8 @@ use_ecs_rest_http() {
 # args: -
 # (Function for test scripts)
 use_ecs_rest_https() {
-       echo -e "Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards ECS"
+       echo -e $BOLD"ECS protocol setting"$EBOLD
+       echo -e " Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards ECS"
        export ECS_ADAPTER=$ECS_RESTBASE_SECURE
        echo ""
        return 0
@@ -1771,7 +2119,9 @@ use_ecs_rest_https() {
 # args: -
 # (Function for test scripts)
 use_ecs_dmaap_http() {
-       echo -e "Using $BOLD http $EBOLD and $BOLD DMAAP $EBOLD towards ECS"
+       echo -e $BOLD"ECS dmaap protocol setting"$EBOLD
+       echo -e $RED" - NOT SUPPORTED - "$ERED
+       echo -e " Using $BOLD http $EBOLD and $BOLD DMAAP $EBOLD towards ECS"
        export ECS_ADAPTER=$ECS_DMAAPBASE
        echo ""
        return 0
@@ -1781,7 +2131,9 @@ use_ecs_dmaap_http() {
 # args: -
 # (Function for test scripts)
 use_ecs_dmaap_https() {
-       echo -e "Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards ECS"
+       echo -e $BOLD"RICSIM protocol setting"$EBOLD
+       echo -e $RED" - NOT SUPPORTED - "$ERED
+       echo -e " Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards ECS"
        export ECS_ADAPTER=$ECS_DMAAPBASE_SECURE
        echo ""
        return 0
@@ -1791,10 +2143,12 @@ use_ecs_dmaap_https() {
 # args: -
 # (Function for test scripts)
 set_ecs_debug() {
-       echo -e $BOLD"Setting ecs debug"$EBOLD
-       curl $LOCALHOST$ECS_EXTERNAL_PORT/actuator/loggers/org.oransc.enrichment -X POST  -H 'Content-Type: application/json' -d '{"configuredLevel":"debug"}' &> /dev/null
+       echo -e $BOLD"Setting ecs debug logging"$EBOLD
+       curlString="$LOCALHOST$ECS_EXTERNAL_PORT/actuator/loggers/org.oransc.enrichment -X POST  -H Content-Type:application/json -d {\"configuredLevel\":\"debug\"}"
+       result=$(__do_curl "$curlString")
        if [ $? -ne 0 ]; then
-               __print_err "could not set debug mode" $@
+               __print_err "Could not set debug mode" $@
+               ((RES_CONF_FAIL++))
                return 1
        fi
        echo ""
@@ -1805,10 +2159,12 @@ set_ecs_debug() {
 # args: -
 # (Function for test scripts)
 set_ecs_trace() {
-       echo -e $BOLD"Setting agent trace"$EBOLD
-       curl $LOCALHOST$ECS_EXTERNAL_PORT/actuator/loggers/org.oransc.enrichment -X POST  -H 'Content-Type: application/json' -d '{"configuredLevel":"trace"}' &> /dev/null
+       echo -e $BOLD"Setting ecs trace logging"$EBOLD
+       curlString="$LOCALHOST$ECS_EXTERNAL_PORT/actuator/loggers/org.oransc.enrichment -X POST  -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}"
+       result=$(__do_curl "$curlString")
        if [ $? -ne 0 ]; then
-               __print_err "could not set trace mode" $@
+               __print_err "Could not set trace mode" $@
+               ((RES_CONF_FAIL++))
                return 1
        fi
        echo ""
@@ -1834,21 +2190,28 @@ use_agent_retries() {
 # (Function for test scripts)
 
 check_policy_agent_logs() {
-       __check_container_logs "Policy Agent" $POLICY_AGENT_APP_NAME $POLICY_AGENT_LOGPATH
+       __check_container_logs "Policy Agent" $POLICY_AGENT_APP_NAME $POLICY_AGENT_LOGPATH WARN ERR
 }
 
 check_ecs_logs() {
-       __check_container_logs "ECS" $ECS_APP_NAME $ECS_LOGPATH
+       __check_container_logs "ECS" $ECS_APP_NAME $ECS_LOGPATH WARN ERR
 }
 
 check_control_panel_logs() {
-       __check_container_logs "Control Panel" $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_LOGPATH
+       __check_container_logs "Control Panel" $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_LOGPATH WARN ERR
+}
+
+check_sdnc_logs() {
+       __check_container_logs "SDNC A1 Controller" $SDNC_APP_NAME $SDNC_KARAF_LOG WARN ERROR
 }
 
 __check_container_logs() {
        dispname=$1
        appname=$2
        logpath=$3
+       warning=$4
+       error=$5
+
        echo -e $BOLD"Checking $dispname container $appname log ($logpath) for WARNINGs and ERRORs"$EBOLD
 
        #tmp=$(docker ps | grep $appname)
@@ -1857,7 +2220,7 @@ __check_container_logs() {
                echo $dispname" is not running, no check made"
                return
        fi
-       foundentries="$(docker exec $tmp grep WARN $logpath | wc -l)"
+       foundentries="$(docker exec -t $tmp grep $warning $logpath | wc -l)"
        if [ $? -ne  0 ];then
                echo "  Problem to search $appname log $logpath"
        else
@@ -1867,7 +2230,7 @@ __check_container_logs() {
                        echo -e "  Found \033[1m"$foundentries"\033[0m WARN entries in $appname log $logpath"
                fi
        fi
-       foundentries="$(docker exec $tmp grep ERR $logpath | wc -l)"
+       foundentries="$(docker exec -t $tmp grep $error $logpath | wc -l)"
        if [ $? -ne  0 ];then
                echo "  Problem to search $appname log $logpath"
        else
@@ -1890,46 +2253,91 @@ store_logs() {
        __print_err "need one arg, <file-prefix>" $@
                exit 1
        fi
-       echo -e $BOLD"Storing all container logs using prefix: "$1$EBOLD
+       echo -e $BOLD"Storing all container logs in $TESTLOGS/$ATC using prefix: "$1$EBOLD
 
        docker stats --no-stream > $TESTLOGS/$ATC/$1_docker_stats.log 2>&1
-       docker logs $CONSUL_APP_NAME > $TESTLOGS/$ATC/$1_consul.log 2>&1
-       docker logs $CBS_APP_NAME > $TESTLOGS/$ATC/$1_cbs.log 2>&1
-       docker logs $POLICY_AGENT_APP_NAME > $TESTLOGS/$ATC/$1_policy-agent.log 2>&1
-       docker logs $ECS_APP_NAME > $TESTLOGS/$ATC/$1_ecs.log 2>&1
-       docker logs $CONTROL_PANEL_APP_NAME > $TESTLOGS/$ATC/$1_control-panel.log 2>&1
-       docker logs $MR_APP_NAME > $TESTLOGS/$ATC/$1_mr.log 2>&1
-       docker logs $CR_APP_NAME > $TESTLOGS/$ATC/$1_cr.log 2>&1
+
+       __check_included_image 'CONSUL'
+       if [ $? -eq 0 ]; then
+               docker logs $CONSUL_APP_NAME > $TESTLOGS/$ATC/$1_consul.log 2>&1
+       fi
+
+       __check_included_image 'CBS'
+       if [ $? -eq 0 ]; then
+               docker logs $CBS_APP_NAME > $TESTLOGS/$ATC/$1_cbs.log 2>&1
+               body="$(__do_curl $LOCALHOST$CBS_EXTERNAL_PORT/service_component_all/$POLICY_AGENT_APP_NAME)"
+               echo "$body" > $TESTLOGS/$ATC/$1_consul_config.json 2>&1
+       fi
+
+       __check_included_image 'PA'
+       if [ $? -eq 0 ]; then
+               docker logs $POLICY_AGENT_APP_NAME > $TESTLOGS/$ATC/$1_policy-agent.log 2>&1
+       fi
+
+       __check_included_image 'ECS'
+       if [ $? -eq 0 ]; then
+               docker logs $ECS_APP_NAME > $TESTLOGS/$ATC/$1_ecs.log 2>&1
+       fi
+
+       __check_included_image 'CP'
+       if [ $? -eq 0 ]; then
+               docker logs $CONTROL_PANEL_APP_NAME > $TESTLOGS/$ATC/$1_control-panel.log 2>&1
+       fi
+
+       __check_included_image 'MR'
+       if [ $? -eq 0 ]; then
+               docker logs $MR_APP_NAME > $TESTLOGS/$ATC/$1_mr.log 2>&1
+       fi
+
+       __check_included_image 'CR'
+       if [ $? -eq 0 ]; then
+               docker logs $CR_APP_NAME > $TESTLOGS/$ATC/$1_cr.log 2>&1
+       fi
+
        cp .httplog_${ATC}.txt $TESTLOGS/$ATC/$1_httplog_${ATC}.txt 2>&1
 
-       docker exec $SDNC_APP_NAME cat $SDNC_KARAF_LOG> $TESTLOGS/$ATC/$1_SDNC_karaf.log 2>&1
+       __check_included_image 'SDNC'
+       if [ $? -eq 0 ]; then
+               docker exec -t $SDNC_APP_NAME cat $SDNC_KARAF_LOG> $TESTLOGS/$ATC/$1_SDNC_karaf.log 2>&1
+       fi
+
+       __check_included_image 'RICSIM'
+       if [ $? -eq 0 ]; then
+               rics=$(docker ps -f "name=$RIC_SIM_PREFIX" --format "{{.Names}}")
+               for ric in $rics; do
+                       docker logs $ric > $TESTLOGS/$ATC/$1_$ric.log 2>&1
+               done
+       fi
+
+       __check_included_image 'PRODSTUB'
+       if [ $? -eq 0 ]; then
+               docker logs $PROD_STUB_APP_NAME > $TESTLOGS/$ATC/$1_prodstub.log 2>&1
+       fi
 
-       rics=$(docker ps -f "name=$RIC_SIM_PREFIX" --format "{{.Names}}")
-       for ric in $rics; do
-               docker logs $ric > $TESTLOGS/$ATC/$1_$ric.log 2>&1
-       done
-       body="$(__do_curl $LOCALHOST$CBS_EXTERNAL_PORT/service_component_all/$POLICY_AGENT_APP_NAME)"
-       echo "$body" > $TESTLOGS/$ATC/$1_consul_config.json 2>&1
        echo ""
 }
 
 ###############
 ## Generic curl
 ###############
-# Generic curl function, assumed all 200-codes are ok
-# args: <url>
+# Generic curl function, assumes all 200-codes are ok
+# args: <valid-curl-args-including full url>
 # returns: <returned response (without respose code)>  or "<no-response-from-server>" or "<not found, <http-code>>""
 # returns: The return code is 0 for ok and 1 for not ok
 __do_curl() {
        echo ${FUNCNAME[1]} "line: "${BASH_LINENO[1]} >> $HTTPLOG
-       curlString="curl -skw %{http_code} $1"
+       curlString="curl -skw %{http_code} $@"
        echo " CMD: $curlString" >> $HTTPLOG
        res=$($curlString)
        echo " RESP: $res" >> $HTTPLOG
        http_code="${res:${#res}-3}"
        if [ ${#res} -eq 3 ]; then
-               echo "<no-response-from-server>"
-               return 1
+               if [ $http_code -lt 200 ] || [ $http_code -gt 299 ]; then
+                       echo "<no-response-from-server>"
+                       return 1
+               else
+                       return 0
+               fi
        else
                if [ $http_code -lt 200 ] || [ $http_code -gt 299 ]; then
                        echo "<not found, resp:${http_code}>"
@@ -1965,8 +2373,9 @@ __var_test() {
                        checkjsonarraycount=1
                fi
 
-               echo -e $BOLD"TEST(${BASH_LINENO[1]}): ${1}, ${3} ${4} ${5} within ${6} seconds"$EBOLD
+               echo -e $BOLD"TEST $TEST_SEQUENCE_NR (${BASH_LINENO[1]}): ${1}, ${3} ${4} ${5} within ${6} seconds"$EBOLD
                ((RES_TEST++))
+               ((TEST_SEQUENCE_NR++))
                start=$SECONDS
                ctr=0
                for (( ; ; )); do
@@ -1978,8 +2387,8 @@ __var_test() {
                                path=${3:5}
                                result="$(__do_curl $2$path)"
                                retcode=$?
-                               echo "$result" > .tmp.curl.json
-                               result=$(python3 ../common/count_json_elements.py ".tmp.curl.json")
+                               echo "$result" > ./tmp/.tmp.curl.json
+                               result=$(python3 ../common/count_json_elements.py "./tmp/.tmp.curl.json")
                        fi
                        duration=$((SECONDS-start))
                        echo -ne " Result=${result} after ${duration} seconds${SAMELINE}"
@@ -2026,8 +2435,9 @@ __var_test() {
                        checkjsonarraycount=1
                fi
 
-               echo -e $BOLD"TEST(${BASH_LINENO[1]}): ${1}, ${3} ${4} ${5}"$EBOLD
+               echo -e $BOLD"TEST $TEST_SEQUENCE_NR (${BASH_LINENO[1]}): ${1}, ${3} ${4} ${5}"$EBOLD
                ((RES_TEST++))
+               ((TEST_SEQUENCE_NR++))
                if [ $checkjsonarraycount -eq 0 ]; then
                        result="$(__do_curl $2$3)"
                        retcode=$?
@@ -2036,8 +2446,8 @@ __var_test() {
                        path=${3:5}
                        result="$(__do_curl $2$path)"
                        retcode=$?
-                       echo "$result" > .tmp.curl.json
-                       result=$(python3 ../common/count_json_elements.py ".tmp.curl.json")
+                       echo "$result" > ./tmp/.tmp.curl.json
+                       result=$(python3 ../common/count_json_elements.py "./tmp/.tmp.curl.json")
                fi
                if [ $retcode -ne 0 ]; then
                        ((RES_FAIL++))
@@ -2070,22 +2480,6 @@ __var_test() {
 
 ### Generic test cases for varaible checking
 
-# Tests if a variable value in the CR is equal to a target value and and optional timeout.
-# Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
-# equal to the target or not.
-# Arg: <variable-name> <target-value> <timeout-in-sec>  - This test waits up to the timeout seconds
-# before setting pass or fail depending on if the variable value becomes equal to the target
-# value or not.
-# (Function for test scripts)
-cr_equal() {
-       if [ $# -eq 2 ] || [ $# -eq 3 ]; then
-               __var_test "CR" "$LOCALHOST$CR_EXTERNAL_PORT/counter/" $1 "=" $2 $3
-       else
-               ((RES_CONF_FAIL++))
-               __print_err "Wrong args to cr_equal, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
-       fi
-}
-
 # Tests if a variable value in the MR stub is equal to a target value and and optional timeout.
 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
 # equal to the target or not.