From 805ac7cae6f73802179b105941ebb12183de91a7 Mon Sep 17 00:00:00 2001 From: JohnKeeney Date: Thu, 27 Jul 2023 17:45:46 +0100 Subject: [PATCH] Update test env to remove '-' in ric hostnames Remove support for docker-compose v1 - which adds '-' in hostnames. Issue-ID: NONRTRIC-871 Change-Id: I0216b7ab9ff07f9aa119f7c0ea328d55e9de72eb Signed-off-by: JohnKeeney --- test/auto-test/README.md | 2 +- test/common/a1pms_api_functions.sh | 8 ++----- test/common/cr_api_functions.sh | 24 ++++--------------- test/common/ricmediatorsim_api_functions.sh | 36 +++++++---------------------- test/common/ricsim_api_functions.sh | 36 +++++++---------------------- test/common/testcase_common.sh | 15 ++++++------ test/jenkins/run_test.sh | 3 ++- 7 files changed, 32 insertions(+), 92 deletions(-) diff --git a/test/auto-test/README.md b/test/auto-test/README.md index bf43d463..2b4586d3 100644 --- a/test/auto-test/README.md +++ b/test/auto-test/README.md @@ -10,7 +10,7 @@ FTC is short for Function Test Case. In addition, there are also other test scri To list all test case files with a s short description, do `grep TC_ONELINE_DESCR *.sh` for a complete list. -The requirements, in terms of the execution environment, to run a script or a suite is to have docker, docker-compose and python3 installed (the scripts warns if not installed). As an option, the scripts can also be executed in a Minikube or Kubernetes installation. The additional requirement is to have a clean minikube/kubernetes installation, preferably with the kube dashboard installed. +The requirements, in terms of the execution environment, to run a script or a suite is to have docker, docker-compose (v2+) and python3 installed (the scripts warns if not installed). As an option, the scripts can also be executed in a Minikube or Kubernetes installation. The additional requirement is to have a clean minikube/kubernetes installation, preferably with the kube dashboard installed. The scripts have been tested to work on both MacOS and Ubuntu using docker. They should work also in git-bash on windows (for docker) but only partly verified. Running using minikube has only been verified on Ubuntu and running on kubernetes has been verified on MacOS and Ubuntu. Successful sample tests has been made on google cloud. ## Configuration diff --git a/test/common/a1pms_api_functions.sh b/test/common/a1pms_api_functions.sh index a1141343..bdf363e7 100644 --- a/test/common/a1pms_api_functions.sh +++ b/test/common/a1pms_api_functions.sh @@ -567,13 +567,9 @@ prepare_a1pms_config() { ric_id=${ric%.*.*} #extract pod id from full hosthame ric_id=$(echo "$ric_id" | tr '-' '_') else - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - ric_id=$ric - else - ric_id=$(echo "$ric" | tr '-' '_') #ric id still needs underscore as it is different from the container name - fi + ric_id=$(echo "$ric" | tr '-' '_') #ric var still needs underscore as it is different from the container name fi - echo " Found a1 sim: "$ric_id + echo " Found a1 sim: "$ric config_json=$config_json"\n \"name\": \"$ric_id\"," xricfound=0 diff --git a/test/common/cr_api_functions.sh b/test/common/cr_api_functions.sh index 00d729cb..4fad4c4e 100644 --- a/test/common/cr_api_functions.sh +++ b/test/common/cr_api_functions.sh @@ -122,11 +122,7 @@ __CR_statistics_setup() { CR_INSTANCE_KUBE=$(($CR_INSTANCE-1)) echo -n " CR-$CR_INSTANCE_KUBE $CR_APP_NAME-$CR_INSTANCE_KUBE $KUBE_SIM_NAMESPACE " else - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - echo -n " CR_$CR_INSTANCE ${CR_APP_NAME}_cr_$CR_INSTANCE " - else - echo -n " CR_$CR_INSTANCE ${CR_APP_NAME}-cr-$CR_INSTANCE " - fi + echo -n " CR_$CR_INSTANCE ${CR_APP_NAME}-cr-$CR_INSTANCE " fi done } @@ -171,11 +167,7 @@ __cr_set_protocoll() { for ((CR_INSTANCE=0; CR_INSTANCE<$MAX_CR_APP_COUNT; CR_INSTANCE++ )); do CR_DOCKER_INSTANCE=$(($CR_INSTANCE+1)) # CR_SERVICE_PATH is the base path to cr - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - __CR_SERVICE_PATH=$1"://"$CR_APP_NAME"_cr_"${CR_DOCKER_INSTANCE}":"$2 # docker access, container->container and script->container via proxy - else - __CR_SERVICE_PATH=$1"://"$CR_APP_NAME"-cr-"${CR_DOCKER_INSTANCE}":"$2 # docker access, container->container and script->container via proxy - fi + __CR_SERVICE_PATH=$1"://"$CR_APP_NAME"-cr-"${CR_DOCKER_INSTANCE}":"$2 # docker access, container->container and script->container via proxy if [ $RUNMODE == "KUBE" ]; then __CR_SERVICE_PATH=$1"://"$CR_APP_NAME"-"$CR_INSTANCE.$CR_APP_NAME"."$KUBE_SIM_NAMESPACE":"$3 # kube access, pod->svc and script->svc via proxy fi @@ -299,11 +291,7 @@ start_cr() { app_data="" cntr=1 while [ $cntr -le $CR_APP_COUNT ]; do - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - app=$CR_APP_NAME"_cr_"$cntr - else - app=$CR_APP_NAME"-cr-"$cntr - fi + app=$CR_APP_NAME"-cr-"$cntr app_data="$app_data $app" let cntr=cntr+1 done @@ -315,11 +303,7 @@ start_cr() { cntr=1 #Counter for docker instance, starts on 1 cntr2=0 #Couter for env var name, starts with 0 to be compablible with kube while [ $cntr -le $CR_APP_COUNT ]; do - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - app=$CR_APP_NAME"_cr_"$cntr - else - app=$CR_APP_NAME"-cr-"$cntr - fi + app=$CR_APP_NAME"-cr-"$cntr __dynvar="CR_SERVICE_PATH_"$cntr2 __check_service_start $app ${!__dynvar}$CR_ALIVE_URL let cntr=cntr+1 diff --git a/test/common/ricmediatorsim_api_functions.sh b/test/common/ricmediatorsim_api_functions.sh index 6449a68d..aef32cb3 100644 --- a/test/common/ricmediatorsim_api_functions.sh +++ b/test/common/ricmediatorsim_api_functions.sh @@ -116,17 +116,10 @@ __RICMEDIATORSIM_statistics_setup() { echo -n " RICMEDIATOR_SIMG3_$RICMEDIATOR_SIMINSTANCE_KUBE ${RICMEDIATOR_SIM_PREFIX}-g3-$RICMEDIATOR_SIMINSTANCE_KUBE $KUBE_A1SIM_NAMESPACE " echo -n " RICMEDIATOR_SIMG4_$RICMEDIATOR_SIMINSTANCE_KUBE ${RICMEDIATOR_SIM_PREFIX}-g4-$RICMEDIATOR_SIMINSTANCE_KUBE $KUBE_A1SIM_NAMESPACE " else - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - echo -n " RICMEDIATOR_SIMG1_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}_g1_$RICMEDIATOR_SIMINSTANCE " - echo -n " RICMEDIATOR_SIMG2_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}_g2_$RICMEDIATOR_SIMINSTANCE " - echo -n " RICMEDIATOR_SIMG3_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}_g3_$RICMEDIATOR_SIMINSTANCE " - echo -n " RICMEDIATOR_SIMG4_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}_g4_$RICMEDIATOR_SIMINSTANCE " - else - echo -n " RICMEDIATOR_SIMG1_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g1-$RICMEDIATOR_SIMINSTANCE " - echo -n " RICMEDIATOR_SIMG2_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g2-$RICMEDIATOR_SIMINSTANCE " - echo -n " RICMEDIATOR_SIMG3_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g3-$RICMEDIATOR_SIMINSTANCE " - echo -n " RICMEDIATOR_SIMG4_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g4-$RICMEDIATOR_SIMINSTANCE " - fi + echo -n " RICMEDIATOR_SIMG1_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g1-$RICMEDIATOR_SIMINSTANCE " + echo -n " RICMEDIATOR_SIMG2_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g2-$RICMEDIATOR_SIMINSTANCE " + echo -n " RICMEDIATOR_SIMG3_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g3-$RICMEDIATOR_SIMINSTANCE " + echo -n " RICMEDIATOR_SIMG4_$RICMEDIATOR_SIMINSTANCE ${RICMEDIATOR_SIM_PREFIX}-g4-$RICMEDIATOR_SIMINSTANCE " fi done } @@ -306,11 +299,7 @@ start_ricmediator_simulators() { # -- app_data="" cntr=1 - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - app_name_prefix=$RICMEDIATOR_SIM_PREFIX"_"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"_" - else - app_name_prefix=$RICMEDIATOR_SIM_PREFIX"-"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"-" - fi + app_name_prefix=$RICMEDIATOR_SIM_PREFIX"-"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"-" while [ $cntr -le $2 ]; do app=$app_name_prefix$cntr app_data="$app_data $app" @@ -321,11 +310,7 @@ start_ricmediator_simulators() { cntr=1 while [ $cntr -le $2 ]; do - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - app=$RICMEDIATOR_SIM_PREFIX"_"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"_"$cntr - else - app=$RICMEDIATOR_SIM_PREFIX"-"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"-"$cntr - fi + app=$RICMEDIATOR_SIM_PREFIX"-"$RICMEDIATOR_SIMCOMPOSE_SERVICE_NAME"-"$cntr __check_service_start $app $RICMEDIATOR_SIM_HTTPX"://"$app:$RICMEDIATOR_SIM_PORT$RICMEDIATOR_SIM_ALIVE_URL let cntr=cntr+1 done @@ -359,13 +344,8 @@ __find_ricmediatorsim_host() { fi echo $RICMEDIATOR_SIM_HTTPX"://"$ricname.$ric_setname.$KUBE_A1SIM_NAMESPACE":"$RICMEDIATOR_SIM_PORT else - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - echo $RICMEDIATOR_SIM_HTTPX"://"$1":"$RICMEDIATOR_SIM_PORT - else - ricname=$(echo "$1" | tr '_' '-') - echo $RICMEDIATOR_SIM_HTTPX"://"$ricname":"$RICMEDIATOR_SIM_PORT - fi - + ricname=$(echo "$1" | tr '_' '-') + echo $RICMEDIATOR_SIM_HTTPX"://"$ricname":"$RICMEDIATOR_SIM_PORT fi } diff --git a/test/common/ricsim_api_functions.sh b/test/common/ricsim_api_functions.sh index 1bdcf1d5..8cb24b8a 100644 --- a/test/common/ricsim_api_functions.sh +++ b/test/common/ricsim_api_functions.sh @@ -103,15 +103,9 @@ __RICSIM_statistics_setup() { echo -n " RICSIM_G2_$RICSIM_INSTANCE_KUBE ${RIC_SIM_PREFIX}-g2-$RICSIM_INSTANCE_KUBE $KUBE_A1SIM_NAMESPACE " echo -n " RICSIM_G3_$RICSIM_INSTANCE_KUBE ${RIC_SIM_PREFIX}-g3-$RICSIM_INSTANCE_KUBE $KUBE_A1SIM_NAMESPACE " else - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - echo -n " RICSIM_G1_$RICSIM_INSTANCE ${RIC_SIM_PREFIX}_g1_$RICSIM_INSTANCE " - echo -n " RICSIM_G2_$RICSIM_INSTANCE ${RIC_SIM_PREFIX}_g2_$RICSIM_INSTANCE " - echo -n " RICSIM_G3_$RICSIM_INSTANCE ${RIC_SIM_PREFIX}_g3_$RICSIM_INSTANCE " - else - echo -n " RICSIM_G1_$RICSIM_INSTANCE ${RIC_SIM_PREFIX}-g1-$RICSIM_INSTANCE " - echo -n " RICSIM_G2_$RICSIM_INSTANCE ${RIC_SIM_PREFIX}-g2-$RICSIM_INSTANCE " - echo -n " RICSIM_G3_$RICSIM_INSTANCE ${RIC_SIM_PREFIX}-g3-$RICSIM_INSTANCE " - fi + echo -n " RICSIM_G1_$RICSIM_INSTANCE ${RIC_SIM_PREFIX}-g1-$RICSIM_INSTANCE " + echo -n " RICSIM_G2_$RICSIM_INSTANCE ${RIC_SIM_PREFIX}-g2-$RICSIM_INSTANCE " + echo -n " RICSIM_G3_$RICSIM_INSTANCE ${RIC_SIM_PREFIX}-g3-$RICSIM_INSTANCE " fi done } @@ -290,16 +284,10 @@ start_ric_simulators() { docker_args="--force-recreate --scale $RICSIM_COMPOSE_SERVICE_NAME=$2" #Create a list of container names - #Will be __ - # or - # -- + #Will be -- app_data="" cntr=1 - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - app_name_prefix=$RIC_SIM_PREFIX"_"$RICSIM_COMPOSE_SERVICE_NAME"_" - else - app_name_prefix=$RIC_SIM_PREFIX"-"$RICSIM_COMPOSE_SERVICE_NAME"-" - fi + app_name_prefix=$RIC_SIM_PREFIX"-"$RICSIM_COMPOSE_SERVICE_NAME"-" while [ $cntr -le $2 ]; do app=$app_name_prefix$cntr app_data="$app_data $app" @@ -310,11 +298,7 @@ start_ric_simulators() { cntr=1 while [ $cntr -le $2 ]; do - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - app=$RIC_SIM_PREFIX"_"$RICSIM_COMPOSE_SERVICE_NAME"_"$cntr - else - app=$RIC_SIM_PREFIX"-"$RICSIM_COMPOSE_SERVICE_NAME"-"$cntr - fi + app=$RIC_SIM_PREFIX"-"$RICSIM_COMPOSE_SERVICE_NAME"-"$cntr __check_service_start $app $RIC_SIM_HTTPX"://"$app:$RIC_SIM_PORT$RIC_SIM_ALIVE_URL let cntr=cntr+1 done @@ -348,12 +332,8 @@ __find_sim_host() { fi echo $RIC_SIM_HTTPX"://"$ricname.$ric_setname.$KUBE_A1SIM_NAMESPACE":"$RIC_SIM_PORT else - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - echo $RIC_SIM_HTTPX"://"$1":"$RIC_SIM_PORT - else - ricname=$(echo "$1" | tr '_' '-') - echo $RIC_SIM_HTTPX"://"$ricname":"$RIC_SIM_PORT - fi + ricname=$(echo "$1" | tr '_' '-') + echo $RIC_SIM_HTTPX"://"$ricname":"$RIC_SIM_PORT fi } diff --git a/test/common/testcase_common.sh b/test/common/testcase_common.sh index 5eb6ab80..a36d0318 100755 --- a/test/common/testcase_common.sh +++ b/test/common/testcase_common.sh @@ -137,10 +137,10 @@ STOP_AT_ERROR=0 # Applies only to images defined in the test-env files with image names and tags defined as XXXX_RELEASE IMAGE_CATEGORY="DEV" -#Var to indicate docker-compose version, V1 or V2 +#Var to indicate docker-compose version, V1 or V2. V1 is not supported. #V1 names replicated containers __ #V2 names replicated containers -- -DOCKER_COMPOSE_VERSION="V1" +DOCKER_COMPOSE_VERSION="V2" # Name of target platform, if set by start cmd IMAGE_TARGET_PLATFORM="" @@ -1196,13 +1196,16 @@ echo " $(docker version --format 'Client version {{.Client.Version}} Server ve if [ $RUNMODE == "DOCKER" ]; then tmp=$(which docker-compose) if [ $? -ne 0 ] || [ -z "$tmp" ]; then - echo -e $RED"docker-compose is required to run the test environment, pls install"$ERED + echo -e $RED"docker-compose (v.2+) is required to run the test environment, pls install"$ERED exit 1 else tmp=$(docker-compose version) echo " docker-compose installed and using version $tmp" if [[ "$tmp" == *'v2'* ]]; then DOCKER_COMPOSE_VERSION="V2" + else + echo -e $RED"docker-compose version $tmp is not supported. Only version v2 is supported, pls install"$ERED + exit 1 fi fi fi @@ -2972,11 +2975,7 @@ __start_container() { envsubst < $compose_file > "gen_"$compose_file compose_file="gen_"$compose_file - if [ $DOCKER_COMPOSE_VERSION == "V1" ]; then - docker_compose_cmd="docker-compose" - else - docker_compose_cmd="docker compose" - fi + docker_compose_cmd="docker compose" if [ "$compose_args" == "NODOCKERARGS" ]; then $docker_compose_cmd -f $compose_file up -d &> .dockererr diff --git a/test/jenkins/run_test.sh b/test/jenkins/run_test.sh index bcf99cda..6ebb5673 100755 --- a/test/jenkins/run_test.sh +++ b/test/jenkins/run_test.sh @@ -22,7 +22,8 @@ echo "--> run_integration.sh" # Install docker-compose -curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o ./docker-compose +DOCKER_C_VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | jq .name -r) +curl -L "https://github.com/docker/compose/releases/download/${DOCKER_C_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o ./docker-compose chmod +x docker-compose export PATH=$PATH:`pwd` -- 2.16.6