+ found_profile=0
+ for prof in $SUPPORTED_PROFILES; do
+ if [ "$TEST_ENV_PROFILE" == "$prof" ]; then
+ echo -e $GREEN"Test case supports the selected test env file"$EGREEN
+ found_profile=1
+ fi
+ done
+ if [ $found_profile -ne 1 ]; then
+ echo -e $RED"Test case does not support the selected test env file"$ERED
+ echo "Profile: "$TEST_ENV_PROFILE" Supported profiles: "$SUPPORTED_PROFILES
+ 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 $AUTOTEST_HOME/../common/test_env* | indent1
+ exit 1
+fi
+
+#This var need be preserved from the command line option, if set, when env var is sourced.
+if [ ! -z "$TMP_RIC_SIM_PREFIX" ]; then
+ RIC_SIM_PREFIX=$TMP_RIC_SIM_PREFIX
+fi
+
+if [ -z "$PROJECT_IMAGES_APP_NAMES" ]; then
+ echo -e $RED"Var PROJECT_IMAGES_APP_NAMES must be defined in: "$TEST_ENV_VAR_FILE $ERED
+ exit 1
+fi
+
+if [[ $SUPPORTED_RUNMODES != *"$RUNMODE"* ]]; then
+ echo -e $RED"This test script does not support RUNMODE $RUNMODE"$ERED
+ echo "Supported RUNMODEs: "$SUPPORTED_RUNMODES
+ exit 1
+fi
+
+# Choose list of included apps depending on run-mode
+if [ $RUNMODE == "KUBE" ]; then
+ INCLUDED_IMAGES=$KUBE_INCLUDED_IMAGES
+else
+ INCLUDED_IMAGES=$DOCKER_INCLUDED_IMAGES
+fi
+
+echo ""
+# auto adding system apps
+__added_apps=""
+echo -e $BOLD"Auto adding system apps"$EBOLD
+if [ $RUNMODE == "KUBE" ]; then
+ INCLUDED_IMAGES=$INCLUDED_IMAGES" "$TESTENV_KUBE_SYSTEM_APPS
+ TMP_APPS=$TESTENV_KUBE_SYSTEM_APPS
+else
+ INCLUDED_IMAGES=$INCLUDED_IMAGES" "$TESTENV_DOCKER_SYSTEM_APPS
+ TMP_APPS=$TESTENV_DOCKER_SYSTEM_APPS
+fi
+if [ ! -z "$TMP_APPS" ]; then
+ for iapp in "$TMP_APPS"; do
+ file_pointer=$(echo $iapp | tr '[:upper:]' '[:lower:]')
+ file_pointer="../common/"$file_pointer"_api_functions.sh"
+ padded_iapp=$iapp
+ while [ ${#padded_iapp} -lt 16 ]; do
+ padded_iapp=$padded_iapp" "
+ done
+ echo " Auto-adding system app $padded_iapp Sourcing $file_pointer"
+ . $file_pointer
+ __added_apps=" $iapp "$__added_apps
+ done
+else
+ echo " None"
+fi
+
+if [ $RUNMODE == "KUBE" ]; then
+ TMP_APPS=$INCLUDED_IMAGES" "$KUBE_PRESTARTED_IMAGES
+else
+ TMP_APPS=$INCLUDED_IMAGES
+fi
+
+echo -e $BOLD"Auto adding included apps"$EBOLD
+ for iapp in $TMP_APPS; do
+ if [[ "$__added_apps" != *"$iapp"* ]]; then
+ file_pointer=$(echo $iapp | tr '[:upper:]' '[:lower:]')
+ file_pointer="../common/"$file_pointer"_api_functions.sh"
+ padded_iapp=$iapp
+ while [ ${#padded_iapp} -lt 16 ]; do
+ padded_iapp=$padded_iapp" "
+ done
+ echo " Auto-adding included app $padded_iapp Sourcing $file_pointer"
+ . $file_pointer
+ if [ ! -f "$file_pointer" ]; then
+ echo " Include file $file_pointer for app $iapp does not exist"
+ exit 1
+ fi
+ fi
+ done
+echo ""
+
+echo -e $BOLD"Test environment info"$EBOLD
+
+# Check needed installed sw
+
+tmp=$(which bash)
+if [ $? -ne 0 ] || [ -z "$tmp" ]; then
+ echo -e $RED"bash is required to run the test environment, pls install"$ERED
+ exit 1
+fi
+echo " bash is installed and using version:"
+echo "$(bash --version)" | indent2
+
+tmp=$(which python3)
+if [ $? -ne 0 ] || [ -z "$tmp" ]; then
+ echo -e $RED"python3 is required to run the test environment, pls install"$ERED
+ exit 1
+fi
+echo " python3 is installed and using version: $(python3 --version)"
+
+tmp=$(which docker)
+if [ $? -ne 0 ] || [ -z "$tmp" ]; then
+ echo -e $RED"docker is required to run the test environment, pls install"$ERED
+ exit 1
+fi
+echo " docker is installed and using versions:"
+echo " $(docker version --format 'Client version {{.Client.Version}} Server version {{.Server.Version}}')"
+
+tmp=$(which docker-compose)
+if [ $? -ne 0 ] || [ -z "$tmp" ]; then
+ if [ $RUNMODE == "DOCKER" ]; then
+ echo -e $RED"docker-compose is required to run the test environment, pls install"$ERED
+ exit 1
+ fi
+fi
+tmp=$(docker-compose version --short)
+echo " docker-compose installed and using version $tmp"
+if [[ "$tmp" == *'v2'* ]]; then
+ DOCKER_COMPOSE_VERION="V2"
+fi
+
+tmp=$(which kubectl)
+if [ $? -ne 0 ] || [ -z tmp ]; then
+ if [ $RUNMODE == "KUBE" ]; then
+ echo -e $RED"kubectl is required to run the test environment in kubernetes mode, pls install"$ERED
+ exit 1
+ fi
+else
+ if [ $RUNMODE == "KUBE" ]; then
+ echo " kubectl is installed and using versions:"
+ echo $(kubectl version --short=true) | indent2
+ res=$(kubectl cluster-info 2>&1)
+ if [ $? -ne 0 ]; then
+ echo -e "$BOLD$RED############################################# $ERED$EBOLD"
+ echo -e $BOLD$RED"Command 'kubectl cluster-info' returned error $ERED$EBOLD"
+ echo -e "$BOLD$RED############################################# $ERED$EBOLD"
+ echo " "
+ echo "kubectl response:"
+ echo $res
+ echo " "
+ echo "This script may have been started with user with no permission to run kubectl"
+ echo "Try running with 'sudo' or set 'KUBECONFIG'"
+ echo "Do either 1, 2 or 3 "
+ echo " "
+ echo "1"
+ echo "Run with sudo"
+ echo -e $BOLD"sudo <test-script-and-parameters>"$EBOLD
+ echo " "
+ echo "2"
+ echo "Export KUBECONFIG and pass env to sudo - (replace user)"
+ echo -e $BOLD"export KUBECONFIG='/home/<user>/.kube/config'"$EBOLD
+ echo -e $BOLD"sudo -E <test-script-and-parameters>"$EBOLD
+ echo " "
+ echo "3"
+ echo "Set KUBECONFIG inline (replace user)"
+ echo -e $BOLD"sudo KUBECONFIG='/home/<user>/.kube/config' <test-script-and-parameters>"$EBOLD
+
+ exit 1
+ fi
+ fi
+fi
+
+echo ""
+
+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="./tmp/.image-list"
+echo -e "Application\tApp short name\tImage\ttag\ttag-switch" > $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)
+# arg: <app-short-name> <target-variable-name> <image-variable-name> <image-tag-variable-name> <tag-suffix> <image name>
+__check_and_create_image_var() {
+
+ if [ $# -ne 6 ]; then
+ echo "Expected arg: <app-short-name> <target-variable-name> <image-variable-name> <image-tag-variable-name> <tag-suffix> <image name>"
+ ((IMAGE_ERR++))
+ return
+ fi
+
+ __check_included_image $1
+ if [ $? -ne 0 ]; then
+ echo -e "$6\t$1\t<image-excluded>\t<no-tag>" >> $image_list_file
+ # Image is excluded since the corresponding app is not used in this test
+ return
+ fi
+ tmp=${6}"\t"${1}"\t"
+ #Create var from the input var names
+ image="${!3}"
+ tmptag=$4"_"$5
+ tag="${!tmptag}"
+
+ optional_image_repo_target=""
+
+ if [ -z $image ]; then
+ __check_ignore_image $1
+ if [ $? -eq 0 ]; then
+ app_ds=$6
+ if [ -z "$6" ]; then
+ app_ds="<app ignored>"
+ fi
+ echo -e "$app_ds\t$1\t<image-ignored>\t<no-tag>" >> $image_list_file
+ # Image is ignored since the corresponding the images is not set in the env file
+ __remove_included_image $1 # Remove the image from the list of included images
+ return
+ fi
+ echo -e $RED"\$"$3" not set in $TEST_ENV_VAR_FILE"$ERED
+ ((IMAGE_ERR++))
+ echo ""
+ tmp=$tmp"<no-image>\t"
+ else
+
+ optional_image_repo_target=$image
+
+ #Add repo depending on image type
+ if [ "$5" == "REMOTE_RELEASE" ]; then
+ image=$NEXUS_RELEASE_REPO$image
+ fi
+ if [ "$5" == "REMOTE" ]; then
+ image=$NEXUS_STAGING_REPO$image
+ fi
+ if [ "$5" == "REMOTE_SNAPSHOT" ]; then
+ image=$NEXUS_SNAPSHOT_REPO$image
+ fi
+ if [ "$5" == "REMOTE_PROXY" ]; then
+ image=$NEXUS_PROXY_REPO$image
+ fi
+ if [ "$5" == "REMOTE_RELEASE_ONAP" ]; then
+ image=$NEXUS_RELEASE_REPO_ONAP$image
+ fi
+ if [ "$5" == "REMOTE_RELEASE_ORAN" ]; then
+ image=$NEXUS_RELEASE_REPO_ORAN$image
+ fi
+ #No nexus repo added for local images, tag: LOCAL
+ tmp=$tmp$image"\t"