Test env updates
[nonrtric.git] / test / common / prodstub_api_functions.sh
index 4d88659..f80e827 100644 (file)
@@ -35,7 +35,7 @@ __PRODSTUB_imagesetup() {
 # <pull-policy-original> 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: <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,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)
+# <response-code> <producer-id> <job-id> <type-id> <target-url> <job-owner> <template-job-file>
+# (Function for test scripts)
+prodstub_check_jobdata_3() {
+       __log_test_start $@
+       if [ $# -ne 7 ]; then
+               __print_err "<response-code> <producer-id> <job-id> <type-id> <target-url> <job-owner> <template-job-file>" $@
+               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