X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fcommon%2Fprodstub_api_functions.sh;h=9a58292e05d671b2989a08fc3cd86c47facc6261;hb=b188e12cc1b4be627ae6f8f424f06c38ffb89804;hp=6c3ce23424213750d2fcff131b630591a13a63df;hpb=afe34e22e0be919b8e054826c23c551b4e493f79;p=nonrtric.git diff --git a/test/common/prodstub_api_functions.sh b/test/common/prodstub_api_functions.sh index 6c3ce234..9a58292e 100644 --- a/test/common/prodstub_api_functions.sh +++ b/test/common/prodstub_api_functions.sh @@ -1,7 +1,7 @@ #!/bin/bash # ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# Copyright (C) 2020-2023 Nordix Foundation. All rights reserved. # ======================================================================== # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ # arg: (selects staging, snapshot, release etc) # is present only for images with staging, snapshot,release tags __PRODSTUB_imagesetup() { - __check_and_create_image_var PRODSTUB "PROD_STUB_IMAGE" "PROD_STUB_IMAGE_BASE" "PROD_STUB_IMAGE_TAG" LOCAL "$PROD_STUB_DISPLAY_NAME" + __check_and_create_image_var PRODSTUB "PROD_STUB_IMAGE" "PROD_STUB_IMAGE_BASE" "PROD_STUB_IMAGE_TAG" LOCAL "$PROD_STUB_DISPLAY_NAME" $IMAGE_TARGET_PLATFORM_IMG_TAG } # Pull image from remote repo or use locally built image @@ -44,7 +44,7 @@ __PRODSTUB_imagepull() { __PRODSTUB_imagebuild() { cd ../prodstub 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 + docker build $IMAGE_TARGET_PLATFORM_CMD_PARAM --build-arg NEXUS_PROXY_REPO=$NEXUS_PROXY_REPO -t $PROD_STUB_IMAGE . &> .dockererr if [ $? -eq 0 ]; then echo -e $GREEN" Build Ok"$EGREEN __retag_and_push_image PROD_STUB_IMAGE @@ -78,12 +78,12 @@ __PRODSTUB_kube_scale_zero() { } # Scale kubernetes resources to zero and wait until this has been accomplished, if relevant. If not relevant to scale, then do no action. -# This function is called for prestarted apps not managed by the test script. +# This function is called for pre-started apps not managed by the test script. __PRODSTUB_kube_scale_zero_and_wait() { echo -e $RED" PRODSTUB app is not scaled in this state"$ERED } -# Delete all kube resouces for the app +# Delete all kube resources for the app # This function is called for apps managed by the test script. __PRODSTUB_kube_delete_all() { __kube_delete_all_resources $KUBE_SIM_NAMESPACE autotest PRODSTUB @@ -91,10 +91,10 @@ __PRODSTUB_kube_delete_all() { # Store docker logs # This function is called for apps managed by the test script. -# args: +# args: __PRODSTUB_store_docker_logs() { if [ $RUNMODE == "KUBE" ]; then - kubectl logs -l "autotest=PRODSTUB" -n $KUBE_SIM_NAMESPACE --tail=-1 > $1$2_prodstub.log 2>&1 + kubectl $KUBECONF logs -l "autotest=PRODSTUB" -n $KUBE_SIM_NAMESPACE --tail=-1 > $1$2_prodstub.log 2>&1 else docker logs $PROD_STUB_APP_NAME > $1$2_prodstub.log 2>&1 fi @@ -107,11 +107,11 @@ __PRODSTUB_initial_setup() { use_prod_stub_http } -# Set app short-name, app name and namespace for logging runtime statistics of kubernets pods or docker containers +# Set app short-name, app name and namespace for logging runtime statistics of kubernetes pods or docker containers # For docker, the namespace shall be excluded -# This function is called for apps managed by the test script as well as for prestarted apps. +# This function is called for apps managed by the test script as well as for pre-started apps. # args: - -__PRODSTUB_statisics_setup() { +__PRODSTUB_statistics_setup() { if [ $RUNMODE == "KUBE" ]; then echo "PRODSTUB $PROD_STUB_APP_NAME $KUBE_SIM_NAMESPACE" else @@ -119,6 +119,12 @@ __PRODSTUB_statisics_setup() { fi } +# Check application requirements, e.g. helm, the the test needs. Exit 1 if req not satisfied +# args: - +__PRODSTUB_test_requirements() { + : +} + ####################################################### # Set http as the protocol to use for all communication to the Prod stub sim @@ -139,7 +145,7 @@ use_prod_stub_https() { # args: __prod_stub_set_protocoll() { echo -e $BOLD"$PROD_STUB_DISPLAY_NAME protocol setting"$EBOLD - echo -e " Using $BOLD http $EBOLD towards $PROD_STUB_DISPLAY_NAME" + echo -e " Using $BOLD $1 $EBOLD towards $PROD_STUB_DISPLAY_NAME" ## Access to Prod stub sim @@ -161,7 +167,6 @@ __prod_stub_set_protocoll() { # args: __prodstub_export_vars() { export PROD_STUB_APP_NAME - export PROD_STUB_APP_NAME_ALIAS export PROD_STUB_DISPLAY_NAME export DOCKER_SIM_NWNAME @@ -188,18 +193,18 @@ start_prod_stub() { __check_included_image "PRODSTUB" retcode_i=$? - # Check if app shall only be used by the testscipt + # Check if app shall only be used by the test script __check_prestarted_image "PRODSTUB" retcode_p=$? if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then - echo -e $RED"The $ECS_APP_NAME app is not included as managed nor prestarted in this test script"$ERED - echo -e $RED"The $ECS_APP_NAME will not be started"$ERED + echo -e $RED"The $PROD_STUB_APP_NAME app is not included as managed nor prestarted in this test script"$ERED + echo -e $RED"The $PROD_STUB_APP_NAME will not be started"$ERED exit fi if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then - echo -e $RED"The $ECS_APP_NAME app is included both as managed and prestarted in this test script"$ERED - echo -e $RED"The $ECS_APP_NAME will not be started"$ERED + echo -e $RED"The $PROD_STUB_APP_NAME app is included both as managed and prestarted in this test script"$ERED + echo -e $RED"The $PROD_STUB_APP_NAME will not be started"$ERED exit fi @@ -256,7 +261,7 @@ start_prod_stub() { return 0 } -# Excute a curl cmd towards the prodstub simulator and check the response code. +# Execute a curl cmd towards the prodstub simulator and check the response code. # args: TEST|CONF [] __execute_curl_to_prodstub() { TIMESTAMP=$(date "+%Y-%m-%d %H:%M:%S") @@ -269,8 +274,14 @@ __execute_curl_to_prodstub() { proxyflag=" --proxy-insecure --proxy $KUBE_PROXY_PATH" fi fi - echo " CMD: $3 $proxyflag" >> $HTTPLOG - res="$($3 $proxyflag)" + if [ ! -z "$KUBE_PROXY_CURL_JWT" ]; then + jwt="-H "\""Authorization: Bearer $KUBE_PROXY_CURL_JWT"\" + echo " CMD: $3 $proxyflag $jwt" >> $HTTPLOG + res=$($3 $proxyflag -H "Authorization: Bearer $KUBE_PROXY_CURL_JWT") + else + echo " CMD: $3 $proxyflag" >> $HTTPLOG + res="$($3 $proxyflag)" + fi echo " RESP: $res" >> $HTTPLOG retcode=$? if [ $retcode -ne 0 ]; then @@ -439,11 +450,8 @@ prodstub_check_jobdata_2() { __log_test_fail_general "Template file "$7" for jobdata, does not exist" return 1 fi - if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then - targetJson="{\"info_job_identity\":\"$3\",\"info_type_identity\":\"$4\",\"target_uri\":\"$5\",\"owner\":\"$6\", \"info_job_data\":$jobfile,\"last_updated\":\"????\"}" - else - targetJson="{\"ei_job_identity\":\"$3\",\"ei_type_identity\":\"$4\",\"target_uri\":\"$5\",\"owner\":\"$6\", \"ei_job_data\":$jobfile,\"last_updated\":\"????\"}" - fi + targetJson="{\"ei_job_identity\":\"$3\",\"ei_type_identity\":\"$4\",\"target_uri\":\"$5\",\"owner\":\"$6\", \"ei_job_data\":$jobfile,\"last_updated\":\"????\"}" + file="./tmp/.p.json" echo "$targetJson" > $file