Adaptations to execute in multi-node kube cluster
Issue-ID: NONRTRIC-480
Signed-off-by: BjornMagnussonXA <bjorn.magnusson@est.tech>
Change-Id: If0df0a9ab83811f1373f50dc154ad90d830e1321
diff --git a/test/common/README.md b/test/common/README.md
index a6c09e2..99ee015 100644
--- a/test/common/README.md
+++ b/test/common/README.md
@@ -129,7 +129,7 @@
| arg list |
|--|
-| `remote|remote-remove docker|kube --env-file <environment-filename> [release] [auto-clean] [--stop-at-error] [--ricsim-prefix <prefix> ] [--use-local-image <app-nam>+] [--use-snapshot-image <app-nam>+] [--use-staging-image <app-nam>+] [--use-release-image <app-nam>+]` |
+| `remote|remote-remove docker|kube --env-file <environment-filename> [release] [auto-clean] [--stop-at-error] [--ricsim-prefix <prefix> ] [--use-local-image <app-nam>+] [--use-snapshot-image <app-nam>+] [--use-staging-image <app-nam>+] [--use-release-image <app-nam>+] [--image-repo <repo-address]` |
| parameter | description |
|-|-|
@@ -146,6 +146,8 @@
| `--use-snapshot-image` | The script will use images from the nexus snapshot repo for the supplied apps, space separated list of app short names |
| `--use-staging-image` | The script will use images from the nexus staging repo for the supplied apps, space separated list of app short names |
| `--use-release-image` | The script will use images from the nexus release repo for the supplied apps, space separated list of app short names |
+| `--image-repo` | Url to image repo. Only required in when running in multi-node kube cluster, otherwise optional. All used images will be re-tagged and pushed to this repo
+
| `help` | Print this info along with the test script description and the list of app short names supported |
## Function: setup_testenvironment
diff --git a/test/common/agent_api_functions.sh b/test/common/agent_api_functions.sh
index 11cc145..0c2e48a 100644
--- a/test/common/agent_api_functions.sh
+++ b/test/common/agent_api_functions.sh
@@ -34,7 +34,7 @@
# <pull-policy-original> 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 @@
}
# 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: <docker-images-format-string> <file-to-append>
__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 @@
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 @@
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 daa2c29..4ebac80 100644
--- a/test/common/api_curl.sh
+++ b/test/common/api_curl.sh
@@ -30,8 +30,8 @@
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 c783a61..1b5c8a8 100644
--- a/test/common/consul_cbs_functions.sh
+++ b/test/common/consul_cbs_functions.sh
@@ -43,7 +43,7 @@
# <pull-policy-original> 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 @@
# <pull-policy-original> 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 @@
}
# 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: <docker-images-format-string> <file-to-append>
__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: <docker-images-format-string> <file-to-append>
__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 7620667..df8a4ad 100644
--- a/test/common/control_panel_api_functions.sh
+++ b/test/common/control_panel_api_functions.sh
@@ -35,7 +35,7 @@
# <pull-policy-original> 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 @@
}
# 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: <docker-images-format-string> <file-to-append>
__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 @@
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 @@
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 d405501..7bca91c 100644
--- a/test/common/controller_api_functions.sh
+++ b/test/common/controller_api_functions.sh
@@ -44,8 +44,8 @@
# <pull-policy-original> 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 @@
}
# 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: <docker-images-format-string> <file-to-append>
__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 @@
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 d587c0c..437b207 100644
--- a/test/common/cr_api_functions.sh
+++ b/test/common/cr_api_functions.sh
@@ -46,9 +46,13 @@
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 @@
}
# 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: <docker-images-format-string> <file-to-append>
__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 d55f439..525ac8b 100644
--- a/test/common/ecs_api_functions.sh
+++ b/test/common/ecs_api_functions.sh
@@ -34,7 +34,7 @@
# <pull-policy-original> 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 @@
}
# 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: <docker-images-format-string> <file-to-append>
__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 d8f2cf1..fbeaddf 100644
--- a/test/common/gateway_api_functions.sh
+++ b/test/common/gateway_api_functions.sh
@@ -35,7 +35,7 @@
# <pull-policy-original> 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 @@
}
# 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: <docker-images-format-string> <file-to-append>
__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 02ccb92..3e58a7e 100644
--- a/test/common/http_proxy_api_functions.sh
+++ b/test/common/http_proxy_api_functions.sh
@@ -34,7 +34,7 @@
# <pull-policy-original> 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 @@
}
# 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: <docker-images-format-string> <file-to-append>
__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 fc9764d..374f3ec 100644
--- a/test/common/kube_proxy_api_functions.sh
+++ b/test/common/kube_proxy_api_functions.sh
@@ -35,7 +35,7 @@
# <pull-policy-original> 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 @@
}
# 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: <docker-images-format-string> <file-to-append>
__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 @@
## 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 @@
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_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
+ KUBE_PROXY_WEB_PATH=$CLUSTER_KUBE_PROXY"://"$CLUSTER_KUBE_PROXY_HOST":"$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"
+ echo " Cluster ip/host, cluster http nodeport cluster web nodeport: $CLUSTER_KUBE_PROXY_HOST $CLUSTER_KUBE_PROXY_NODEPORT $KUBE_PROXY_WEB_NODEPORT"
- __check_service_start $KUBE_PROXY_APP_NAME $KUBE_PROXY_PATH$KUBE_PROXY_ALIVE_URL
+ 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
+
+ # 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 0d44bdf..1c2f155 100644
--- a/test/common/mr_api_functions.sh
+++ b/test/common/mr_api_functions.sh
@@ -53,9 +53,9 @@
# <pull-policy-original> 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 @@
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 @@
}
# 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: <docker-images-format-string> <file-to-append>
__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: <docker-images-format-string> <file-to-append>
__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 4d88659..ae3f193 100644
--- a/test/common/prodstub_api_functions.sh
+++ b/test/common/prodstub_api_functions.sh
@@ -46,9 +46,13 @@
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 @@
}
# 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: <docker-images-format-string> <file-to-append>
__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 @@
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 10f64e6..254883e 100644
--- a/test/common/rapp_catalogue_api_functions.sh
+++ b/test/common/rapp_catalogue_api_functions.sh
@@ -34,13 +34,17 @@
# <pull-policy-original> 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: <docker-images-format-string> <file-to-append>
__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 c82be76..bf30310 100644
--- a/test/common/ricsimulator_api_functions.sh
+++ b/test/common/ricsimulator_api_functions.sh
@@ -34,13 +34,17 @@
# <pull-policy-original> 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: <docker-images-format-string> <file-to-append>
__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 @@
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 809e1f7..f5cf837 100644
--- a/test/common/test_env-onap-guilin.sh
+++ b/test/common/test_env-onap-guilin.sh
@@ -294,8 +294,7 @@
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 559dab2..8ab85f0 100644
--- a/test/common/test_env-onap-honolulu.sh
+++ b/test/common/test_env-onap-honolulu.sh
@@ -359,8 +359,7 @@
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 15b5854..a59c0e0 100755
--- a/test/common/test_env-oran-cherry.sh
+++ b/test/common/test_env-oran-cherry.sh
@@ -360,8 +360,7 @@
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 96a4186..1890b71 100755
--- a/test/common/test_env-oran-dawn.sh
+++ b/test/common/test_env-oran-dawn.sh
@@ -218,7 +218,7 @@
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_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_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 d969245..b232577 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 <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>+]"
+ echo " [--use-staging-image <app-nam>+] [--use-release-image <app-nam>+] [--image-repo <repo-address]"
}
if [ $# -eq 1 ] && [ "$1" == "help" ]; then
@@ -51,6 +51,7 @@
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 "--image-repo - Url to image repo. Only required in when running in multi-node kube cluster, otherwise optional. All used images will be re-tagged and pushed to this repo"
echo ""
echo "List of app short names supported: "$APP_SHORT_NAMES
exit 0
@@ -300,6 +301,9 @@
TIMER_MEASUREMENTS=".timer_measurement.txt"
echo -e "Activity \t Duration" > $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 @@
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 @@
# 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++))
@@ -630,6 +651,8 @@
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 @@
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
@@ -680,7 +706,14 @@
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 @@
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 <script-start-arg> <descriptive-image-name> <container-base-name> <image-with-tag>
+#args <script-start-arg> <descriptive-image-name> <container-base-name> <image-with-tag-var-name>
__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 @@
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 @@
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 @@
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 @@
# 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