__print_args() {
echo "Args: remote|remote-remove docker|kube --env-file <environment-filename> [release] [auto-clean] [--stop-at-error] "
echo " [--ricsim-prefix <prefix> ] [--use-local-image <app-nam>+] [--use-snapshot-image <app-nam>+]"
- echo " [--use-staging-image <app-nam>+] [--use-release-image <app-nam>+] [--image-repo <repo-address>]"
+ echo " [--use-staging-image <app-nam>+] [--use-release-image <app-nam>+] [--use-external-image <app-nam>+] [--image-repo <repo-address>]"
echo " [--repo-policy local|remote] [--cluster-timeout <timeout-in seconds>] [--print-stats]"
echo " [--override <override-environment-filename>] [--pre-clean] [--gen-stats] [--delete-namespaces]"
echo " [--delete-containers] [--endpoint-stats] [--kubeconfig <config-file>] [--host-path-dir <local-host-dir>]"
echo "--use-snapshot-image - The script will use images from the nexus snapshot repo for the supplied apps, space separated list of app short names"
echo "--use-staging-image - The script will use images from the nexus staging repo for the supplied apps, space separated list of app short names"
echo "--use-release-image - The script will use images from the nexus release repo for the supplied apps, space separated list of app short names"
+ echo "--use-external-image - The script will use images from the external (non oran/onap) repo for the supplied apps, space separated list of app short names"
echo "--image-repo - Url to optional image repo. Only locally built images will be re-tagged and pushed to this repo"
echo "--repo-policy - Policy controlling which images to re-tag and push if param --image-repo is set. Default is 'local'"
echo "--cluster-timeout - Optional timeout for cluster where it takes time to obtain external ip/host-name. Timeout in seconds. "
# Var to hold the app names to use remote release images for
USE_RELEASE_IMAGES=""
+# Var to hold the app names to use external release images for
+USE_EXTERNAL_IMAGES=""
# 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
#Var to indicate docker-compose version, V1 or V2
#V1 names replicated containers <proj-name>_<service-name>_<index>
#V2 names replicated containers <proj-name>-<service-name>-<index>
-DOCKER_COMPOSE_VERION="V1"
+DOCKER_COMPOSE_VERSION="V1"
# Function to indent cmd output with one space
indent1() { sed 's/^/ /'; }
TCLOG=$TESTLOGS/$ATC/TC.log
exec &> >(tee ${TCLOG})
+echo $(date) > $TESTLOGS/$ATC/endpoint_tc_start.log
+echo "Test failed" > $TESTLOGS/$ATC/endpoint_tc_end.log # Will be overritten if test is ok
+
#Variables for counting tests as well as passed and failed tests
RES_TEST=0
RES_PASS=0
fi
fi
fi
+ if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--use-external-image" ]; then
+ USE_EXTERNAL_IMAGES=""
+ shift
+ while [ $# -gt 0 ] && [[ "$1" != "--"* ]]; do
+ USE_EXTERNAL_IMAGES=$USE_EXTERNAL_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-external-image'"
+ fi
+ fi
+ shift;
+ done
+ foundparm=0
+ if [ -z "$USE_EXTERNAL_IMAGES" ]; then
+ paramerror=1
+ if [ -z "$paramerror_str" ]; then
+ paramerror_str="No app name found for flag: '--use-use-external-image'"
+ fi
+ else
+ echo "Option set - Overriding with external images for app(s):"$USE_EXTERNAL_IMAGES
+ fi
+ fi
+ fi
if [ $paramerror -eq 0 ]; then
if [ "$1" == "--image-repo" ]; then
shift;
echo -e $RED"docker-compose is required to run the test environment, pls install"$ERED
exit 1
else
- tmp=$(docker-compose version --short)
+ tmp=$(docker-compose version)
echo " docker-compose installed and using version $tmp"
if [[ "$tmp" == *'v2'* ]]; then
- DOCKER_COMPOSE_VERION="V2"
+ DOCKER_COMPOSE_VERSION="V2"
fi
fi
fi
if [ "$5" == "REMOTE_RELEASE_ORAN" ]; then
image=$NEXUS_RELEASE_REPO_ORAN$image
fi
- #No nexus repo added for local images, tag: LOCAL
+ #No nexus repo added for local images, tag: LOCAL and other tags
tmp=$tmp$image"\t"
fi
if [ -z $tag ]; then
((CTR++))
fi
done
+ for im in $USE_EXTERNAL_IMAGES; do
+ if [ "$1" == "$im" ]; then
+ suffix="EXTERNAL"
+ ((CTR++))
+ fi
+ done
echo $suffix
if [ $CTR -gt 1 ]; then
exit 1
echo "Runtime statistics collected in file: "$TESTLOGS/$ATC/stat_data.csv
echo ""
fi
-
+ TMP_FLAG_FAIL_PASS=0
total=$((RES_PASS+RES_FAIL))
if [ $RES_TEST -eq 0 ]; then
+ TMP_FLAG_FAIL_PASS=1
echo -e "\033[1mNo tests seem to have been executed. Check the script....\033[0m"
echo -e "\033[31m\033[1m ___ ___ ___ ___ ___ _____ ___ _ ___ _ _ _ ___ ___ \033[0m"
echo -e "\033[31m\033[1m/ __|/ __| _ \_ _| _ \_ _| | __/_\ |_ _| | | | | | _ \ __|\033[0m"
echo -e "\033[31m\033[1m\__ \ (__| /| || _/ | | | _/ _ \ | || |_| |_| | / _| \033[0m"
echo -e "\033[31m\033[1m|___/\___|_|_\___|_| |_| |_/_/ \_\___|____\___/|_|_\___|\033[0m"
elif [ $total != $RES_TEST ]; then
+ TMP_FLAG_FAIL_PASS=1
echo -e "\033[1mTotal number of tests does not match the sum of passed and failed tests. Check the script....\033[0m"
echo -e "\033[31m\033[1m ___ ___ ___ ___ ___ _____ ___ _ ___ _ _ _ ___ ___ \033[0m"
echo -e "\033[31m\033[1m/ __|/ __| _ \_ _| _ \_ _| | __/_\ |_ _| | | | | | _ \ __|\033[0m"
echo -e "\033[31m\033[1m\__ \ (__| /| || _/ | | | _/ _ \ | || |_| |_| | / _| \033[0m"
echo -e "\033[31m\033[1m|___/\___|_|_\___|_| |_| |_/_/ \_\___|____\___/|_|_\___|\033[0m"
elif [ $RES_CONF_FAIL -ne 0 ]; then
+ TMP_FLAG_FAIL_PASS=1
echo -e "\033[1mOne or more configurations has failed. Check the script log....\033[0m"
echo -e "\033[31m\033[1m ___ ___ ___ ___ ___ _____ ___ _ ___ _ _ _ ___ ___ \033[0m"
echo -e "\033[31m\033[1m/ __|/ __| _ \_ _| _ \_ _| | __/_\ |_ _| | | | | | _ \ __|\033[0m"
echo -e "\033[31m\033[1m\__ \ (__| /| || _/ | | | _/ _ \ | || |_| |_| | / _| \033[0m"
echo -e "\033[31m\033[1m|___/\___|_|_\___|_| |_| |_/_/ \_\___|____\___/|_|_\___|\033[0m"
elif [ $RES_PASS = $RES_TEST ]; then
+ TMP_FLAG_FAIL_PASS=0
echo -e "All tests \033[32m\033[1mPASS\033[0m"
echo -e "\033[32m\033[1m ___ _ ___ ___ \033[0m"
echo -e "\033[32m\033[1m | _ \/_\ / __/ __| \033[0m"
#Create file with OK exit code
echo "0" > "$AUTOTEST_HOME/.result$ATC.txt"
echo "0" > "$TESTLOGS/$ATC/.result$ATC.txt"
+ echo $(date) > $TESTLOGS/$ATC/endpoint_tc_end.log
else
+ TMP_FLAG_FAIL_PASS=1
echo -e "One or more tests with status \033[31m\033[1mFAIL\033[0m "
echo -e "\033[31m\033[1m ___ _ ___ _ \033[0m"
echo -e "\033[31m\033[1m | __/_\ |_ _| | \033[0m"
echo -e "\033[31m\033[1m | _/ _ \ | || |__ \033[0m"
echo -e "\033[31m\033[1m |_/_/ \_\___|____|\033[0m"
echo ""
+ fi
+
+ if [ $TMP_FLAG_FAIL_PASS -ne 0 ]; then
# Update test suite counter
if [ -f .tmp_tcsuite_fail_ctr ]; then
tmpval=$(< .tmp_tcsuite_fail_ctr)
ns_flag=""
ns_text=""
fi
- result=$(kubectl $KUBECONF get $restype $ns_flag -o jsonpath='{.items[?(@.metadata.labels.'$labelname'=="'$labelid'")].metadata.name}')
+ result=$(kubectl $KUBECONF get $restype $ns_flag -o jsonpath='{.items[?(@.metadata.labels.'$labelname'=="'$labelid'")].metadata.name}' 2> /dev/null)
if [ $? -eq 0 ] && [ ! -z "$result" ]; then
deleted_resourcetypes=$deleted_resourcetypes" "$restype
for resid in $result; do
fi
done
+ # Remove istio label on namespaces
+ test_env_namespaces=$(kubectl $KUBECONF get ns --no-headers -o custom-columns=":metadata.name" -l autotest=engine -l istio-injection=enabled) #Get list of ns created by the test env
+ if [ $? -ne 0 ]; then
+ echo " Cannot get list of namespaces...continues.."
+ else
+ for test_env_ns in $test_env_namespaces; do
+ echo " Removing istio label on ns: "$test_env_ns
+ __kube_label_non_ns_instance ns $test_env_ns "istio-injection-"
+ done
+ fi
+
echo ""
}
envsubst < $compose_file > "gen_"$compose_file
compose_file="gen_"$compose_file
- if [ $DOCKER_COMPOSE_VERION == "V1" ]; then
+ if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then
docker_compose_cmd="docker-compose"
else
docker_compose_cmd="docker compose"