+#Variables for counting tests as well as passed and failed tests
+RES_TEST=0
+RES_PASS=0
+RES_FAIL=0
+RES_CONF_FAIL=0
+RES_DEVIATION=0
+
+#Var to control if current stats shall be printed
+PRINT_CURRENT_STATS=0
+
+#Var to control if container/pod runtim statistics shall be collected
+COLLECT_RUNTIME_STATS=0
+COLLECT_RUNTIME_STATS_PID=0
+
+#Var to control if endpoint statistics shall be collected
+COLLECT_ENDPOINT_STATS=0
+
+#Var to control if namespaces shall be delete before test setup
+DELETE_KUBE_NAMESPACES=0
+
+#Var to control if containers shall be delete before test setup
+DELETE_CONTAINERS=0
+
+#File to keep deviation messages
+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++))
+ __print_current_stats
+ fi
+}
+trap trap_fnc ERR
+
+# Trap to kill subprocess for stats collection (if running)
+trap_fnc2() {
+ if [ $COLLECT_RUNTIME_STATS_PID -ne 0 ]; then
+ kill $COLLECT_RUNTIME_STATS_PID
+ fi
+}
+trap trap_fnc2 EXIT
+
+# Counter for tests
+TEST_SEQUENCE_NR=1
+
+# Function to log the start of a test case
+__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++))
+}
+
+# Function to print current statistics
+__print_current_stats() {
+ if [ $PRINT_CURRENT_STATS -ne 0 ]; then
+ echo " Current stats - exe-time, tests, passes, fails, conf fails, deviations: $(($SECONDS-$TCTEST_START)), $RES_TEST, $RES_PASS, $RES_FAIL, $RES_CONF_FAIL, $RES_DEVIATION"
+ fi
+}
+
+# General function to log a failed test case
+__log_test_fail_general() {
+ echo -e $RED" FAIL."$1 $ERED
+ ((RES_FAIL++))
+ __print_current_stats
+ __check_stop_at_error
+}
+
+# Function to log a test case failed due to incorrect response code
+__log_test_fail_status_code() {
+ echo -e $RED" FAIL. Exepected status "$1", got "$2 $3 $ERED
+ ((RES_FAIL++))
+ __print_current_stats
+ __check_stop_at_error
+}
+
+# Function to log a test case failed due to incorrect response body
+__log_test_fail_body() {
+ echo -e $RED" FAIL, returned body not correct"$ERED
+ ((RES_FAIL++))
+ __print_current_stats
+ __check_stop_at_error
+}
+
+# Function to log a test case that is not supported
+__log_test_fail_not_supported() {
+ echo -e $RED" FAIL, function not supported"$ERED
+ ((RES_FAIL++))
+ __print_current_stats
+ __check_stop_at_error
+}
+
+# General function to log a passed test case
+__log_test_pass() {
+ if [ $# -gt 0 ]; then
+ echo $@
+ fi
+ ((RES_PASS++))
+ echo -e $GREEN" PASS"$EGREEN
+ __print_current_stats
+}
+
+#Counter for configurations
+CONF_SEQUENCE_NR=1
+
+# Function to log the start of a configuration setup
+__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++))
+}
+
+# Function to log a failed configuration setup
+__log_conf_fail_general() {
+ echo -e $RED" FAIL."$1 $ERED
+ ((RES_CONF_FAIL++))
+ __print_current_stats
+ __check_stop_at_error
+}
+
+# Function to log a failed configuration setup due to incorrect response code
+__log_conf_fail_status_code() {
+ echo -e $RED" FAIL. Exepected status "$1", got "$2 $3 $ERED
+ ((RES_CONF_FAIL++))
+ __print_current_stats
+ __check_stop_at_error
+}
+
+# Function to log a failed configuration setup due to incorrect response body
+__log_conf_fail_body() {
+ echo -e $RED" FAIL, returned body not correct"$ERED
+ ((RES_CONF_FAIL++))
+ __print_current_stats
+ __check_stop_at_error
+}
+
+# Function to log a configuration that is not supported
+__log_conf_fail_not_supported() {
+ echo -e $RED" FAIL, function not supported"$ERED$@
+ ((RES_CONF_FAIL++))
+ __print_current_stats
+ __check_stop_at_error
+}
+
+# Function to log a passed configuration setup
+__log_conf_ok() {
+ if [ $# -gt 0 ]; then
+ echo $@
+ fi
+ echo -e $GREEN" OK"$EGREEN
+ __print_current_stats
+}
+
+# Function to collect stats on endpoints
+# args: <app-id> <end-point-no> <http-operation> <end-point-url> <http-status> [<count>]
+__collect_endpoint_stats() {
+ if [ $COLLECT_ENDPOINT_STATS -eq 0 ]; then
+ return
+ fi
+ ENDPOINT_COUNT=1
+ if [ $# -gt 5 ]; then
+ ENDPOINT_COUNT=$6
+ fi
+ ENDPOINT_STAT_FILE=$TESTLOGS/$ATC/endpoint_$ATC_$1_$2".log"
+ ENDPOINT_POS=0
+ ENDPOINT_NEG=0
+ if [ -f $ENDPOINT_STAT_FILE ]; then
+ ENDPOINT_VAL=$(< $ENDPOINT_STAT_FILE)
+ ENDPOINT_POS=$(echo $ENDPOINT_VAL | cut -f4 -d ' ' | cut -f1 -d '/')
+ ENDPOINT_NEG=$(echo $ENDPOINT_VAL | cut -f5 -d ' ' | cut -f1 -d '/')
+ fi
+
+ if [ $5 -ge 200 ] && [ $5 -lt 300 ]; then
+ let ENDPOINT_POS=ENDPOINT_POS+$ENDPOINT_COUNT
+ else
+ let ENDPOINT_NEG=ENDPOINT_NEG+$ENDPOINT_COUNT
+ fi
+
+ printf '%-2s %-10s %-45s %-16s %-16s' "#" "$3" "$4" "$ENDPOINT_POS/$ENDPOINT_POS" "$ENDPOINT_NEG/$ENDPOINT_NEG" > $ENDPOINT_STAT_FILE
+}
+
+# Function to collect stats on endpoints
+# args: <app-id> <image-info>
+__collect_endpoint_stats_image_info() {
+ if [ $COLLECT_ENDPOINT_STATS -eq 0 ]; then
+ return
+ fi
+ ENDPOINT_STAT_FILE=$TESTLOGS/$ATC/imageinfo_$ATC_$1".log"
+ echo $POLICY_AGENT_IMAGE > $ENDPOINT_STAT_FILE
+}
+
+#Var for measuring execution time
+TCTEST_START=$SECONDS
+
+#Vars to hold the start time and timer text for a custom timer
+TC_TIMER_STARTTIME=""
+TC_TIMER_TIMER_TEXT=""
+TC_TIMER_CURRENT_FAILS="" # Then numer of failed test when timer starts.
+ # Compared with the current number of fails at timer stop
+ # to judge the measurement reliability
+
+#File to save timer measurement results
+TIMER_MEASUREMENTS=".timer_measurement.txt"
+echo -e "Activity \t Duration \t Info" > $TIMER_MEASUREMENTS
+
+# If this is set, some images (controlled by the parameter repo-policy) will be re-tagged and pushed to this repo before any
+IMAGE_REPO_ADR=""
+IMAGE_REPO_POLICY="local"
+CLUSTER_TIME_OUT=0
+
+echo "-------------------------------------------------------------------------------------------------"
+echo "----------------------------------- Test case: "$ATC
+echo "----------------------------------- Started: "$(date)
+echo "-------------------------------------------------------------------------------------------------"
+echo "-- Description: "$TC_ONELINE_DESCR
+echo "-------------------------------------------------------------------------------------------------"
+echo "----------------------------------- Test case setup -----------------------------------"
+
+echo "Setting AUTOTEST_HOME="$AUTOTEST_HOME
+START_ARG=$1
+paramerror=0
+paramerror_str=""
+if [ $# -lt 1 ]; then
+ paramerror=1
+fi
+if [ $paramerror -eq 0 ]; then
+ if [ "$1" != "remote" ] && [ "$1" != "remote-remove" ]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="First arg shall be 'remote' or 'remote-remove'"
+ fi
+ else
+ shift;
+ fi
+fi
+if [ $paramerror -eq 0 ]; then
+ if [ "$1" != "docker" ] && [ "$1" != "kube" ]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="Second arg shall be 'docker' or 'kube'"
+ fi
+ else
+ if [ $1 == "docker" ]; then
+ RUNMODE="DOCKER"
+ echo "Setting RUNMODE=DOCKER"
+ fi
+ if [ $1 == "kube" ]; then
+ RUNMODE="KUBE"
+ echo "Setting RUNMODE=KUBE"
+ fi
+ shift;
+ fi
+fi
+foundparm=0
+while [ $paramerror -eq 0 ] && [ $foundparm -eq 0 ]; do
+ foundparm=1
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "release" ]; then
+ IMAGE_CATEGORY="RELEASE"
+ echo "Option set - Release image tags used for applicable images "
+ shift;
+ foundparm=0
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "auto-clean" ]; then
+ AUTO_CLEAN="auto"
+ echo "Option set - Auto clean at end of test script"
+ shift;
+ foundparm=0
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--stop-at-error" ]; then
+ STOP_AT_ERROR=1
+ echo "Option set - Stop at first error"
+ shift;
+ foundparm=0
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--ricsim-prefix" ]; then
+ shift;
+ TMP_RIC_SIM_PREFIX=$1 #RIC_SIM_PREFIX need to be updated after sourcing of the env file
+ if [ -z "$1" ]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="No prefix found for flag: '--ricsim-prefix'"
+ fi
+ else
+ echo "Option set - Overriding RIC_SIM_PREFIX with: "$1
+ shift;
+ foundparm=0
+ fi
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--env-file" ]; then
+ shift;
+ TEST_ENV_VAR_FILE=$1
+ if [ -z "$1" ]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="No env file found for flag: '--env-file'"
+ fi
+ else
+ echo "Option set - Reading test env from: "$1
+ shift;
+ foundparm=0
+ fi
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--use-local-image" ]; then
+ USE_LOCAL_IMAGES=""
+ shift
+ while [ $# -gt 0 ] && [[ "$1" != "--"* ]]; do
+ USE_LOCAL_IMAGES=$USE_LOCAL_IMAGES" "$1
+ if [[ "$AVAILABLE_IMAGES_OVERRIDE" != *"$1"* ]]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="App name $1 is not available for local override for flag: '--use-local-image'"
+ fi
+ fi
+ shift;
+ done
+ foundparm=0
+ if [ -z "$USE_LOCAL_IMAGES" ]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="No app name found for flag: '--use-local-image'"
+ fi
+ else
+ echo "Option set - Overriding with local images for app(s):"$USE_LOCAL_IMAGES
+ fi
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--use-snapshot-image" ]; then
+ USE_SNAPSHOT_IMAGES=""
+ shift
+ while [ $# -gt 0 ] && [[ "$1" != "--"* ]]; do
+ USE_SNAPSHOT_IMAGES=$USE_SNAPSHOT_IMAGES" "$1
+ if [[ "$AVAILABLE_IMAGES_OVERRIDE" != *"$1"* ]]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="App name $1 is not available for snapshot override for flag: '--use-snapshot-image'"
+ fi
+ fi
+ shift;
+ done
+ foundparm=0
+ if [ -z "$USE_SNAPSHOT_IMAGES" ]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="No app name found for flag: '--use-snapshot-image'"
+ fi
+ else
+ echo "Option set - Overriding with snapshot images for app(s):"$USE_SNAPSHOT_IMAGES
+ fi
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--use-staging-image" ]; then
+ USE_STAGING_IMAGES=""
+ shift
+ while [ $# -gt 0 ] && [[ "$1" != "--"* ]]; do
+ USE_STAGING_IMAGES=$USE_STAGING_IMAGES" "$1
+ if [[ "$AVAILABLE_IMAGES_OVERRIDE" != *"$1"* ]]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="App name $1 is not available for staging override for flag: '--use-staging-image'"
+ fi
+ fi
+ shift;
+ done
+ foundparm=0
+ if [ -z "$USE_STAGING_IMAGES" ]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="No app name found for flag: '--use-staging-image'"
+ fi
+ else
+ echo "Option set - Overriding with staging images for app(s):"$USE_STAGING_IMAGES
+ fi
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--use-release-image" ]; then
+ USE_RELEASE_IMAGES=""
+ shift
+ while [ $# -gt 0 ] && [[ "$1" != "--"* ]]; do
+ USE_RELEASE_IMAGES=$USE_RELEASE_IMAGES" "$1
+ if [[ "$AVAILABLE_IMAGES_OVERRIDE" != *"$1"* ]]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="App name $1 is not available for release override for flag: '--use-release-image'"
+ fi
+ fi
+ shift;
+ done
+ foundparm=0
+ if [ -z "$USE_RELEASE_IMAGES" ]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="No app name found for flag: '--use-release-image'"
+ fi
+ else
+ echo "Option set - Overriding with release images for app(s):"$USE_RELEASE_IMAGES
+ fi
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--image-repo" ]; then
+ shift;
+ IMAGE_REPO_ADR=$1
+ if [ -z "$1" ]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="No image repo url found for : '--image-repo'"
+ fi
+ else
+ echo "Option set - Image repo url: "$1
+ shift;
+ foundparm=0
+ fi
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--repo-policy" ]; then
+ shift;
+ IMAGE_REPO_POLICY=$1
+ if [ -z "$1" ]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="No policy found for : '--repo-policy'"
+ fi
+ else
+ if [ "$1" == "local" ] || [ "$1" == "remote" ]; then
+ echo "Option set - Image repo policy: "$1
+ shift;
+ foundparm=0
+ else
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="Repo policy shall be 'local' or 'remote'"
+ fi
+ fi
+ fi
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--cluster-timeout" ]; then
+ shift;
+ CLUSTER_TIME_OUT=$1
+ if [ -z "$1" ]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="No timeout value found for : '--cluster-timeout'"
+ fi
+ else
+ #Check if positive int
+ case ${CLUSTER_TIME_OUT#[+]} in
+ *[!0-9]* | '')
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="Value for '--cluster-timeout' not an int : "$CLUSTER_TIME_OUT
+ fi
+ ;;
+ * ) ;; # Ok
+ esac
+ echo "Option set - Cluster timeout: "$1
+ shift;
+ foundparm=0
+ fi
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--override" ]; then
+ shift;
+ TEST_ENV_VAR_FILE_OVERRIDE=$1
+ if [ -z "$1" ]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="No env file found for flag: '--override'"
+ fi
+ else
+ if [ ! -f $TEST_ENV_VAR_FILE_OVERRIDE ]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="File for '--override' does not exist : "$TEST_ENV_VAR_FILE_OVERRIDE
+ fi
+ fi
+ echo "Option set - Override env from: "$1
+ shift;
+ foundparm=0
+ fi
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--pre-clean" ]; then
+ PRE_CLEAN=1
+ echo "Option set - Pre-clean of kube/docker resouces"
+ shift;
+ foundparm=0
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--print-stats" ]; then
+ PRINT_CURRENT_STATS=1
+ echo "Option set - Print stats after every test-case and config"
+ shift;
+ foundparm=0
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--gen-stats" ]; then
+ COLLECT_RUNTIME_STATS=1
+ echo "Option set - Collect runtime statistics"
+ shift;
+ foundparm=0
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--delete-namespaces" ]; then
+ if [ $RUNMODE == "DOCKER" ]; then
+ DELETE_KUBE_NAMESPACES=0
+ echo "Option ignored - Delete namespaces (ignored when running docker)"
+ else
+ if [ -z "KUBE_PRESTARTED_IMAGES" ]; then
+ DELETE_KUBE_NAMESPACES=0
+ echo "Option ignored - Delete namespaces (ignored when using prestarted apps)"
+ else
+ DELETE_KUBE_NAMESPACES=1
+ echo "Option set - Delete namespaces"
+ fi
+ fi
+ shift;
+ foundparm=0
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--delete-containers" ]; then
+ if [ $RUNMODE == "DOCKER" ]; then
+ DELETE_CONTAINERS=1
+ echo "Option set - Delete containers started by previous test(s)"
+ else
+ echo "Option ignored - Delete containers (ignored when running kube)"
+ fi
+ shift;
+ foundparm=0
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--endpoint-stats" ]; then
+ COLLECT_ENDPOINT_STATS=1
+ echo "Option set - Collect endpoint statistics"
+ shift;
+ foundparm=0
+ fi
+ fi
+
+done
+echo ""
+
+#Still params left?
+if [ $paramerror -eq 0 ] && [ $# -gt 0 ]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="Unknown parameter(s): "$@
+ fi
+fi
+
+if [ $paramerror -eq 1 ]; then
+ echo -e $RED"Incorrect arg list: "$paramerror_str$ERED
+ __print_args
+ exit 1
+fi
+
+# sourcing the selected env variables for the test case
+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_VAR_FILE_OVERRIDE" ]; then
+ echo -e $BOLD"Sourcing override env vars from: "$TEST_ENV_VAR_FILE_OVERRIDE$EBOLD
+ . $TEST_ENV_VAR_FILE_OVERRIDE
+ fi
+
+ if [ -z "$TEST_ENV_PROFILE" ] || [ -z "$SUPPORTED_PROFILES" ]; then
+ echo -e $YELLOW"This test case may not 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
+ 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
+ if [ $? -ne 0 ]; then
+ echo " Include file $file_pointer contain errors. Exiting..."
+ exit 1
+ fi
+ __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"
+ if [ ! -f "$file_pointer" ]; then
+ echo " Include file $file_pointer for app $iapp does not exist"
+ exit 1
+ fi
+ . $file_pointer
+ if [ $? -ne 0 ]; then
+ echo " Include file $file_pointer contain errors. Exiting..."
+ 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