Merge "NONRTRIC - PMS Persistent storage of policies and type definitions"
[nonrtric.git] / test / common / ecs_api_functions.sh
index 986f396..d55f439 100644 (file)
 
 # This is a script that contains container/service management functions and test functions for ECS
 
+################ Test engine functions ################
+
+# Create the image var used during the test
+# arg: <image-tag-suffix> (selects staging, snapshot, release etc)
+# <image-tag-suffix> is present only for images with staging, snapshot,release tags
+__ECS_imagesetup() {
+       __check_and_create_image_var ECS "ECS_IMAGE" "ECS_IMAGE_BASE" "ECS_IMAGE_TAG" $1 "$ECS_DISPLAY_NAME"
+}
+
+# Pull image from remote repo or use locally built image
+# arg: <pull-policy-override> <pull-policy-original>
+# <pull-policy-override> Shall be used for images allowing overriding. For example use a local image when test is started to use released images
+# <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
+}
+
+# Build image (only for simulator or interfaces stubs owned by the test environment)
+# arg: <image-tag-suffix> (selects staging, snapshot, release etc)
+# <image-tag-suffix> is present only for images with staging, snapshot,release tags
+__ECS_imagebuild() {
+       echo -e $RED" Image for app ECS shall never be built"$ERED
+}
+
+# Generate a string for each included image using the app display name and a docker images format string
+# arg: <docker-images-format-string> <file-to-append>
+__ECS_image_data() {
+       echo -e "$ECS_DISPLAY_NAME\t$(docker images --format $1 $ECS_IMAGE)" >>   $2
+}
+
+# Scale kubernetes resources to zero
+# All resources shall be ordered to be scaled to 0, if relevant. If not relevant to scale, then do no action.
+# This function is called for apps fully managed by the test script
+__ECS_kube_scale_zero() {
+       __kube_scale_all_resources $KUBE_NONRTRIC_NAMESPACE autotest ECS
+}
+
+# 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.
+__ECS_kube_scale_zero_and_wait() {
+       __kube_scale_and_wait_all_resources $KUBE_NONRTRIC_NAMESPACE app nonrtric-enrichmentservice
+}
+
+# Delete all kube resouces for the app
+# This function is called for apps managed by the test script.
+__ECS_kube_delete_all() {
+       __kube_delete_all_resources $KUBE_NONRTRIC_NAMESPACE autotest ECS
+}
+
+# Store docker logs
+# This function is called for apps managed by the test script.
+# args: <log-dir> <file-prexix>
+__ECS_store_docker_logs() {
+       docker logs $ECS_APP_NAME > $1$2_ecs.log 2>&1
+}
+#######################################################
+
+
 ## Access to ECS
 # Host name may be changed if app started by kube
 # Direct access
@@ -88,7 +147,7 @@ use_ecs_dmaap_https() {
 }
 
 # Start the ECS
-# args: -
+# args: PROXY|NOPROXY <config-file>
 # (Function for test scripts)
 start_ecs() {
 
@@ -141,12 +200,37 @@ start_ecs() {
                        export ECS_DATA_CONFIGMAP_NAME=$ECS_APP_NAME"-data"
                        export ECS_CONTAINER_MNT_DIR
 
+                       export ECS_DATA_PV_NAME=$ECS_APP_NAME"-pv"
+                       #Create a unique path for the pv each time to prevent a previous volume to be reused
+                       export ECS_PV_PATH="ecsdata-"$(date +%s)
+
+                       if [ $1 == "PROXY" ]; then
+                               ECS_HTTP_PROXY_CONFIG_PORT=$HTTP_PROXY_CONFIG_PORT  #Set if proxy is started
+                               ECS_HTTP_PROXY_CONFIG_HOST_NAME=$HTTP_PROXY_CONFIG_HOST_NAME #Set if proxy is started
+                               if [ $ECS_HTTP_PROXY_CONFIG_PORT -eq 0 ] || [ -z "$ECS_HTTP_PROXY_CONFIG_HOST_NAME" ]; then
+                                       echo -e $YELLOW" Warning: HTTP PROXY will not be configured, proxy app not started"$EYELLOW
+                               else
+                                       echo " Configured with http proxy"
+                               fi
+                       else
+                               ECS_HTTP_PROXY_CONFIG_PORT=0
+                               ECS_HTTP_PROXY_CONFIG_HOST_NAME=""
+                               echo " Configured without http proxy"
+                       fi
+                       export ECS_HTTP_PROXY_CONFIG_PORT
+                       export ECS_HTTP_PROXY_CONFIG_HOST_NAME
+
                        # Create config map for config
                        datafile=$PWD/tmp/$ECS_CONFIG_FILE
-                       cp $1 $datafile
+                       cp $2 $datafile
                        output_yaml=$PWD/tmp/ecs_cfc.yaml
                        __kube_create_configmap $ECS_CONFIG_CONFIGMAP_NAME $KUBE_NONRTRIC_NAMESPACE autotest ECS $datafile $output_yaml
 
+                       # Create pv
+                       input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"pv.yaml
+                       output_yaml=$PWD/tmp/ecs_pv.yaml
+                       __kube_create_instance pv $ECS_APP_NAME $input_yaml $output_yaml
+
                        # Create pvc
                        input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"pvc.yaml
                        output_yaml=$PWD/tmp/ecs_pvc.yaml
@@ -193,7 +277,7 @@ start_ecs() {
                cd $SIM_GROUP
                cd ecs
                cd $ECS_HOST_MNT_DIR
-               cd ..
+               #cd ..
                if [ -d db ]; then
                        if [ "$(ls -A $DIR)" ]; then
                                echo -e $BOLD" Cleaning files in mounted dir: $PWD/db"$EBOLD
@@ -212,13 +296,36 @@ start_ecs() {
                export ECS_APP_NAME_ALIAS
                export ECS_HOST_MNT_DIR
                export ECS_CONTAINER_MNT_DIR
+               export ECS_CONFIG_MOUNT_PATH
+               export ECS_CONFIG_FILE
                export ECS_INTERNAL_PORT
                export ECS_EXTERNAL_PORT
                export ECS_INTERNAL_SECURE_PORT
                export ECS_EXTERNAL_SECURE_PORT
                export DOCKER_SIM_NWNAME
+               export ECS_DISPLAY_NAME
+
+               if [ $1 == "PROXY" ]; then
+                       ECS_HTTP_PROXY_CONFIG_PORT=$HTTP_PROXY_CONFIG_PORT  #Set if proxy is started
+                       ECS_HTTP_PROXY_CONFIG_HOST_NAME=$HTTP_PROXY_CONFIG_HOST_NAME #Set if proxy is started
+                       if [ $ECS_HTTP_PROXY_CONFIG_PORT -eq 0 ] || [ -z "$ECS_HTTP_PROXY_CONFIG_HOST_NAME" ]; then
+                               echo -e $YELLOW" Warning: HTTP PROXY will not be configured, proxy app not started"$EYELLOW
+                       else
+                               echo " Configured with http proxy"
+                       fi
+               else
+                       ECS_HTTP_PROXY_CONFIG_PORT=0
+                       ECS_HTTP_PROXY_CONFIG_HOST_NAME=""
+                       echo " Configured without http proxy"
+               fi
+               export ECS_HTTP_PROXY_CONFIG_PORT
+               export ECS_HTTP_PROXY_CONFIG_HOST_NAME
+
+               dest_file=$SIM_GROUP/$ECS_COMPOSE_DIR/$ECS_HOST_MNT_DIR/$ECS_CONFIG_FILE
+
+               envsubst < $2 > $dest_file
 
-               __start_container $ECS_COMPOSE_DIR NODOCKERARGS 1 $ECS_APP_NAME
+               __start_container $ECS_COMPOSE_DIR "" NODOCKERARGS 1 $ECS_APP_NAME
 
                __check_service_start $ECS_APP_NAME $ECS_PATH$ECS_ALIVE_URL
        fi
@@ -279,13 +386,20 @@ set_ecs_trace() {
 # Perform curl retries when making direct call to ECS for the specified http response codes
 # Speace separated list of http response codes
 # args: [<response-code>]*
-use_agent_retries() {
+use_ecs_retries() {
        echo -e $BOLD"Do curl retries to the ECS REST inteface for these response codes:$@"$EBOLD
-       ECS_AGENT_RETRY_CODES=$@
+       ECS_RETRY_CODES=$@
        echo ""
        return 0
 }
 
+# Check the ecs logs for WARNINGs and ERRORs
+# args: -
+# (Function for test scripts)
+check_ecs_logs() {
+       __check_container_logs "ECS" $ECS_APP_NAME $ECS_LOGPATH WARN ERR
+}
+
 
 # Tests if a variable value in the ECS is equal to a target value and and optional timeout.
 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
@@ -322,7 +436,7 @@ ecs_api_a1_get_job_ids() {
                        return 1
                fi
        else
-               echo -e $YELLOW"USING NOT CONFIRMED INTERFACE - FLAT URI STRUCTURE"$EYELLOW
+               echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
                # Valid number of parameters 4,5,6 etc
        if [ $# -lt 3 ]; then
                        __print_err "<response-code> <type-id>|NOTYPE  <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
@@ -473,7 +587,7 @@ ecs_api_a1_get_type_ids() {
 
 # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}​/status
 # args: <response-code> <type-id> <job-id> [<status>]
-# args (flat uri structure): <response-code> <job-id> [<status>]
+# args (flat uri structure): <response-code> <job-id> [<status> [<timeout>]]
 # (Function for test scripts)
 ecs_api_a1_get_job_status() {
        __log_test_start $@
@@ -505,32 +619,61 @@ ecs_api_a1_get_job_status() {
                        fi
                fi
        else
-               echo -e $YELLOW"USING NOT CONFIRMED INTERFACE - FLAT URI STRUCTURE"$EYELLOW
-               if [ $# -ne 2 ] && [ $# -ne 3 ]; then
-                       __print_err "<response-code> <job-id> [<status>]" $@
+               echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
+               if [ $# -lt 2 ] && [ $# -gt 4 ]; then
+                       __print_err "<response-code> <job-id> [<status> [<timeout>]]" $@
                        return 1
                fi
 
                query="/A1-EI/v1/eijobs/$2/status"
 
-               res="$(__do_curl_to_api ECS GET $query)"
-               status=${res:${#res}-3}
+               start=$SECONDS
+               for (( ; ; )); do
+                       res="$(__do_curl_to_api ECS GET $query)"
+                       status=${res:${#res}-3}
 
-               if [ $status -ne $1 ]; then
-                       __log_test_fail_status_code $1 $status
-                       return 1
-               fi
-               if [ $# -eq 3 ]; then
-                       body=${res:0:${#res}-3}
-                       targetJson="{\"eiJobStatus\": \"$3\"}"
-                       echo " TARGET JSON: $targetJson" >> $HTTPLOG
-                       res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+                       if [ $# -eq 4 ]; then
+                               duration=$((SECONDS-start))
+                               echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
+                               if [ $duration -gt $4 ]; then
+                                       echo ""
+                                       duration=-1  #Last iteration
+                               fi
+                       else
+                               duration=-1 #single test, no wait
+                       fi
 
-                       if [ $res -ne 0 ]; then
-                               __log_test_fail_body
-                               return 1
+                       if [ $status -ne $1 ]; then
+                               if [ $duration -eq -1 ]; then
+                                       __log_test_fail_status_code $1 $status
+                                       return 1
+                               fi
                        fi
-               fi
+                       if [ $# -ge 3 ] && [ $status -eq $1 ]; then
+                               body=${res:0:${#res}-3}
+                               targetJson="{\"eiJobStatus\": \"$3\"}"
+                               echo " TARGET JSON: $targetJson" >> $HTTPLOG
+                               res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+                               if [ $res -ne 0 ]; then
+                                       if [ $duration -eq -1 ]; then
+                                               __log_test_fail_body
+                                               return 1
+                                       fi
+                               else
+                                       duration=-1  #Goto pass
+                               fi
+                       fi
+                       if [ $duration -eq -1 ]; then
+                               if [ $# -eq 4 ]; then
+                                       echo ""
+                               fi
+                               __log_test_pass
+                               return 0
+                       else
+                               sleep 1
+                       fi
+               done
        fi
 
        __log_test_pass
@@ -551,7 +694,7 @@ ecs_api_a1_get_job() {
                fi
                query="/A1-EI/v1/eitypes/$2/eijobs/$3"
        else
-               echo -e $YELLOW"USING NOT CONFIRMED INTERFACE - FLAT URI STRUCTURE"$EYELLOW
+               echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
                if [ $# -ne 2 ] && [ $# -ne 7 ]; then
                        __print_err "<response-code> <job-id> [<type-id> <target-url> <owner-id> <notification-url> <template-job-file>]" $@
                        return 1
@@ -627,7 +770,7 @@ ecs_api_a1_delete_job() {
 
                query="/A1-EI/v1/eitypes/$2/eijobs/$3"
        else
-               echo -e $YELLOW"USING NOT CONFIRMED INTERFACE - FLAT URI STRUCTURE"$EYELLOW
+               echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
                if [ $# -ne 2 ]; then
                        __print_err "<response-code> <job-id>" $@
                        return 1
@@ -672,7 +815,7 @@ ecs_api_a1_put_job() {
 
                query="/A1-EI/v1/eitypes/$2/eijobs/$3"
        else
-               echo -e $YELLOW"USING NOT CONFIRMED INTERFACE - FLAT URI STRUCTURE"$EYELLOW
+               echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
                if [ $# -lt 7 ]; then
                        __print_err "<response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file>" $@
                        return 1
@@ -818,7 +961,7 @@ ecs_api_edp_get_producer_status() {
 
 
 # API Test function: GET /ei-producer/v1/eiproducers
-# args: <response-code> [ EMPTY | <producer-id>+]
+# args (v1_1): <response-code> [ EMPTY | <producer-id>+]
 # (Function for test scripts)
 ecs_api_edp_get_producer_ids() {
        __log_test_start $@
@@ -864,8 +1007,58 @@ ecs_api_edp_get_producer_ids() {
        return 0
 }
 
+# API Test function: GET /ei-producer/v1/eiproducers
+# args (v1_2): <response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]
+# (Function for test scripts)
+ecs_api_edp_get_producer_ids_2() {
+       __log_test_start $@
+
+    if [ $# -lt 1 ]; then
+               __print_err "<response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]" $@
+               return 1
+       fi
+
+       query="/ei-producer/v1/eiproducers"
+       if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then
+               query=$query"?ei_type_id=$2"
+       fi
+    res="$(__do_curl_to_api ECS GET $query)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               __log_test_fail_status_code $1 $status
+               return 1
+       fi
+
+       if [ $# -gt 2 ]; then
+               body=${res:0:${#res}-3}
+               targetJson="["
+
+               for pid in ${@:3} ; do
+                       if [ "$targetJson" != "[" ]; then
+                               targetJson=$targetJson","
+                       fi
+                       if [ $pid != "EMPTY" ]; then
+                               targetJson=$targetJson"\"$pid\""
+                       fi
+               done
+
+               targetJson=$targetJson"]"
+               echo " TARGET JSON: $targetJson" >> $HTTPLOG
+               res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+               if [ $res -ne 0 ]; then
+                       __log_test_fail_body
+                       return 1
+               fi
+       fi
+
+       __log_test_pass
+       return 0
+}
+
 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
-# args: <response-code> <type-id> [<job-schema-file> (EMPTY | [<producer-id>]+)]
+# args: (v1_1) <response-code> <type-id> [<job-schema-file> (EMPTY | [<producer-id>]+)]
 # (Function for test scripts)
 ecs_api_edp_get_type() {
        __log_test_start $@
@@ -923,8 +1116,115 @@ ecs_api_edp_get_type() {
        return 0
 }
 
+# API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
+# args: (v1_2) <response-code> <type-id> [<job-schema-file> ]
+# (Function for test scripts)
+ecs_api_edp_get_type_2() {
+       __log_test_start $@
+
+       paramError=1
+       if [ $# -eq 2 ]; then
+               paramError=0
+       fi
+       if [ $# -eq 3 ]; then
+               paramError=0
+       fi
+    if [ $paramError -ne 0 ]; then
+               __print_err "<response-code> <type-id> [<job-schema-file> ]" $@
+               return 1
+       fi
+
+       query="/ei-producer/v1/eitypes/$2"
+    res="$(__do_curl_to_api ECS GET $query)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               __log_test_fail_status_code $1 $status
+               return 1
+       fi
+       if [ $# -eq 3 ]; then
+               body=${res:0:${#res}-3}
+
+               if [ -f $3 ]; then
+                       schema=$(cat $3)
+               else
+                       __log_test_fail_general "Job template file "$3", does not exist"
+                       return 1
+               fi
+
+               targetJson="{\"ei_job_data_schema\":$schema}"
+
+               echo " TARGET JSON: $targetJson" >> $HTTPLOG
+               res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+               if [ $res -ne 0 ]; then
+                       __log_test_fail_body
+                       return 1
+               fi
+       fi
+       __log_test_pass
+       return 0
+}
+
+# API Test function: PUT /ei-producer/v1/eitypes/{eiTypeId}
+# args: (v1_2) <response-code> <type-id> <job-schema-file>
+# (Function for test scripts)
+ecs_api_edp_put_type_2() {
+       __log_test_start $@
+
+    if [ $# -ne 3 ]; then
+               __print_err "<response-code> <type-id> <job-schema-file>" $@
+               return 1
+       fi
+
+       if [ ! -f $3 ]; then
+               __log_test_fail_general "Job schema file "$3", does not exist"
+               return 1
+       fi
+       schema=$(cat $3)
+       input_json="{\"ei_job_data_schema\":$schema}"
+       file="./tmp/put_type.json"
+       echo $input_json > $file
+
+       query="/ei-producer/v1/eitypes/$2"
+    res="$(__do_curl_to_api ECS PUT $query $file)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               __log_test_fail_status_code $1 $status
+               return 1
+       fi
+
+       __log_test_pass
+       return 0
+}
+
+# API Test function: DELETE /ei-producer/v1/eitypes/{eiTypeId}
+# args: (v1_2) <response-code> <type-id>
+# (Function for test scripts)
+ecs_api_edp_delete_type_2() {
+       __log_test_start $@
+
+    if [ $# -ne 2 ]; then
+               __print_err "<response-code> <type-id>" $@
+               return 1
+       fi
+
+       query="/ei-producer/v1/eitypes/$2"
+    res="$(__do_curl_to_api ECS DELETE $query)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               __log_test_fail_status_code $1 $status
+               return 1
+       fi
+
+       __log_test_pass
+       return 0
+}
+
 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
-# args: <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | [<type-id> <schema-file>]+) ]
+# args: (v1_1) <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | [<type-id> <schema-file>]+) ]
 # (Function for test scripts)
 ecs_api_edp_get_producer() {
        __log_test_start $@
@@ -992,6 +1292,67 @@ ecs_api_edp_get_producer() {
        return 0
 }
 
+# API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
+# args (v1_2): <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]
+# (Function for test scripts)
+ecs_api_edp_get_producer_2() {
+       __log_test_start $@
+
+       #Possible arg count: 2, 5, 6, 7, 8 etc
+       paramError=1
+       if [ $# -eq 2 ]; then
+               paramError=0
+       fi
+       if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then
+               paramError=0
+       fi
+       if [ $# -ge 5 ]; then
+               paramError=0
+       fi
+
+    if [ $paramError -ne 0 ]; then
+               __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]" $@
+               return 1
+       fi
+
+       query="/ei-producer/v1/eiproducers/$2"
+    res="$(__do_curl_to_api ECS GET $query)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               __log_test_fail_status_code $1 $status
+               return 1
+       fi
+
+       if [ $# -gt 2 ]; then
+               body=${res:0:${#res}-3}
+               targetJson="["
+               if [ $# -gt 4 ] && [ "$5" != "EMPTY" ]; then
+                       arr=(${@:5})
+                       for ((i=0; i<$(($#-4)); i=i+1)); do
+                               if [ "$targetJson" != "[" ]; then
+                                       targetJson=$targetJson","
+                               fi
+                               targetJson=$targetJson"\"${arr[$i]}\""
+                       done
+               fi
+               targetJson=$targetJson"]"
+               if [ $# -gt 4 ]; then
+                       targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
+               fi
+               echo " TARGET JSON: $targetJson" >> $HTTPLOG
+               res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+               if [ $res -ne 0 ]; then
+                       __log_test_fail_body
+                       return 1
+               fi
+       fi
+
+       __log_test_pass
+       return 0
+}
+
 # API Test function: DELETE /ei-producer/v1/eiproducers/{eiProducerId}
 # args: <response-code> <producer-id>
 # (Function for test scripts)
@@ -1017,7 +1378,7 @@ ecs_api_edp_delete_producer() {
 }
 
 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
-# args: <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+
+# args: (v1_1) <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+
 # (Function for test scripts)
 ecs_api_edp_put_producer() {
        __log_test_start $@
@@ -1071,8 +1432,57 @@ ecs_api_edp_put_producer() {
        return 0
 }
 
+# API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
+# args: (v1_2) <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]
+# (Function for test scripts)
+ecs_api_edp_put_producer_2() {
+       __log_test_start $@
+
+       #Valid number of parametrer 5,6,8,10,
+       paramError=1
+       if  [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then
+               paramError=0
+       elif [ $# -ge 5 ]; then
+               paramError=0
+       fi
+       if [ $paramError -ne 0 ]; then
+               __print_err "<response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]" $@
+               return 1
+       fi
+
+       inputJson="["
+       if [ $# -gt 4 ] && [ "$5" != "NOTYPE" ]; then
+               arr=(${@:5})
+               for ((i=0; i<$(($#-4)); i=i+1)); do
+                       if [ "$inputJson" != "[" ]; then
+                               inputJson=$inputJson","
+                       fi
+                       inputJson=$inputJson"\""${arr[$i]}"\""
+               done
+       fi
+       inputJson="\"supported_ei_types\":"$inputJson"]"
+
+       inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
+
+       inputJson="{"$inputJson"}"
+
+       file="./tmp/.p.json"
+       echo "$inputJson" > $file
+       query="/ei-producer/v1/eiproducers/$2"
+    res="$(__do_curl_to_api ECS PUT $query $file)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne $1 ]; then
+               __log_test_fail_status_code $1 $status
+               return 1
+       fi
+
+       __log_test_pass
+       return 0
+}
+
 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
-# args: <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)
+# args: (V1-1) <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)
 # (Function for test scripts)
 ecs_api_edp_get_producer_jobs() {
        __log_test_start $@
@@ -1135,6 +1545,69 @@ ecs_api_edp_get_producer_jobs() {
        return 0
 }
 
+# API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
+# args: (V1-2) <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)
+# (Function for test scripts)
+ecs_api_edp_get_producer_jobs_2() {
+       __log_test_start $@
+
+       #Valid number of parameter 2,3,7,11
+       paramError=1
+       if [ $# -eq 2 ]; then
+               paramError=0
+       fi
+       if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
+               paramError=0
+       fi
+       variablecount=$(($#-2))
+       if [ $# -gt 3 ] && [ $(($variablecount%5)) -eq 0 ]; then
+               paramError=0
+       fi
+       if [ $paramError -eq 1 ]; then
+               __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)" $@
+               return 1
+       fi
+
+       query="/ei-producer/v1/eiproducers/$2/eijobs"
+    res="$(__do_curl_to_api ECS GET $query)"
+    status=${res:${#res}-3}
+       if [ $status -ne $1 ]; then
+               __log_test_fail_status_code $1 $status
+               return 1
+       fi
+       if [ $# -gt 2 ]; then
+               body=${res:0:${#res}-3}
+               targetJson="["
+               if [ $# -gt 3 ]; then
+                       arr=(${@:3})
+                       for ((i=0; i<$(($#-3)); i=i+5)); do
+                               if [ "$targetJson" != "[" ]; then
+                                       targetJson=$targetJson","
+                               fi
+                               if [ -f ${arr[$i+4]} ]; then
+                                       jobfile=$(cat ${arr[$i+4]})
+                                       jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
+                               else
+                                       _log_test_fail_general "Job template file "${arr[$i+4]}", does not exist"
+                                       return 1
+                               fi
+                               targetJson=$targetJson"{\"ei_job_identity\":\"${arr[$i]}\",\"ei_type_identity\":\"${arr[$i+1]}\",\"target_uri\":\"${arr[$i+2]}\",\"owner\":\"${arr[$i+3]}\",\"ei_job_data\":$jobfile, \"last_updated\":\"????\"}"
+                       done
+               fi
+               targetJson=$targetJson"]"
+
+               echo " TARGET JSON: $targetJson" >> $HTTPLOG
+               res=$(python3 ../common/compare_json.py "$targetJson" "$body")
+
+               if [ $res -ne 0 ]; then
+                       __log_test_fail_body
+                       return 1
+               fi
+       fi
+
+       __log_test_pass
+       return 0
+}
 
 ##########################################
 ####          Service status          ####
@@ -1168,7 +1641,7 @@ ecs_api_service_status() {
 # Function prefix: ecs_api_admin
 
 # Admin to remove all jobs
-# args:
+# args: <response-code> [ <type> ]
 # (Function for test scripts)
 
 ecs_api_admin_reset() {