X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fcommon%2Fcontroller_api_functions.sh;h=d703d838560c9b8f4c031aa05cbda1fd4a08c827;hb=960e66a1728c1c332f6b74320bbd086a442ba5ea;hp=d4055018220a380d3a198c513a126afb5a736495;hpb=edea18a8fda2e2201cb3ede7f7af13f610bf4acc;p=nonrtric.git diff --git a/test/common/controller_api_functions.sh b/test/common/controller_api_functions.sh index d4055018..d703d838 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 @@ -265,6 +272,57 @@ start_sdnc() { return 0 } + +# Stop the sndc +# args: - +# args: - +# (Function for test scripts) +stop_sdnc() { + echo -e $BOLD"Stopping $SDNC_DISPLAY_NAME"$EBOLD + + if [ $RUNMODE == "KUBE" ]; then + __log_conf_fail_not_supported " Cannot stop sndc in KUBE mode" + return 1 + else + docker stop $SDNC_APP_NAME &> ./tmp/.dockererr + if [ $? -ne 0 ]; then + __print_err "Could not stop $SDNC_APP_NAME" $@ + cat ./tmp/.dockererr + ((RES_CONF_FAIL++)) + return 1 + fi + fi + echo -e $BOLD$GREEN"Stopped"$EGREEN$EBOLD + echo "" + return 0 +} + +# Start a previously stopped sdnc +# args: - +# (Function for test scripts) +start_stopped_sdnc() { + echo -e $BOLD"Starting (the previously stopped) $SDNC_DISPLAY_NAME"$EBOLD + + if [ $RUNMODE == "KUBE" ]; then + __log_conf_fail_not_supported " Cannot restart sndc in KUBE mode" + return 1 + else + docker start $SDNC_APP_NAME &> ./tmp/.dockererr + if [ $? -ne 0 ]; then + __print_err "Could not start (the stopped) $SDNC_APP_NAME" $@ + cat ./tmp/.dockererr + ((RES_CONF_FAIL++)) + return 1 + fi + fi + __check_service_start $SDNC_APP_NAME $SDNC_PATH$SDNC_ALIVE_URL + if [ $? -ne 0 ]; then + return 1 + fi + echo "" + return 0 +} + # Check the agent logs for WARNINGs and ERRORs # args: - # (Function for test scripts) @@ -299,8 +357,12 @@ __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 + if [ $KUBE_PROXY_HTTPX == "http" ]; then + proxyflag=" --proxy $KUBE_PROXY_PATH" + else + proxyflag=" --proxy-insecure --proxy $KUBE_PROXY_PATH" + fi 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"