From 483ee33ac3de88385c0eeb3f1ecf3a1bb760db54 Mon Sep 17 00:00:00 2001 From: BjornMagnussonXA Date: Thu, 8 Apr 2021 01:35:24 +0200 Subject: [PATCH] Adaptations to execute in multi-node kube cluster Issue-ID: NONRTRIC-480 Signed-off-by: BjornMagnussonXA Change-Id: If0df0a9ab83811f1373f50dc154ad90d830e1321 --- test/common/README.md | 4 +- test/common/agent_api_functions.sh | 14 +-- test/common/api_curl.sh | 4 +- test/common/consul_cbs_functions.sh | 12 ++- test/common/control_panel_api_functions.sh | 16 +++- test/common/controller_api_functions.sh | 15 +++- test/common/cr_api_functions.sh | 12 ++- test/common/ecs_api_functions.sh | 6 +- test/common/gateway_api_functions.sh | 6 +- test/common/http_proxy_api_functions.sh | 6 +- test/common/kube_proxy_api_functions.sh | 44 +++++----- test/common/mr_api_functions.sh | 28 ++++-- test/common/prodstub_api_functions.sh | 16 +++- test/common/rapp_catalogue_api_functions.sh | 6 +- test/common/ricsimulator_api_functions.sh | 10 ++- test/common/test_env-onap-guilin.sh | 3 +- test/common/test_env-onap-honolulu.sh | 3 +- test/common/test_env-oran-cherry.sh | 3 +- test/common/test_env-oran-dawn.sh | 9 +- test/common/testcase_common.sh | 122 +++++++++++++++++++++++--- test/simulator-group/control_panel/app.yaml | 2 +- test/simulator-group/control_panel/nginx.conf | 4 +- test/simulator-group/control_panel/svc.yaml | 4 +- test/simulator-group/cr/app.yaml | 2 +- test/simulator-group/dmaapmr/app.yaml | 6 +- test/simulator-group/ecs/app.yaml | 2 +- test/simulator-group/httpproxy/app.yaml | 2 +- test/simulator-group/kubeproxy/app.yaml | 2 +- test/simulator-group/kubeproxy/svc.yaml | 1 + test/simulator-group/mrstub/app.yaml | 2 +- test/simulator-group/ngw/app.yaml | 2 +- test/simulator-group/policy_agent/app.yaml | 2 +- test/simulator-group/prodstub/app.yaml | 2 +- test/simulator-group/rapp_catalogue/app.yaml | 2 +- test/simulator-group/ric/app.yaml | 2 +- test/simulator-group/sdnc/app.yaml | 4 +- test/simulator-group/sdnc/app2.yaml | 4 +- 37 files changed, 285 insertions(+), 99 deletions(-) diff --git a/test/common/README.md b/test/common/README.md index a6c09e23..99ee0158 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -129,7 +129,7 @@ The script can be started with these arguments | arg list | |--| -| `remote|remote-remove docker|kube --env-file [release] [auto-clean] [--stop-at-error] [--ricsim-prefix ] [--use-local-image +] [--use-snapshot-image +] [--use-staging-image +] [--use-release-image +]` | +| `remote|remote-remove docker|kube --env-file [release] [auto-clean] [--stop-at-error] [--ricsim-prefix ] [--use-local-image +] [--use-snapshot-image +] [--use-staging-image +] [--use-release-image +] [--image-repo Shall be used for images that does not allow overriding # Both var may contain: 'remote', 'remote-remove' or 'local' __PA_imagepull() { - __check_and_pull_image $1 "$POLICY_AGENT_DISPLAY_NAME" $POLICY_AGENT_APP_NAME $POLICY_AGENT_IMAGE + __check_and_pull_image $1 "$POLICY_AGENT_DISPLAY_NAME" $POLICY_AGENT_APP_NAME POLICY_AGENT_IMAGE } # Build image (only for simulator or interfaces stubs owned by the test environment) @@ -45,9 +45,13 @@ __PA_imagebuild() { } # Generate a string for each included image using the app display name and a docker images format string +# If a custom image repo is used then also the source image from the local repo is listed # arg: __PA_image_data() { echo -e "$POLICY_AGENT_DISPLAY_NAME\t$(docker images --format $1 $POLICY_AGENT_IMAGE)" >> $2 + if [ ! -z "$POLICY_AGENT_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $POLICY_AGENT_IMAGE_SOURCE)" >> $2 + fi } # Scale kubernetes resources to zero @@ -928,8 +932,8 @@ api_put_policy_parallel() { httpproxy="NOPROXY" if [ $RUNMODE == "KUBE" ]; then - if [ ! -z "$CLUSTER_KUBE_PROXY_NODEPORT" ]; then - httpproxy="http://localhost:$CLUSTER_KUBE_PROXY_NODEPORT" + if [ ! -z "$KUBE_PROXY_PATH" ]; then + httpproxy=$KUBE_PROXY_PATH fi fi @@ -1123,8 +1127,8 @@ api_delete_policy_parallel() { httpproxy="NOPROXY" if [ $RUNMODE == "KUBE" ]; then - if [ ! -z "$CLUSTER_KUBE_PROXY_NODEPORT" ]; then - httpproxy="http://localhost:$CLUSTER_KUBE_PROXY_NODEPORT" + if [ ! -z "$KUBE_PROXY_PATH" ]; then + httpproxy=$KUBE_PROXY_PATH fi fi diff --git a/test/common/api_curl.sh b/test/common/api_curl.sh index daa2c294..4ebac805 100644 --- a/test/common/api_curl.sh +++ b/test/common/api_curl.sh @@ -30,8 +30,8 @@ __do_curl_to_api() { echo " (${BASH_LINENO[0]}) - ${TIMESTAMP}: ${FUNCNAME[0]}" $@ >> $HTTPLOG proxyflag="" if [ $RUNMODE == "KUBE" ]; then - if [ ! -z "$CLUSTER_KUBE_PROXY_NODEPORT" ]; then - proxyflag=" --proxy http://localhost:$CLUSTER_KUBE_PROXY_NODEPORT" + if [ ! -z "$KUBE_PROXY_PATH" ]; then + proxyflag=" --proxy $KUBE_PROXY_PATH" fi fi paramError=0 diff --git a/test/common/consul_cbs_functions.sh b/test/common/consul_cbs_functions.sh index c783a612..1b5c8a8e 100644 --- a/test/common/consul_cbs_functions.sh +++ b/test/common/consul_cbs_functions.sh @@ -43,7 +43,7 @@ __CBS_imagesetup() { # Shall be used for images that does not allow overriding # Both var may contain: 'remote', 'remote-remove' or 'local' __CONSUL_imagepull() { - __check_and_pull_image $2 "$CONSUL_DISPLAY_NAME" $CONSUL_APP_NAME $CONSUL_IMAGE + __check_and_pull_image $2 "$CONSUL_DISPLAY_NAME" $CONSUL_APP_NAME CONSUL_IMAGE } # Pull image from remote repo or use locally built image @@ -52,7 +52,7 @@ __CONSUL_imagepull() { # Shall be used for images that does not allow overriding # Both var may contain: 'remote', 'remote-remove' or 'local' __CBS_imagepull() { - __check_and_pull_image $2 "$CBS_DISPLAY_NAME" $CBS_APP_NAME $CBS_IMAGE + __check_and_pull_image $2 "$CBS_DISPLAY_NAME" $CBS_APP_NAME CBS_IMAGE } # Build image (only for simulator or interfaces stubs owned by the test environment) @@ -70,15 +70,23 @@ __CBS_imagebuild() { } # Generate a string for each included image using the app display name and a docker images format string +# If a custom image repo is used then also the source image from the local repo is listed # arg: __CONSUL_image_data() { echo -e "$CONSUL_DISPLAY_NAME\t$(docker images --format $1 $CONSUL_IMAGE)" >> $2 + if [ ! -z "$CONSUL_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $CONSUL_IMAGE_SOURCE)" >> $2 + fi } # Generate a string for each included image using the app display name and a docker images format string +# If a custom image repo is used then also the source image from the local repo is listed # arg: __CBS_image_data() { echo -e "$CBS_DISPLAY_NAME\t$(docker images --format $1 $CBS_IMAGE)" >> $2 + if [ ! -z "$CBS_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $CBS_IMAGE_SOURCE)" >> $2 + fi } # Scale kubernetes resources to zero diff --git a/test/common/control_panel_api_functions.sh b/test/common/control_panel_api_functions.sh index 7620667f..df8a4adf 100644 --- a/test/common/control_panel_api_functions.sh +++ b/test/common/control_panel_api_functions.sh @@ -35,7 +35,7 @@ __CP_imagesetup() { # Shall be used for images that does not allow overriding # Both var may contain: 'remote', 'remote-remove' or 'local' __CP_imagepull() { - __check_and_pull_image $1 "$CONTROL_PANEL_DISPLAY_NAME" $CONTROL_PANEL_APP_NAME $CONTROL_PANEL_IMAGE + __check_and_pull_image $1 "$CONTROL_PANEL_DISPLAY_NAME" $CONTROL_PANEL_APP_NAME CONTROL_PANEL_IMAGE } # Build image (only for simulator or interfaces stubs owned by the test environment) @@ -46,9 +46,13 @@ __CP_imagebuild() { } # Generate a string for each included image using the app display name and a docker images format string +# If a custom image repo is used then also the source image from the local repo is listed # arg: __CP_image_data() { echo -e "$CONTROL_PANEL_DISPLAY_NAME\t$(docker images --format $1 $CONTROL_PANEL_IMAGE)" >> $2 + if [ ! -z "$CONTROL_PANEL_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $CONTROL_PANEL_IMAGE_SOURCE)" >> $2 + fi } # Scale kubernetes resources to zero @@ -164,10 +168,13 @@ start_control_panel() { export CONTROL_PANEL_CONFIG_MOUNT_PATH export CONTROL_PANEL_CONFIG_FILE export CP_CONFIG_CONFIGMAP_NAME=$CONTROL_PANEL_APP_NAME"-config" + export CP_PROXY_CONFIGMAP_NAME=$CONTROL_PANEL_APP_NAME"-proxy" - export NGW_DOMAIN_NAME=$NRT_GATEWAY_APP_NAME.$KUBE_NONRTRIC_NAMESPACE + export NGW_DOMAIN_NAME=$NRT_GATEWAY_APP_NAME.$KUBE_NONRTRIC_NAMESPACE.svc.cluster.local # suffix needed for nginx name resolution export NRT_GATEWAY_EXTERNAL_PORT + export CP_NGINX_RESOLVER=$CONTROL_PANEL_NGINX_KUBE_RESOLVER + #Check if nonrtric namespace exists, if not create it __kube_create_namespace $KUBE_NONRTRIC_NAMESPACE @@ -245,10 +252,11 @@ start_control_panel() { export CONTROL_PANEL_DISPLAY_NAME export NGW_DOMAIN_NAME=$NRT_GATEWAY_APP_NAME + export CP_NGINX_RESOLVER=$CONTROL_PANEL_NGINX_DOCKER_RESOLVER + dest_file=$SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_HOST_MNT_DIR/$CONTROL_PANEL_CONFIG_FILE - envsubst '${NGW_DOMAIN_NAME},${NRT_GATEWAY_EXTERNAL_PORT},${POLICY_AGENT_EXTERNAL_SECURE_PORT},${ECS_EXTERNAL_SECURE_PORT},${POLICY_AGENT_DOMAIN_NAME},${ECS_DOMAIN_NAME}' < $1 > $dest_file - #envsubst < $1 > $dest_file + envsubst '${NGW_DOMAIN_NAME},${CP_NGINX_RESOLVER},${NRT_GATEWAY_EXTERNAL_PORT},${POLICY_AGENT_EXTERNAL_SECURE_PORT},${ECS_EXTERNAL_SECURE_PORT},${POLICY_AGENT_DOMAIN_NAME},${ECS_DOMAIN_NAME}' < $1 > $dest_file __start_container $CONTROL_PANEL_COMPOSE_DIR "" NODOCKERARGS 1 $CONTROL_PANEL_APP_NAME diff --git a/test/common/controller_api_functions.sh b/test/common/controller_api_functions.sh index d4055018..7bca91c6 100644 --- a/test/common/controller_api_functions.sh +++ b/test/common/controller_api_functions.sh @@ -44,8 +44,8 @@ __SDNC_imagesetup() { # Shall be used for images that does not allow overriding # Both var may contain: 'remote', 'remote-remove' or 'local' __SDNC_imagepull() { - __check_and_pull_image $1 "$SDNC_DISPLAY_NAME" $SDNC_APP_NAME $SDNC_A1_CONTROLLER_IMAGE - __check_and_pull_image $2 "SDNC DB" $SDNC_APP_NAME $SDNC_DB_IMAGE + __check_and_pull_image $1 "$SDNC_DISPLAY_NAME" $SDNC_APP_NAME SDNC_A1_CONTROLLER_IMAGE + __check_and_pull_image $2 "SDNC DB" $SDNC_APP_NAME SDNC_DB_IMAGE } # Build image (only for simulator or interfaces stubs owned by the test environment) @@ -56,10 +56,17 @@ __SDNC_imagebuild() { } # Generate a string for each included image using the app display name and a docker images format string +# If a custom image repo is used then also the source image from the local repo is listed # arg: __SDNC_image_data() { echo -e "$SDNC_DISPLAY_NAME\t$(docker images --format $1 $SDNC_A1_CONTROLLER_IMAGE)" >> $2 + if [ ! -z "$SDNC_A1_CONTROLLER_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $SDNC_A1_CONTROLLER_IMAGE_SOURCE)" >> $2 + fi echo -e "SDNC DB\t$(docker images --format $1 $SDNC_DB_IMAGE)" >> $2 + if [ ! -z "$SDNC_DB_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $SDNC_DB_IMAGE_SOURCE)" >> $2 + fi } # Scale kubernetes resources to zero @@ -299,8 +306,8 @@ __do_curl_to_controller() { echo " FILE ($payload) : $json" >> $HTTPLOG proxyflag="" if [ $RUNMODE == "KUBE" ]; then - if [ ! -z "$CLUSTER_KUBE_PROXY_NODEPORT" ]; then - proxyflag=" --proxy http://localhost:$CLUSTER_KUBE_PROXY_NODEPORT" + if [ ! -z "$KUBE_PROXY_PATH" ]; then + proxyflag=" --proxy KUBE_PROXY_PATH" fi fi curlString="curl -skw %{http_code} $proxyflag -X POST $SDNC_API_PATH$1 -H accept:application/json -H Content-Type:application/json --data-binary @$payload" diff --git a/test/common/cr_api_functions.sh b/test/common/cr_api_functions.sh index d587c0c7..437b2077 100644 --- a/test/common/cr_api_functions.sh +++ b/test/common/cr_api_functions.sh @@ -46,9 +46,13 @@ __CR_imagebuild() { echo " Building CR - $CR_DISPLAY_NAME - image: $CR_IMAGE" docker build --build-arg NEXUS_PROXY_REPO=$NEXUS_PROXY_REPO -t $CR_IMAGE . &> .dockererr if [ $? -eq 0 ]; then - echo -e $GREEN" Build Ok"$EGREEN + echo -e $GREEN" Build Ok"$EGREEN + __retag_and_push_image CR_IMAGE + if [ $? -ne 0 ]; then + exit 1 + fi else - echo -e $RED" Build Failed"$ERED + echo -e $RED" Build Failed"$ERED ((RES_CONF_FAIL++)) cat .dockererr echo -e $RED"Exiting...."$ERED @@ -57,9 +61,13 @@ __CR_imagebuild() { } # Generate a string for each included image using the app display name and a docker images format string +# If a custom image repo is used then also the source image from the local repo is listed # arg: __CR_image_data() { echo -e "$CR_DISPLAY_NAME\t$(docker images --format $1 $CR_IMAGE)" >> $2 + if [ ! -z "$CR_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $CR_IMAGE_SOURCE)" >> $2 + fi } # Scale kubernetes resources to zero diff --git a/test/common/ecs_api_functions.sh b/test/common/ecs_api_functions.sh index d55f4399..525ac8b5 100644 --- a/test/common/ecs_api_functions.sh +++ b/test/common/ecs_api_functions.sh @@ -34,7 +34,7 @@ __ECS_imagesetup() { # Shall be used for images that does not allow overriding # Both var may contain: 'remote', 'remote-remove' or 'local' __ECS_imagepull() { - __check_and_pull_image $1 "$ECS_DISPLAY_NAME" $ECS_APP_NAME $ECS_IMAGE + __check_and_pull_image $1 "$ECS_DISPLAY_NAME" $ECS_APP_NAME ECS_IMAGE } # Build image (only for simulator or interfaces stubs owned by the test environment) @@ -45,9 +45,13 @@ __ECS_imagebuild() { } # Generate a string for each included image using the app display name and a docker images format string +# If a custom image repo is used then also the source image from the local repo is listed # arg: __ECS_image_data() { echo -e "$ECS_DISPLAY_NAME\t$(docker images --format $1 $ECS_IMAGE)" >> $2 + if [ ! -z "$ECS_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $ECS_IMAGE_SOURCE)" >> $2 + fi } # Scale kubernetes resources to zero diff --git a/test/common/gateway_api_functions.sh b/test/common/gateway_api_functions.sh index d8f2cf1a..fbeaddf9 100644 --- a/test/common/gateway_api_functions.sh +++ b/test/common/gateway_api_functions.sh @@ -35,7 +35,7 @@ __NGW_imagesetup() { # Shall be used for images that does not allow overriding # Both var may contain: 'remote', 'remote-remove' or 'local' __NGW_imagepull() { - __check_and_pull_image $1 "$NRT_GATEWAY_DISPLAY_NAME" $NRT_GATEWAY_APP_NAME $NRT_GATEWAY_IMAGE + __check_and_pull_image $1 "$NRT_GATEWAY_DISPLAY_NAME" $NRT_GATEWAY_APP_NAME NRT_GATEWAY_IMAGE } # Build image (only for simulator or interfaces stubs owned by the test environment) @@ -46,9 +46,13 @@ __NGW_imagebuild() { } # Generate a string for each included image using the app display name and a docker images format string +# If a custom image repo is used then also the source image from the local repo is listed # arg: __NGW_image_data() { echo -e "$NRT_GATEWAY_DISPLAY_NAME\t$(docker images --format $1 $NRT_GATEWAY_IMAGE)" >> $2 + if [ ! -z "$NRT_GATEWAY_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $NRT_GATEWAY_IMAGE_SOURCE)" >> $2 + fi } # Scale kubernetes resources to zero diff --git a/test/common/http_proxy_api_functions.sh b/test/common/http_proxy_api_functions.sh index 02ccb92a..3e58a7e0 100644 --- a/test/common/http_proxy_api_functions.sh +++ b/test/common/http_proxy_api_functions.sh @@ -34,7 +34,7 @@ __HTTPPROXY_imagesetup() { # Shall be used for images that does not allow overriding # Both var may contain: 'remote', 'remote-remove' or 'local' __HTTPPROXY_imagepull() { - __check_and_pull_image $2 "$HTTP_PROXY_DISPLAY_NAME" $HTTP_PROXY_APP_NAME $HTTP_PROXY_IMAGE + __check_and_pull_image $2 "$HTTP_PROXY_DISPLAY_NAME" $HTTP_PROXY_APP_NAME HTTP_PROXY_IMAGE } # Build image (only for simulator or interfaces stubs owned by the test environment) @@ -45,9 +45,13 @@ __HTTPPROXY_imagebuild() { } # Generate a string for each included image using the app display name and a docker images format string +# If a custom image repo is used then also the source image from the local repo is listed # arg: __HTTPPROXY_image_data() { echo -e "$HTTP_PROXY_DISPLAY_NAME\t$(docker images --format $1 $HTTP_PROXY_IMAGE)" >> $2 + if [ ! -z "$HTTP_PROXY_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $HTTP_PROXY_IMAGE_SOURCE)" >> $2 + fi } # Scale kubernetes resources to zero diff --git a/test/common/kube_proxy_api_functions.sh b/test/common/kube_proxy_api_functions.sh index fc9764d3..374f3ec4 100644 --- a/test/common/kube_proxy_api_functions.sh +++ b/test/common/kube_proxy_api_functions.sh @@ -35,7 +35,7 @@ __KUBEPROXY_imagesetup() { # Shall be used for images that does not allow overriding # Both var may contain: 'remote', 'remote-remove' or 'local' __KUBEPROXY_imagepull() { - __check_and_pull_image $2 "$KUBE_PROXY_DISPLAY_NAME" $KUBE_PROXY_APP_NAME $KUBE_PROXY_IMAGE + __check_and_pull_image $2 "$KUBE_PROXY_DISPLAY_NAME" $KUBE_PROXY_APP_NAME KUBE_PROXY_IMAGE } # Build image (only for simulator or interfaces stubs owned by the test environment) @@ -46,9 +46,13 @@ __KUBEPROXY_imagebuild() { } # Generate a string for each included image using the app display name and a docker images format string +# If a custom image repo is used then also the source image from the local repo is listed # arg: __KUBEPROXY_image_data() { echo -e "$KUBE_PROXY_DISPLAY_NAME\t$(docker images --format $1 $KUBE_PROXY_IMAGE)" >> $2 + if [ ! -z "$KUBE_PROXY_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $KUBE_PROXY_IMAGE_SOURCE)" >> $2 + fi } # Scale kubernetes resources to zero @@ -83,9 +87,9 @@ __KUBEPROXY_store_docker_logs() { ## Access to Kube Http Proxy # Host name may be changed if app started by kube # Direct access from script -KUBE_PROXY_HTTPX="http" -KUBE_PROXY_HOST_NAME=$LOCALHOST_NAME -KUBE_PROXY_PATH=$KUBE_PROXY_HTTPX"://"$KUBE_PROXY_HOST_NAME":"$KUBE_PROXY_WEB_EXTERNAL_PORT +#BMXX KUBE_PROXY_HTTPX="http" +#BMXX KUBE_PROXY_HOST_NAME=$LOCALHOST_NAME +#BMXX KUBE_PROXY_PATH=$KUBE_PROXY_HTTPX"://"$KUBE_PROXY_HOST_NAME":"$KUBE_PROXY_WEB_EXTERNAL_PORT ######################### ### Http Proxy functions @@ -151,27 +155,25 @@ start_kube_proxy() { fi echo " Retrieving host and ports for service..." - KUBE_PROXY_HOST_NAME=$(__kube_get_service_host $KUBE_PROXY_APP_NAME $KUBE_SIM_NAMESPACE) - KUBE_PROXY_WEB_EXTERNAL_PORT=$(__kube_get_service_port $KUBE_PROXY_APP_NAME $KUBE_SIM_NAMESPACE "web") - KUBE_PROXY_EXTERNAL_PORT=$(__kube_get_service_port $KUBE_PROXY_APP_NAME $KUBE_SIM_NAMESPACE "http") - - - minikube status > /dev/null - if [ $? -eq 0 ]; then - echo -e $GREEN" Running minikube inside a kubernetes cluster. No proxy needed for the test script to access services"$EGREEN - export CLUSTER_KUBE_PROXY_NODEPORT="" - else - echo -e $YELLOW" Running outside the kubernetes cluster. Proxy is setup to access services from the test script"$EYELLOW - export CLUSTER_KUBE_PROXY_NODEPORT=$(__kube_get_service_nodeport $KUBE_PROXY_APP_NAME $KUBE_SIM_NAMESPACE "http") + + CLUSTER_KUBE_PROXY="http" + CLUSTER_KUBE_PROXY_HOST=$(kubectl config view -o jsonpath={.clusters[0].cluster.server} | awk -F[/:] '{print $4}') + if [[ $CLUSTER_KUBE_PROXY_HOST == *"kubernetes"* ]]; then + echo -e $YELLOW" The cluster host is: $CLUSTER_KUBE_PROXY_HOST. The proxy (mitmproxy) used by test script requires an ip so the ip is assumed and set to 127.0.0.1" + CLUSTER_KUBE_PROXY_HOST="127.0.0.1" fi + CLUSTER_KUBE_PROXY_NODEPORT=$(__kube_get_service_nodeport $KUBE_PROXY_APP_NAME $KUBE_SIM_NAMESPACE "http") # port for proxy access + KUBE_PROXY_WEB_NODEPORT=$(__kube_get_service_nodeport $KUBE_PROXY_APP_NAME $KUBE_SIM_NAMESPACE "web") # web port, only for alive test + + KUBE_PROXY_WEB_PATH=$CLUSTER_KUBE_PROXY"://"$CLUSTER_KUBE_PROXY_HOST":"$KUBE_PROXY_WEB_NODEPORT - KUBE_PROXY_PATH=$KUBE_PROXY_HTTPX"://"$KUBE_PROXY_HOST_NAME":"$KUBE_PROXY_WEB_EXTERNAL_PORT - KUBE_PROXY_CONFIG_PORT=$KUBE_PROXY_EXTERNAL_PORT - KUBE_PROXY_CONFIG_HOST_NAME=$KUBE_PROXY_APP_NAME"."$KUBE_SIM_NAMESPACE + echo " Cluster ip/host, cluster http nodeport cluster web nodeport: $CLUSTER_KUBE_PROXY_HOST $CLUSTER_KUBE_PROXY_NODEPORT $KUBE_PROXY_WEB_NODEPORT" - echo " Host IP, http port, cluster http nodeport (may be empty): $KUBE_PROXY_HOST_NAME $KUBE_PROXY_WEB_EXTERNAL_PORT $CLUSTER_KUBE_PROXY_NODEPORT" + export KUBE_PROXY_PATH= # Make sure proxy is empty when checking the proxy itself + __check_service_start $KUBE_PROXY_APP_NAME $KUBE_PROXY_WEB_PATH$KUBE_PROXY_ALIVE_URL - __check_service_start $KUBE_PROXY_APP_NAME $KUBE_PROXY_PATH$KUBE_PROXY_ALIVE_URL + # Set proxy for all subsequent calls for all services etc + export KUBE_PROXY_PATH=$CLUSTER_KUBE_PROXY"://"$CLUSTER_KUBE_PROXY_HOST":"$CLUSTER_KUBE_PROXY_NODEPORT else echo $YELLOW" Kube http proxy not needed in docker test. App not started" diff --git a/test/common/mr_api_functions.sh b/test/common/mr_api_functions.sh index 0d44bdf2..1c2f155d 100644 --- a/test/common/mr_api_functions.sh +++ b/test/common/mr_api_functions.sh @@ -53,9 +53,9 @@ __MR_imagepull() { # Shall be used for images that does not allow overriding # Both var may contain: 'remote', 'remote-remove' or 'local' __DMAAPMR_imagepull() { - __check_and_pull_image $2 "DMAAP Message Router" $MR_DMAAP_APP_NAME $ONAP_DMAAPMR_IMAGE - __check_and_pull_image $2 "ZooKeeper" $MR_ZOOKEEPER_APP_NAME $ONAP_ZOOKEEPER_IMAGE - __check_and_pull_image $2 "Kafka" $MR_KAFKA_APP_NAME $ONAP_KAFKA_IMAGE + __check_and_pull_image $2 "DMAAP Message Router" $MR_DMAAP_APP_NAME ONAP_DMAAPMR_IMAGE + __check_and_pull_image $2 "ZooKeeper" $MR_ZOOKEEPER_APP_NAME ONAP_ZOOKEEPER_IMAGE + __check_and_pull_image $2 "Kafka" $MR_KAFKA_APP_NAME ONAP_KAFKA_IMAGE } # Build image (only for simulator or interfaces stubs owned by the test environment) @@ -66,9 +66,13 @@ __MR_imagebuild() { echo " Building MR - $MR_STUB_DISPLAY_NAME - image: $MRSTUB_IMAGE" docker build --build-arg NEXUS_PROXY_REPO=$NEXUS_PROXY_REPO -t $MRSTUB_IMAGE . &> .dockererr if [ $? -eq 0 ]; then - echo -e $GREEN" Build Ok"$EGREEN + echo -e $GREEN" Build Ok"$EGREEN + __retag_and_push_image MRSTUB_IMAGE + if [ $? -ne 0 ]; then + exit 1 + fi else - echo -e $RED" Build Failed"$ERED + echo -e $RED" Build Failed"$ERED ((RES_CONF_FAIL++)) cat .dockererr echo -e $RED"Exiting...."$ERED @@ -84,17 +88,31 @@ __DMAAPMR_imagebuild() { } # Generate a string for each included image using the app display name and a docker images format string +# If a custom image repo is used then also the source image from the local repo is listed # arg: __MR_image_data() { echo -e "$MR_STUB_DISPLAY_NAME\t$(docker images --format $1 $MRSTUB_IMAGE)" >> $2 + if [ ! -z "$MRSTUB_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $MRSTUB_IMAGE_SOURCE)" >> $2 + fi } # Generate a string for each included image using the app display name and a docker images format string +# If a custom image repo is used then also the source image from the local repo is listed # arg: __DMAAPMR_image_data() { echo -e "DMAAP Message Router\t$(docker images --format $1 $ONAP_DMAAPMR_IMAGE)" >> $2 + if [ ! -z "$ONAP_DMAAPMR_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $ONAP_DMAAPMR_IMAGE_SOURCE)" >> $2 + fi echo -e "ZooKeeper\t$(docker images --format $1 $ONAP_ZOOKEEPER_IMAGE)" >> $2 + if [ ! -z "$ONAP_ZOOKEEPER_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $ONAP_ZOOKEEPER_IMAGE_SOURCE)" >> $2 + fi echo -e "Kafka\t$(docker images --format $1 $ONAP_KAFKA_IMAGE)" >> $2 + if [ ! -z "$ONAP_KAFKA_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $ONAP_KAFKA_IMAGE_SOURCE)" >> $2 + fi } # Scale kubernetes resources to zero diff --git a/test/common/prodstub_api_functions.sh b/test/common/prodstub_api_functions.sh index 4d88659b..ae3f193b 100644 --- a/test/common/prodstub_api_functions.sh +++ b/test/common/prodstub_api_functions.sh @@ -46,9 +46,13 @@ __PRODSTUB_imagebuild() { echo " Building PRODSTUB - $PROD_STUB_DISPLAY_NAME - image: $PROD_STUB_IMAGE" docker build --build-arg NEXUS_PROXY_REPO=$NEXUS_PROXY_REPO -t $PROD_STUB_IMAGE . &> .dockererr if [ $? -eq 0 ]; then - echo -e $GREEN" Build Ok"$EGREEN + echo -e $GREEN" Build Ok"$EGREEN + __retag_and_push_image PROD_STUB_IMAGE + if [ $? -ne 0 ]; then + exit 1 + fi else - echo -e $RED" Build Failed"$ERED + echo -e $RED" Build Failed"$ERED ((RES_CONF_FAIL++)) cat .dockererr echo -e $RED"Exiting...."$ERED @@ -57,9 +61,13 @@ __PRODSTUB_imagebuild() { } # Generate a string for each included image using the app display name and a docker images format string +# If a custom image repo is used then also the source image from the local repo is listed # arg: __PRODSTUB_image_data() { echo -e "$PROD_STUB_DISPLAY_NAME\t$(docker images --format $1 $PROD_STUB_IMAGE)" >> $2 + if [ ! -z "$PROD_STUB_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $PROD_STUB_IMAGE_SOURCE)" >> $2 + fi } # Scale kubernetes resources to zero @@ -261,8 +269,8 @@ __execute_curl_to_prodstub() { echo "(${BASH_LINENO[0]}) - ${TIMESTAMP}: ${FUNCNAME[0]}" $@ >> $HTTPLOG proxyflag="" if [ $RUNMODE == "KUBE" ]; then - if [ ! -z "$CLUSTER_KUBE_PROXY_NODEPORT" ]; then - proxyflag=" --proxy http://localhost:$CLUSTER_KUBE_PROXY_NODEPORT" + if [ ! -z "$KUBE_PROXY_PATH" ]; then + proxyflag=" --proxy $KUBE_PROXY_PATH" fi fi echo " CMD: $3 $proxyflag" >> $HTTPLOG diff --git a/test/common/rapp_catalogue_api_functions.sh b/test/common/rapp_catalogue_api_functions.sh index 10f64e6d..254883eb 100644 --- a/test/common/rapp_catalogue_api_functions.sh +++ b/test/common/rapp_catalogue_api_functions.sh @@ -34,13 +34,17 @@ __RC_imagesetup() { # Shall be used for images that does not allow overriding # Both arg var may contain: 'remote', 'remote-remove' or 'local' __RC_imagepull() { - __check_and_pull_image $1 "$c" $RAPP_CAT_APP_NAME $RAPP_CAT_IMAGE + __check_and_pull_image $1 "$c" $RAPP_CAT_APP_NAME RAPP_CAT_IMAGE } # Generate a string for each included image using the app display name and a docker images format string +# If a custom image repo is used then also the source image from the local repo is listed # arg: __RC_image_data() { echo -e "$RAPP_CAT_DISPLAY_NAME\t$(docker images --format $1 $RAPP_CAT_IMAGE)" >> $2 + if [ ! -z "$RAPP_CAT_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $RAPP_CAT_IMAGE_SOURCE)" >> $2 + fi } # Scale kubernetes resources to zero diff --git a/test/common/ricsimulator_api_functions.sh b/test/common/ricsimulator_api_functions.sh index c82be765..bf30310e 100644 --- a/test/common/ricsimulator_api_functions.sh +++ b/test/common/ricsimulator_api_functions.sh @@ -34,13 +34,17 @@ __RICSIM_imagesetup() { # Shall be used for images that does not allow overriding # Both var may contain: 'remote', 'remote-remove' or 'local' __RICSIM_imagepull() { - __check_and_pull_image $1 "$RIC_SIM_DISPLAY_NAME" $RIC_SIM_PREFIX"_"$RIC_SIM_BASE $RIC_SIM_IMAGE + __check_and_pull_image $1 "$RIC_SIM_DISPLAY_NAME" $RIC_SIM_PREFIX"_"$RIC_SIM_BASE RIC_SIM_IMAGE } # Generate a string for each included image using the app display name and a docker images format string +# If a custom image repo is used then also the source image from the local repo is listed # arg: __RICSIM_image_data() { echo -e "$RIC_SIM_DISPLAY_NAME\t$(docker images --format $1 $RIC_SIM_IMAGE)" >> $2 + if [ ! -z "$RIC_SIM_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $RIC_SIM_IMAGE_SOURCE)" >> $2 + fi } # Scale kubernetes resources to zero @@ -346,8 +350,8 @@ __execute_curl_to_sim() { echo ${FUNCNAME[1]} "line: "${BASH_LINENO[1]} >> $HTTPLOG proxyflag="" if [ $RUNMODE == "KUBE" ]; then - if [ ! -z "$CLUSTER_KUBE_PROXY_NODEPORT" ]; then - proxyflag=" --proxy http://localhost:$CLUSTER_KUBE_PROXY_NODEPORT" + if [ ! -z "$KUBE_PROXY_PATH" ]; then + proxyflag=" --proxy $KUBE_PROXY_PATH" fi fi echo " CMD: $2 $proxyflag" >> $HTTPLOG diff --git a/test/common/test_env-onap-guilin.sh b/test/common/test_env-onap-guilin.sh index 809e1f7c..f5cf837f 100644 --- a/test/common/test_env-onap-guilin.sh +++ b/test/common/test_env-onap-guilin.sh @@ -294,8 +294,7 @@ KUBE_PROXY_EXTERNAL_PORT=8730 # Kube Http Proxy conta KUBE_PROXY_INTERNAL_PORT=8080 # Kube Http Proxy container internal port (container -> container) KUBE_PROXY_WEB_EXTERNAL_PORT=8731 # Kube Http Proxy container external port (host -> container) KUBE_PROXY_WEB_INTERNAL_PORT=8081 # Kube Http Proxy container internal port (container -> container) -KUBE_PROXY_CONFIG_PORT=0 # Port number for proxy config, will be set if proxy is started -KUBE_PROXY_CONFIG_HOST_NAME="" # Proxy host, will be set if proxy is started +KUBE_PROXY_PATH="" # Proxy url path, will be set if proxy is started KUBE_PROXY_ALIVE_URL="/" # Base path for alive check KUBE_PROXY_COMPOSE_DIR="kubeproxy" # Dir in simulator_group for docker-compose diff --git a/test/common/test_env-onap-honolulu.sh b/test/common/test_env-onap-honolulu.sh index 559dab2d..8ab85f04 100644 --- a/test/common/test_env-onap-honolulu.sh +++ b/test/common/test_env-onap-honolulu.sh @@ -359,8 +359,7 @@ KUBE_PROXY_EXTERNAL_PORT=8730 # Kube Http Proxy conta KUBE_PROXY_INTERNAL_PORT=8080 # Kube Http Proxy container internal port (container -> container) KUBE_PROXY_WEB_EXTERNAL_PORT=8731 # Kube Http Proxy container external port (host -> container) KUBE_PROXY_WEB_INTERNAL_PORT=8081 # Kube Http Proxy container internal port (container -> container) -KUBE_PROXY_CONFIG_PORT=0 # Port number for proxy config, will be set if proxy is started -KUBE_PROXY_CONFIG_HOST_NAME="" # Proxy host, will be set if proxy is started +KUBE_PROXY_PATH="" # Proxy url path, will be set if proxy is started KUBE_PROXY_ALIVE_URL="/" # Base path for alive check KUBE_PROXY_COMPOSE_DIR="kubeproxy" # Dir in simulator_group for docker-compose diff --git a/test/common/test_env-oran-cherry.sh b/test/common/test_env-oran-cherry.sh index 15b5854d..a59c0e03 100755 --- a/test/common/test_env-oran-cherry.sh +++ b/test/common/test_env-oran-cherry.sh @@ -360,8 +360,7 @@ KUBE_PROXY_EXTERNAL_PORT=8730 # Kube Http Proxy conta KUBE_PROXY_INTERNAL_PORT=8080 # Kube Http Proxy container internal port (container -> container) KUBE_PROXY_WEB_EXTERNAL_PORT=8731 # Kube Http Proxy container external port (host -> container) KUBE_PROXY_WEB_INTERNAL_PORT=8081 # Kube Http Proxy container internal port (container -> container) -KUBE_PROXY_CONFIG_PORT=0 # Port number for proxy config, will be set if proxy is started -KUBE_PROXY_CONFIG_HOST_NAME="" # Proxy host, will be set if proxy is started +KUBE_PROXY_PATH="" # Proxy url path, will be set if proxy is started KUBE_PROXY_ALIVE_URL="/" # Base path for alive check KUBE_PROXY_COMPOSE_DIR="kubeproxy" # Dir in simulator_group for docker-compose diff --git a/test/common/test_env-oran-dawn.sh b/test/common/test_env-oran-dawn.sh index 96a41869..1890b718 100755 --- a/test/common/test_env-oran-dawn.sh +++ b/test/common/test_env-oran-dawn.sh @@ -218,7 +218,7 @@ POLICY_AGENT_HOST_MNT_DIR="./mnt" # Mounted dir, relative POLICY_AGENT_LOGPATH="/var/log/policy-agent/application.log" # Path the application log in the Policy Agent container POLICY_AGENT_APP_NAME_ALIAS="policy-agent-container" # Alias name, name used by the control panel POLICY_AGENT_CONFIG_KEY="policy-agent" # Key for consul config -POLICY_AGENT_PKG_NAME="org.oransc.policyagent" # Java base package name +POLICY_AGENT_PKG_NAME="org.onap.ccsdk.oran.a1policymanagementservice" # Java base package name POLICY_AGENT_ACTUATOR="/actuator/loggers/$POLICY_AGENT_PKG_NAME" # Url for trace/debug POLICY_AGENT_ALIVE_URL="$PMS_API_PREFIX/v2/status" # Base path for alive check POLICY_AGENT_COMPOSE_DIR="policy_agent" # Dir in simulator_group for docker-compose @@ -383,8 +383,10 @@ CONTROL_PANEL_COMPOSE_DIR="control_panel" # Dir in simulator_grou CONTROL_PANEL_CONFIG_FILE=nginx.conf # Config file name CONTROL_PANEL_HOST_MNT_DIR="./mnt" # Mounted dir, relative to compose file, on the host CONTROL_PANEL_CONFIG_MOUNT_PATH=/etc/nginx # Container internal path for config +CONTROL_PANEL_NGINX_KUBE_RESOLVER="kube-dns.kube-system.svc.cluster.local valid=5s" #nginx resolver for kube +CONTROL_PANEL_NGINX_DOCKER_RESOLVER="127.0.0.11" # nginx resolver for docker -NRT_GATEWAY_APP_NAME="nonrtricgateway" # Name of the Gateway container +NRT_GATEWAY_APP_NAME="nonrtricgateway" # Name of the Gateway container NRT_GATEWAY_DISPLAY_NAME="NonRT-RIC Gateway" NRT_GATEWAY_EXTERNAL_PORT=9090 # Gateway container external port (host -> container) NRT_GATEWAY_INTERNAL_PORT=9090 # Gateway container internal port (container -> container) @@ -416,8 +418,7 @@ KUBE_PROXY_EXTERNAL_PORT=8730 # Kube Http Proxy conta KUBE_PROXY_INTERNAL_PORT=8080 # Kube Http Proxy container internal port (container -> container) KUBE_PROXY_WEB_EXTERNAL_PORT=8731 # Kube Http Proxy container external port (host -> container) KUBE_PROXY_WEB_INTERNAL_PORT=8081 # Kube Http Proxy container internal port (container -> container) -KUBE_PROXY_CONFIG_PORT=0 # Port number for proxy config, will be set if proxy is started -KUBE_PROXY_CONFIG_HOST_NAME="" # Proxy host, will be set if proxy is started +KUBE_PROXY_PATH="" # Proxy url path, will be set if proxy is started KUBE_PROXY_ALIVE_URL="/" # Base path for alive check KUBE_PROXY_COMPOSE_DIR="kubeproxy" # Dir in simulator_group for docker-compose diff --git a/test/common/testcase_common.sh b/test/common/testcase_common.sh index d9692452..b2325771 100755 --- a/test/common/testcase_common.sh +++ b/test/common/testcase_common.sh @@ -26,7 +26,7 @@ __print_args() { echo "Args: remote|remote-remove docker|kube --env-file [release] [auto-clean] [--stop-at-error] " echo " [--ricsim-prefix ] [--use-local-image +] [--use-snapshot-image +]" - echo " [--use-staging-image +] [--use-release-image +]" + echo " [--use-staging-image +] [--use-release-image +] [--image-repo $TIMER_MEASUREMENTS +# If this is set, all used images will be re-tagged and pushed to this repo before any +IMAGE_REPO_ADR="" + echo "-------------------------------------------------------------------------------------------------" echo "----------------------------------- Test case: "$ATC @@ -503,6 +507,22 @@ while [ $paramerror -eq 0 ] && [ $foundparm -eq 0 ]; do 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 done echo "" @@ -612,6 +632,7 @@ 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: __check_and_create_image_var() { + if [ $# -ne 6 ]; then echo "Expected arg: " ((IMAGE_ERR++)) @@ -630,6 +651,8 @@ __check_and_create_image_var() { tmptag=$4"_"$5 tag="${!tmptag}" + optional_image_repo_target="" + if [ -z $image ]; then __check_ignore_image $1 if [ $? -eq 0 ]; then @@ -647,6 +670,9 @@ __check_and_create_image_var() { echo "" tmp=$tmp"\t" else + + optional_image_repo_target=$image + #Add repo depending on image type if [ "$5" == "REMOTE_RELEASE" ]; then image=$NEXUS_RELEASE_REPO$image @@ -680,7 +706,14 @@ __check_and_create_image_var() { tmp=$tmp"\t"$5 echo -e "$tmp" >> $image_list_file #Export the env var - export "${2}"=$image":"$tag + export "${2}"=$image":"$tag #Note, this var may be set to the value of the target value below in __check_and_pull_image + if [ ! -z "$IMAGE_REPO_ADR" ]; then + export "${2}_SOURCE"=$image":"$tag #Var to keep the actual source image + export "${2}_TARGET"=$IMAGE_REPO_ADR"/"$optional_image_repo_target":"$tag #Create image + tag for optional image repo - pushed later if needed + else + export "${2}_SOURCE"="" + export "${2}_TARGET"="" + fi } # Check if app uses image included in this test run @@ -830,21 +863,58 @@ __check_image_override() { return 0 } +# Function to re-tag and image and push to another image repo +__retag_and_push_image() { + if [ ! -z "$IMAGE_REPO_ADR" ]; then + source_image="${!1}" + trg_var_name=$1_"TARGET" # This var is created in func __check_and_create_image_var + target_image="${!trg_var_name}" + echo -ne " Attempt to re-tag image to: ${BOLD}${target_image}${EBOLD}${SAMELINE}" + tmp=$(docker image tag $source_image ${target_image} ) + if [ $? -ne 0 ]; then + docker stop $tmp &> ./tmp/.dockererr + ((IMAGE_ERR++)) + echo "" + echo -e " Attempt to re-tag image to: ${BOLD}${target_image}${EBOLD} - ${RED}Failed${ERED}" + cat ./tmp/.dockererr + return 1 + else + echo -e " Attempt to re-tag image to: ${BOLD}${target_image}${EBOLD} - ${GREEN}OK${EGREEN}" + fi + echo -ne " Attempt to push re-tagged image: ${BOLD}${target_image}${EBOLD}${SAMELINE}" + tmp=$(docker push ${target_image} ) + if [ $? -ne 0 ]; then + docker stop $tmp &> ./tmp/.dockererr + ((IMAGE_ERR++)) + echo "" + echo -e " Attempt to push re-tagged image: ${BOLD}${target_image}${EBOLD} - ${RED}Failed${ERED}" + cat ./tmp/.dockererr + return 1 + else + echo -e " Attempt to push re-tagged image: ${BOLD}${target_image}${EBOLD} - ${GREEN}OK${EGREEN}" + fi + export "${1}"=$target_image + fi + return 0 +} + #Function to check if image exist and stop+remove the container+pull new images as needed -#args +#args __check_and_pull_image() { - echo -e " Checking $BOLD$2$EBOLD container(s) with basename: $BOLD$3$EBOLD using image: $BOLD$4$EBOLD" + source_image="${!4}" + + echo -e " Checking $BOLD$2$EBOLD container(s) with basename: $BOLD$3$EBOLD using image: $BOLD$source_image$EBOLD" format_string="\"{{.Repository}}\\t{{.Tag}}\\t{{.CreatedSince}}\\t{{.Size}}\"" - tmp_im=$(docker images --format $format_string ${4}) + tmp_im=$(docker images --format $format_string $source_image) if [ $1 == "local" ]; then if [ -z "$tmp_im" ]; then - echo -e " "$2" (local image): \033[1m"$4"\033[0m $RED does not exist in local registry, need to be built (or manually pulled)"$ERED + echo -e " "$2" (local image): \033[1m"$source_image"\033[0m $RED does not exist in local registry, need to be built (or manually pulled)"$ERED ((IMAGE_ERR++)) return 1 else - echo -e " "$2" (local image): \033[1m"$4"\033[0m "$GREEN"OK"$EGREEN + echo -e " "$2" (local image): \033[1m"$source_image"\033[0m "$GREEN"OK"$EGREEN fi elif [ $1 == "remote" ] || [ $1 == "remote-remove" ]; then if [ $1 == "remote-remove" ]; then @@ -881,7 +951,7 @@ __check_and_pull_image() { fi if [ -z "$tmp_im" ]; then echo -ne " Pulling image${SAMELINE}" - out=$(docker pull $4) + out=$(docker pull $source_image) if [ $? -ne 0 ]; then echo "" echo -e " Pulling image -$RED could not be pulled"$ERED @@ -902,7 +972,10 @@ __check_and_pull_image() { echo -e " Pulling image -$GREEN OK $EGREEN(exists in local repository)" fi fi - return 0 + + __retag_and_push_image $4 + + return $? } setup_testenvironment() { @@ -1078,6 +1151,30 @@ setup_testenvironment() { column -t -s $'\t' $docker_tmp_file | indent1 echo "" + if [ $RUNMODE == "KUBE" ]; then + + echo "=================================================================================" + echo "=================================================================================" + + CLUSTER_IP=$(kubectl config view -o jsonpath={.clusters[0].cluster.server} | awk -F[/:] '{print $4}') + if [[ $CLUSTER_IP != *"kubernetes"* ]]; then + echo -e $YELLOW" The cluster ip is: $CLUSTER_IP. This kubernetes is likely a multi-node cluster."$EYELLOW + echo -e $YELLOW" The image pull policy is set to 'Never'."$EYELLOW + export KUBE_IMAGE_PULL_POLICY="Never" + if [ -z "$IMAGE_REPO_ADR" ]; then + echo -e $RED" The flag --image-repo need to be provided to the cmd with the path to a custom image repo'."$ERED + exit 1 + fi + else + echo -e $YELLOW" The cluster ip is: $CLUSTER_IP. This kubernetes is likely a single-node cluster on a local machine."$EYELLOW + echo -e $YELLOW" The image pull policy is set to 'Never'."$EYELLOW + export KUBE_IMAGE_PULL_POLICY="Never" + fi + + echo "=================================================================================" + echo "=================================================================================" + echo "" + fi echo -e $BOLD"======================================================="$EBOLD echo -e $BOLD"== Common test setup completed - test script begins =="$EBOLD @@ -2091,12 +2188,13 @@ store_logs() { # 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} $@" + proxyflag="" if [ $RUNMODE == "KUBE" ]; then - if [ ! -z "$CLUSTER_KUBE_PROXY_NODEPORT" ]; then - curlString="curl -skw %{http_code} --proxy http://localhost:$CLUSTER_KUBE_PROXY_NODEPORT $@" + if [ ! -z "$KUBE_PROXY_PATH" ]; then + proxyflag=" --proxy $KUBE_PROXY_PATH" fi fi + curlString="curl -skw %{http_code} $proxyflag $@" echo " CMD: $curlString" >> $HTTPLOG res=$($curlString) echo " RESP: $res" >> $HTTPLOG diff --git a/test/simulator-group/control_panel/app.yaml b/test/simulator-group/control_panel/app.yaml index a962f3dc..2b2b84b0 100644 --- a/test/simulator-group/control_panel/app.yaml +++ b/test/simulator-group/control_panel/app.yaml @@ -20,7 +20,7 @@ spec: containers: - name: $CONTROL_PANEL_APP_NAME image: $CONTROL_PANEL_IMAGE - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: $CONTROL_PANEL_INTERNAL_PORT diff --git a/test/simulator-group/control_panel/nginx.conf b/test/simulator-group/control_panel/nginx.conf index 0014ffb0..5b1e8954 100644 --- a/test/simulator-group/control_panel/nginx.conf +++ b/test/simulator-group/control_panel/nginx.conf @@ -18,7 +18,9 @@ events{} http { include /etc/nginx/mime.types; - resolver 127.0.0.11; + + resolver ${CP_NGINX_RESOLVER}; + server { listen 8080; server_name localhost; diff --git a/test/simulator-group/control_panel/svc.yaml b/test/simulator-group/control_panel/svc.yaml index 85a4682e..61dc5de8 100644 --- a/test/simulator-group/control_panel/svc.yaml +++ b/test/simulator-group/control_panel/svc.yaml @@ -7,15 +7,17 @@ metadata: run: $CONTROL_PANEL_APP_NAME autotest: CP spec: - type: ClusterIP + type: NodePort ports: - port: $CONTROL_PANEL_EXTERNAL_PORT targetPort: $CONTROL_PANEL_INTERNAL_PORT protocol: TCP name: http + nodePort: - port: $CONTROL_PANEL_EXTERNAL_SECURE_PORT targetPort: $CONTROL_PANEL_INTERNAL_SECURE_PORT protocol: TCP name: https + nodePort: selector: run: $CONTROL_PANEL_APP_NAME \ No newline at end of file diff --git a/test/simulator-group/cr/app.yaml b/test/simulator-group/cr/app.yaml index 3497b88a..0cb36d2a 100644 --- a/test/simulator-group/cr/app.yaml +++ b/test/simulator-group/cr/app.yaml @@ -20,7 +20,7 @@ spec: containers: - name: $CR_APP_NAME image: $CR_IMAGE - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: $CR_INTERNAL_PORT diff --git a/test/simulator-group/dmaapmr/app.yaml b/test/simulator-group/dmaapmr/app.yaml index 50e6943c..39756bb0 100644 --- a/test/simulator-group/dmaapmr/app.yaml +++ b/test/simulator-group/dmaapmr/app.yaml @@ -20,7 +20,7 @@ spec: containers: - name: $MR_DMAAP_KUBE_APP_NAME image: $ONAP_DMAAPMR_IMAGE - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: $MR_INTERNAL_PORT @@ -77,7 +77,7 @@ spec: containers: - name: $MR_KAFKA_BWDS_NAME image: $ONAP_KAFKA_IMAGE - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: 9092 @@ -142,7 +142,7 @@ spec: containers: - name: $MR_ZOOKEEPER_APP_NAME image: $ONAP_ZOOKEEPER_IMAGE - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: 2181 diff --git a/test/simulator-group/ecs/app.yaml b/test/simulator-group/ecs/app.yaml index 640b61de..bc1bad95 100644 --- a/test/simulator-group/ecs/app.yaml +++ b/test/simulator-group/ecs/app.yaml @@ -20,7 +20,7 @@ spec: containers: - name: $ECS_APP_NAME image: $ECS_IMAGE - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: $ECS_INTERNAL_PORT diff --git a/test/simulator-group/httpproxy/app.yaml b/test/simulator-group/httpproxy/app.yaml index 3e0c8ac3..266eb199 100644 --- a/test/simulator-group/httpproxy/app.yaml +++ b/test/simulator-group/httpproxy/app.yaml @@ -20,7 +20,7 @@ spec: containers: - name: $HTTP_PROXY_APP_NAME image: $HTTP_PROXY_IMAGE - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: $HTTP_PROXY_INTERNAL_PORT diff --git a/test/simulator-group/kubeproxy/app.yaml b/test/simulator-group/kubeproxy/app.yaml index 08241a37..3e6636b7 100644 --- a/test/simulator-group/kubeproxy/app.yaml +++ b/test/simulator-group/kubeproxy/app.yaml @@ -20,7 +20,7 @@ spec: containers: - name: $KUBE_PROXY_APP_NAME image: $KUBE_PROXY_IMAGE - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: $KUBE_PROXY_INTERNAL_PORT diff --git a/test/simulator-group/kubeproxy/svc.yaml b/test/simulator-group/kubeproxy/svc.yaml index 1a11fc40..ea044832 100644 --- a/test/simulator-group/kubeproxy/svc.yaml +++ b/test/simulator-group/kubeproxy/svc.yaml @@ -18,5 +18,6 @@ spec: targetPort: $KUBE_PROXY_WEB_INTERNAL_PORT protocol: TCP name: web + nodePort: selector: run: $KUBE_PROXY_APP_NAME diff --git a/test/simulator-group/mrstub/app.yaml b/test/simulator-group/mrstub/app.yaml index f29db939..0cf0f512 100644 --- a/test/simulator-group/mrstub/app.yaml +++ b/test/simulator-group/mrstub/app.yaml @@ -20,7 +20,7 @@ spec: containers: - name: $MR_STUB_APP_NAME image: $MRSTUB_IMAGE - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: $MR_INTERNAL_PORT diff --git a/test/simulator-group/ngw/app.yaml b/test/simulator-group/ngw/app.yaml index c38de9f0..90706031 100644 --- a/test/simulator-group/ngw/app.yaml +++ b/test/simulator-group/ngw/app.yaml @@ -20,7 +20,7 @@ spec: containers: - name: $NRT_GATEWAY_APP_NAME image: $NRT_GATEWAY_IMAGE - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: $NRT_GATEWAY_INTERNAL_PORT diff --git a/test/simulator-group/policy_agent/app.yaml b/test/simulator-group/policy_agent/app.yaml index ddbae372..bbe8fae5 100644 --- a/test/simulator-group/policy_agent/app.yaml +++ b/test/simulator-group/policy_agent/app.yaml @@ -20,7 +20,7 @@ spec: containers: - name: $POLICY_AGENT_APP_NAME image: $POLICY_AGENT_IMAGE - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: $POLICY_AGENT_INTERNAL_PORT diff --git a/test/simulator-group/prodstub/app.yaml b/test/simulator-group/prodstub/app.yaml index 9fb5ad5e..b8f27e29 100644 --- a/test/simulator-group/prodstub/app.yaml +++ b/test/simulator-group/prodstub/app.yaml @@ -20,7 +20,7 @@ spec: containers: - name: $PROD_STUB_APP_NAME image: $PROD_STUB_IMAGE - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: $PROD_STUB_INTERNAL_PORT diff --git a/test/simulator-group/rapp_catalogue/app.yaml b/test/simulator-group/rapp_catalogue/app.yaml index 0c0a26cf..65a9f807 100644 --- a/test/simulator-group/rapp_catalogue/app.yaml +++ b/test/simulator-group/rapp_catalogue/app.yaml @@ -20,7 +20,7 @@ spec: containers: - name: $RAPP_CAT_APP_NAME image: $RAPP_CAT_IMAGE - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: $RAPP_CAT_INTERNAL_PORT diff --git a/test/simulator-group/ric/app.yaml b/test/simulator-group/ric/app.yaml index df5d982e..a4040394 100644 --- a/test/simulator-group/ric/app.yaml +++ b/test/simulator-group/ric/app.yaml @@ -28,7 +28,7 @@ spec: value: "1" - name: ALLOW_HTTP value: "true" - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: $RIC_SIM_INTERNAL_PORT diff --git a/test/simulator-group/sdnc/app.yaml b/test/simulator-group/sdnc/app.yaml index 75e30d49..13d47393 100644 --- a/test/simulator-group/sdnc/app.yaml +++ b/test/simulator-group/sdnc/app.yaml @@ -20,7 +20,7 @@ spec: containers: - name: $SDNC_APP_NAME image: $SDNC_A1_CONTROLLER_IMAGE - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: $SDNC_INTERNAL_PORT @@ -64,7 +64,7 @@ spec: containers: - name: $SDNC_DB_APP_NAME image: $SDNC_DB_IMAGE - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: 3306 diff --git a/test/simulator-group/sdnc/app2.yaml b/test/simulator-group/sdnc/app2.yaml index 3a0f5973..48aeaf9f 100644 --- a/test/simulator-group/sdnc/app2.yaml +++ b/test/simulator-group/sdnc/app2.yaml @@ -20,7 +20,7 @@ spec: containers: - name: $SDNC_APP_NAME image: $SDNC_A1_CONTROLLER_IMAGE - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: $SDNC_INTERNAL_PORT @@ -80,7 +80,7 @@ spec: containers: - name: $SDNC_DB_APP_NAME image: $SDNC_DB_IMAGE - imagePullPolicy: Never + imagePullPolicy: $KUBE_IMAGE_PULL_POLICY ports: - name: http containerPort: 3306 -- 2.16.6