X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fcommon%2Fprodstub_api_functions.sh;h=f80e827ba6eb57dc39527a1074b3eb3887b30514;hb=84ffd4a403baee1b7aa86f9986f0c1659a5a0881;hp=4d88659b02d27e1fd805c316237c701acb799dea;hpb=be9a07faf8fbc1030404bbc71f409eb5e19736ba;p=nonrtric.git diff --git a/test/common/prodstub_api_functions.sh b/test/common/prodstub_api_functions.sh index 4d88659b..f80e827b 100644 --- a/test/common/prodstub_api_functions.sh +++ b/test/common/prodstub_api_functions.sh @@ -35,7 +35,7 @@ __PRODSTUB_imagesetup() { # Shall be used for images that does not allow overriding # Both var may contain: 'remote', 'remote-remove' or 'local' __PRODSTUB_imagepull() { - echo -e $RED"Image for app PRODSTUB shall never be pulled from remove repo"$ERED + echo -e $RED"Image for app PRODSTUB shall never be pulled from remote repo"$ERED } # Build image (only for simulator or interfaces stubs owned by the test environment) @@ -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,12 @@ __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 + if [ $KUBE_PROXY_HTTPX == "http" ]; then + proxyflag=" --proxy $KUBE_PROXY_PATH" + else + proxyflag=" --proxy-insecure --proxy $KUBE_PROXY_PATH" + fi fi fi echo " CMD: $3 $proxyflag" >> $HTTPLOG @@ -406,7 +418,7 @@ prodstub_check_jobdata() { jobfile=$(cat $7) jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g") else - _log_test_fail_general "Template file "$7" for jobdata, does not exist" + __log_test_fail_general "Template file "$7" for jobdata, does not exist" return 1 fi targetJson="{\"ei_job_identity\":\"$3\",\"ei_type_identity\":\"$4\",\"target_uri\":\"$5\",\"owner\":\"$6\", \"ei_job_data\":$jobfile}" @@ -432,10 +444,40 @@ prodstub_check_jobdata_2() { jobfile=$(cat $7) jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g") else - _log_test_fail_general "Template file "$7" for jobdata, does not exist" + __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 + file="./tmp/.p.json" + echo "$targetJson" > $file + + curlString="curl -X GET -skw %{http_code} $PROD_STUB_PATH/jobdata/$2/$3" + + __execute_curl_to_prodstub TEST $1 "$curlString" $file + return $? +} + +# Prodstub API: Get job data for a job and compare with a target job json (info-jobs) +# +# (Function for test scripts) +prodstub_check_jobdata_3() { + __log_test_start $@ + if [ $# -ne 7 ]; then + __print_err " " $@ + return 1 + fi + if [ -f $7 ]; then + jobfile=$(cat $7) + jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g") + else + __log_test_fail_general "Template file "$7" for jobdata, does not exist" return 1 fi - targetJson="{\"ei_job_identity\":\"$3\",\"ei_type_identity\":\"$4\",\"target_uri\":\"$5\",\"owner\":\"$6\", \"ei_job_data\":$jobfile,\"last_updated\":\"????\"}" + targetJson="{\"info_job_identity\":\"$3\",\"info_type_identity\":\"$4\",\"target_uri\":\"$5\",\"owner\":\"$6\", \"info_job_data\":$jobfile,\"last_updated\":\"????\"}" file="./tmp/.p.json" echo "$targetJson" > $file