Adaptation of test env to helm chart
[nonrtric.git] / test / common / ecs_api_functions.sh
index 525ac8b..2b434f1 100644 (file)
@@ -64,7 +64,7 @@ __ECS_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.
 __ECS_kube_scale_zero_and_wait() {
-       __kube_scale_and_wait_all_resources $KUBE_NONRTRIC_NAMESPACE app nonrtric-enrichmentservice
+       __kube_scale_and_wait_all_resources $KUBE_NONRTRIC_NAMESPACE app "$KUBE_NONRTRIC_NAMESPACE"-enrichmentservice
 }
 
 # Delete all kube resouces for the app
@@ -77,25 +77,29 @@ __ECS_kube_delete_all() {
 # 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
+       if [ $RUNMODE == "KUBE" ]; then
+               kubectl  logs -l "autotest=ECS" -n $KUBE_NONRTRIC_NAMESPACE --tail=-1 > $1$2_ecs.log 2>&1
+       else
+               docker logs $ECS_APP_NAME > $1$2_ecs.log 2>&1
+       fi
 }
-#######################################################
 
+# Initial setup of protocol, host and ports
+# This function is called for apps managed by the test script.
+# args: -
+__ECS_initial_setup() {
+       use_ecs_rest_http
+}
 
-## Access to ECS
-# Host name may be changed if app started by kube
-# Direct access
-ECS_HTTPX="http"
-ECS_HOST_NAME=$LOCALHOST_NAME
-ECS_PATH=$ECS_HTTPX"://"$ECS_HOST_NAME":"$ECS_EXTERNAL_PORT
+#######################################################
 
-# ECS_ADAPTER used for switch between REST and DMAAP (only REST supported currently)
-ECS_ADAPTER_TYPE="REST"
-ECS_ADAPTER=$ECS_PATH
 
 # Make curl retries towards ECS for http response codes set in this env var, space separated list of codes
 ECS_RETRY_CODES=""
 
+#Save first worker node the pod is started on
+__ECS_WORKER_NODE=""
+
 ###########################
 ### ECS functions
 ###########################
@@ -104,28 +108,14 @@ ECS_RETRY_CODES=""
 # args: -
 # (Function for test scripts)
 use_ecs_rest_http() {
-       echo -e $BOLD"ECS protocol setting"$EBOLD
-       echo -e " Using $BOLD http $EBOLD and $BOLD REST $EBOLD towards ECS"
-       ECS_HTTPX="http"
-       ECS_PATH=$ECS_HTTPX"://"$ECS_HOST_NAME":"$ECS_EXTERNAL_PORT
-
-       ECS_ADAPTER_TYPE="REST"
-       ECS_ADAPTER=$ECS_PATH
-       echo ""
+       __ecs_set_protocoll "http" $ECS_INTERNAL_PORT $ECS_EXTERNAL_PORT
 }
 
 # All calls to ECS will be directed to the ECS REST interface from now on
 # args: -
 # (Function for test scripts)
 use_ecs_rest_https() {
-       echo -e $BOLD"ECS protocol setting"$EBOLD
-       echo -e " Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards ECS"
-       ECS_HTTPX="https"
-       ECS_PATH=$ECS_HTTPX"://"$ECS_HOST_NAME":"$ECS_EXTERNAL_SECURE_PORT
-
-       ECS_ADAPTER_TYPE="REST"
-       ECS_ADAPTER=$ECS_PATH
-       echo ""
+       __ecs_set_protocoll "https" $ECS_INTERNAL_SECURE_PORT $ECS_EXTERNAL_SECURE_PORT
 }
 
 # All calls to ECS will be directed to the ECS dmaap interface over http from now on
@@ -139,17 +129,68 @@ use_ecs_dmaap_http() {
        echo ""
 }
 
-# All calls to ECS will be directed to the ECS dmaap interface over https from now on
-# args: -
-# (Function for test scripts)
-use_ecs_dmaap_https() {
-       echo -e $BOLD"RICSIM protocol setting"$EBOLD
-       echo -e $RED" - NOT SUPPORTED - "$ERED
-       echo -e " Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards ECS"
-       ECS_ADAPTER_TYPE="MR-HTTPS"
+# Setup paths to svc/container for internal and external access
+# args: <protocol> <internal-port> <external-port>
+__ecs_set_protocoll() {
+       echo -e $BOLD"$ECS_DISPLAY_NAME protocol setting"$EBOLD
+       echo -e " Using $BOLD http $EBOLD towards $ECS_DISPLAY_NAME"
+
+       ## Access to ECS
+
+       ECS_SERVICE_PATH=$1"://"$ECS_APP_NAME":"$2  # docker access, container->container and script->container via proxy
+       if [ $RUNMODE == "KUBE" ]; then
+               ECS_SERVICE_PATH=$1"://"$ECS_APP_NAME.$KUBE_NONRTRIC_NAMESPACE":"$3 # kube access, pod->svc and script->svc via proxy
+       fi
+
+       # ECS_ADAPTER used for switching between REST and DMAAP (only REST supported currently)
+       ECS_ADAPTER_TYPE="REST"
+       ECS_ADAPTER=$ECS_SERVICE_PATH
+
        echo ""
 }
 
+# Export env vars for config files, docker compose and kube resources
+# args: PROXY|NOPROXY
+__ecs_export_vars() {
+               export ECS_APP_NAME
+               export ECS_APP_NAME_ALIAS
+               export KUBE_NONRTRIC_NAMESPACE
+               export ECS_IMAGE
+               export ECS_INTERNAL_PORT
+               export ECS_INTERNAL_SECURE_PORT
+               export ECS_EXTERNAL_PORT
+               export ECS_EXTERNAL_SECURE_PORT
+               export ECS_CONFIG_MOUNT_PATH
+               export ECS_CONFIG_CONFIGMAP_NAME=$ECS_APP_NAME"-config"
+               export ECS_DATA_CONFIGMAP_NAME=$ECS_APP_NAME"-data"
+               export ECS_CONTAINER_MNT_DIR
+               export ECS_HOST_MNT_DIR
+               export ECS_CONFIG_FILE
+               export DOCKER_SIM_NWNAME
+               export ECS_DISPLAY_NAME
+
+
+               export ECS_DATA_PV_NAME=$ECS_APP_NAME"-pv"
+               export ECS_DATA_PVC_NAME=$ECS_APP_NAME"-pvc"
+               #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
+                       export ECS_HTTP_PROXY_CONFIG_PORT=$HTTP_PROXY_CONFIG_PORT  #Set if proxy is started
+                       export 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
+                       export ECS_HTTP_PROXY_CONFIG_PORT=0
+                       export ECS_HTTP_PROXY_CONFIG_HOST_NAME=""
+                       echo " Configured without http proxy"
+               fi
+}
+
+
 # Start the ECS
 # args: PROXY|NOPROXY <config-file>
 # (Function for test scripts)
@@ -182,7 +223,8 @@ start_ecs() {
                if [ $retcode_p -eq 0 ]; then
                        echo -e " Using existing $ECS_APP_NAME deployment and service"
                        echo " Setting ECS replicas=1"
-                       __kube_scale deployment $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
+                       res_type=$(__kube_get_resource_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
+                       __kube_scale $res_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
                fi
 
                # Check if app shall be fully managed by the test script
@@ -192,37 +234,7 @@ start_ecs() {
                        #Check if nonrtric namespace exists, if not create it
                        __kube_create_namespace $KUBE_NONRTRIC_NAMESPACE
 
-                       export ECS_APP_NAME
-                       export KUBE_NONRTRIC_NAMESPACE
-                       export ECS_IMAGE
-                       export ECS_INTERNAL_PORT
-                       export ECS_INTERNAL_SECURE_PORT
-                       export ECS_EXTERNAL_PORT
-                       export ECS_EXTERNAL_SECURE_PORT
-                       export ECS_CONFIG_MOUNT_PATH
-                       export ECS_CONFIG_CONFIGMAP_NAME=$ECS_APP_NAME"-config"
-                       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
+                       __ecs_export_vars $1
 
                        # Create config map for config
                        datafile=$PWD/tmp/$ECS_CONFIG_FILE
@@ -251,24 +263,22 @@ start_ecs() {
                        __kube_create_instance app $ECS_APP_NAME $input_yaml $output_yaml
                fi
 
-               echo " Retrieving host and ports for service..."
-               ECS_HOST_NAME=$(__kube_get_service_host $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
-               ECS_EXTERNAL_PORT=$(__kube_get_service_port $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE "http")
-               ECS_EXTERNAL_SECURE_PORT=$(__kube_get_service_port $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE "https")
-
-               echo " Host IP, http port, https port: $ECS_HOST_NAME $ECS_EXTERNAL_PORT $ECS_EXTERNAL_SECURE_PORT"
+               # Tie the ECS to a worker node so that ECS will always be scheduled to the same worker node if the ECS pod is restarted
+               # A PVC of type hostPath is mounted to ECS, for persistent storage, so the ECS must always be on the node which mounted the volume
 
-               if [ $ECS_HTTPX == "http" ]; then
-                       ECS_PATH=$ECS_HTTPX"://"$ECS_HOST_NAME":"$ECS_EXTERNAL_PORT
+               # Keep the initial worker node in case the pod need to be "restarted" - must be made to the same node due to a volume mounted on the host
+               if [ $retcode_i -eq 0 ]; then
+                       __ECS_WORKER_NODE=$(kubectl get pod -l "autotest=ECS" -n $KUBE_NONRTRIC_NAMESPACE -o jsonpath='{.items[*].spec.nodeName}')
+                       if [ -z "$__ECS_WORKER_NODE" ]; then
+                               echo -e $YELLOW" Cannot find worker node for pod for $ECS_APP_NAME, persistency may not work"$EYELLOW
+                       fi
                else
-                       ECS_PATH=$ECS_HTTPX"://"$ECS_HOST_NAME":"$ECS_EXTERNAL_SECURE_PORT
+                       echo -e $YELLOW" Persistency may not work for app $ECS_APP_NAME in multi-worker node config when running it as a prestarted app"$EYELLOW
                fi
 
-               __check_service_start $ECS_APP_NAME $ECS_PATH$ECS_ALIVE_URL
 
-               if [ $ECS_ADAPTER_TYPE == "REST" ]; then
-                       ECS_ADAPTER=$ECS_PATH
-               fi
+               __check_service_start $ECS_APP_NAME $ECS_SERVICE_PATH$ECS_ALIVE_URL
+
        else
                __check_included_image 'ECS'
                if [ $? -eq 1 ]; then
@@ -294,36 +304,10 @@ start_ecs() {
                else
                        echo " No files in mounted dir or dir does not exists"
                fi
-               cd $curdir
 
-               export ECS_APP_NAME
-               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
+               cd $curdir
 
-               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
+               __ecs_export_vars $1
 
                dest_file=$SIM_GROUP/$ECS_COMPOSE_DIR/$ECS_HOST_MNT_DIR/$ECS_CONFIG_FILE
 
@@ -331,26 +315,96 @@ start_ecs() {
 
                __start_container $ECS_COMPOSE_DIR "" NODOCKERARGS 1 $ECS_APP_NAME
 
-               __check_service_start $ECS_APP_NAME $ECS_PATH$ECS_ALIVE_URL
+               __check_service_start $ECS_APP_NAME $ECS_SERVICE_PATH$ECS_ALIVE_URL
+       fi
+       echo ""
+       return 0
+}
+
+# Stop the ecs
+# args: -
+# args: -
+# (Function for test scripts)
+stop_ecs() {
+       echo -e $BOLD"Stopping $ECS_DISPLAY_NAME"$EBOLD
+
+       if [ $RUNMODE == "KUBE" ]; then
+
+               __check_prestarted_image "ECS"
+               if [ $? -eq 0 ]; then
+                       echo -e $YELLOW" Persistency may not work for app $ECS_APP_NAME in multi-worker node config when running it as a prestarted app"$EYELLOW
+                       res_type=$(__kube_get_resource_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
+                       __kube_scale $res_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 0
+                       return 0
+               fi
+
+               __kube_scale_all_resources $KUBE_NONRTRIC_NAMESPACE autotest ECS
+               echo "  Deleting the replica set - a new will be started when the app is started"
+               tmp=$(kubectl delete rs -n $KUBE_NONRTRIC_NAMESPACE -l "autotest=ECS")
+               if [ $? -ne 0 ]; then
+                       echo -e $RED" Could not delete replica set "$RED
+                       ((RES_CONF_FAIL++))
+                       return 1
+               fi
+       else
+               docker stop $ECS_APP_NAME &> ./tmp/.dockererr
+               if [ $? -ne 0 ]; then
+                       __print_err "Could not stop $ECS_APP_NAME" $@
+                       cat ./tmp/.dockererr
+                       ((RES_CONF_FAIL++))
+                       return 1
+               fi
        fi
+       echo -e $BOLD$GREEN"Stopped"$EGREEN$EBOLD
        echo ""
        return 0
 }
 
-# Restart ECS
+# Start a previously stopped ecs
 # args: -
 # (Function for test scripts)
-restart_ecs() {
-       echo -e $BOLD"Re-starting ECS"$EBOLD
-       docker restart $ECS_APP_NAME &> ./tmp/.dockererr
+start_stopped_ecs() {
+       echo -e $BOLD"Starting (the previously stopped) $ECS_DISPLAY_NAME"$EBOLD
+
+       if [ $RUNMODE == "KUBE" ]; then
+
+               __check_prestarted_image "ECS"
+               if [ $? -eq 0 ]; then
+                       echo -e $YELLOW" Persistency may not work for app $ECS_APP_NAME in multi-worker node config when running it as a prestarted app"$EYELLOW
+                       res_type=$(__kube_get_resource_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
+                       __kube_scale $res_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
+                       __check_service_start $ECS_APP_NAME $ECS_SERVICE_PATH$ECS_ALIVE_URL
+                       return 0
+               fi
+
+               # Tie the PMS to the same worker node it was initially started on
+               # A PVC of type hostPath is mounted to PMS, for persistent storage, so the PMS must always be on the node which mounted the volume
+               if [ -z "$__ECS_WORKER_NODE" ]; then
+                       echo -e $RED" No initial worker node found for pod "$RED
+                       ((RES_CONF_FAIL++))
+                       return 1
+               else
+                       echo -e $BOLD" Setting nodeSelector kubernetes.io/hostname=$__ECS_WORKER_NODE to deployment for $ECS_APP_NAME. Pod will always run on this worker node: $__PA_WORKER_NODE"$BOLD
+                       echo -e $BOLD" The mounted volume is mounted as hostPath and only available on that worker node."$BOLD
+                       tmp=$(kubectl patch deployment $ECS_APP_NAME -n $KUBE_NONRTRIC_NAMESPACE --patch '{"spec": {"template": {"spec": {"nodeSelector": {"kubernetes.io/hostname": "'$__ECS_WORKER_NODE'"}}}}}')
+                       if [ $? -ne 0 ]; then
+                               echo -e $YELLOW" Cannot set nodeSelector to deployment for $ECS_APP_NAME, persistency may not work"$EYELLOW
+                       fi
+                       __kube_scale deployment $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
+               fi
+       else
+               docker start $ECS_APP_NAME &> ./tmp/.dockererr
+               if [ $? -ne 0 ]; then
+                       __print_err "Could not start (the stopped) $ECS_APP_NAME" $@
+                       cat ./tmp/.dockererr
+                       ((RES_CONF_FAIL++))
+                       return 1
+               fi
+       fi
+       __check_service_start $ECS_APP_NAME $ECS_SERVICE_PATH$ECS_ALIVE_URL
        if [ $? -ne 0 ]; then
-               __print_err "Could not restart $ECS_APP_NAME" $@
-               cat ./tmp/.dockererr
-               ((RES_CONF_FAIL++))
                return 1
        fi
-
-       __check_service_start $ECS_APP_NAME $ECS_PATH$ECS_ALIVE_URL
        echo ""
        return 0
 }
@@ -360,7 +414,7 @@ restart_ecs() {
 # (Function for test scripts)
 set_ecs_debug() {
        echo -e $BOLD"Setting ecs debug logging"$EBOLD
-       curlString="$ECS_PATH$ECS_ACTUATOR -X POST  -H Content-Type:application/json -d {\"configuredLevel\":\"debug\"}"
+       curlString="$ECS_SERVICE_PATH$ECS_ACTUATOR -X POST  -H Content-Type:application/json -d {\"configuredLevel\":\"debug\"}"
        result=$(__do_curl "$curlString")
        if [ $? -ne 0 ]; then
                __print_err "Could not set debug mode" $@
@@ -376,7 +430,7 @@ set_ecs_debug() {
 # (Function for test scripts)
 set_ecs_trace() {
        echo -e $BOLD"Setting ecs trace logging"$EBOLD
-       curlString="$ECS_PATH/actuator/loggers/org.oransc.enrichment -X POST  -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}"
+       curlString="$ECS_SERVICE_PATH/actuator/loggers/org.oransc.enrichment -X POST  -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}"
        result=$(__do_curl "$curlString")
        if [ $? -ne 0 ]; then
                __print_err "Could not set trace mode" $@
@@ -414,7 +468,7 @@ check_ecs_logs() {
 # (Function for test scripts)
 ecs_equal() {
        if [ $# -eq 2 ] || [ $# -eq 3 ]; then
-               __var_test ECS "$ECS_PATH/" $1 "=" $2 $3
+               __var_test ECS "$ECS_SERVICE_PATH/" $1 "=" $2 $3
        else
                __print_err "Wrong args to ecs_equal, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
        fi
@@ -721,7 +775,7 @@ ecs_api_a1_get_job() {
                                jobfile=$(cat $6)
                                jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
                        else
-                               _log_test_fail_general "Job template file "$6", does not exist"
+                               __log_test_fail_general "Job template file "$6", does not exist"
                                return 1
                        fi
                        targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
@@ -741,7 +795,7 @@ ecs_api_a1_get_job() {
                                jobfile=$(cat $7)
                                jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
                        else
-                               _log_test_fail_general "Job template file "$6", does not exist"
+                               __log_test_fail_general "Job template file "$6", does not exist"
                                return 1
                        fi
                        targetJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
@@ -809,7 +863,7 @@ ecs_api_a1_put_job() {
                        jobfile=$(cat $6)
                        jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
                else
-                       _log_test_fail_general "Job template file "$6", does not exist"
+                       __log_test_fail_general "Job template file "$6", does not exist"
                        return 1
                fi
 
@@ -828,7 +882,7 @@ ecs_api_a1_put_job() {
                        jobfile=$(cat $7)
                        jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
                else
-                       _log_test_fail_general "Job template file "$7", does not exist"
+                       __log_test_fail_general "Job template file "$7", does not exist"
                        return 1
                fi
 
@@ -858,6 +912,7 @@ ecs_api_a1_put_job() {
 # Function prefix: ecs_api_edp
 
 # API Test function: GET /ei-producer/v1/eitypes
+# API Test function: GET /data-producer/v1/info-types
 # args: <response-code> [ EMPTY | <type-id>+]
 # (Function for test scripts)
 ecs_api_edp_get_type_ids() {
@@ -867,8 +922,11 @@ ecs_api_edp_get_type_ids() {
                __print_err "<response-code> [ EMPTY | <type-id>+]" $@
                return 1
        fi
-
-       query="/ei-producer/v1/eitypes"
+       if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
+               query="/data-producer/v1/info-types"
+       else
+               query="/ei-producer/v1/eitypes"
+       fi
     res="$(__do_curl_to_api ECS GET $query)"
     status=${res:${#res}-3}
 
@@ -903,6 +961,7 @@ ecs_api_edp_get_type_ids() {
 }
 
 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/status
+# API Test function: GET /data-producer/v1/info-producers/{infoProducerId}/status
 # args: <response-code> <producer-id> [<status> [<timeout>]]
 # (Function for test scripts)
 ecs_api_edp_get_producer_status() {
@@ -912,8 +971,11 @@ ecs_api_edp_get_producer_status() {
                __print_err "<response-code> <producer-id> [<status> [<timeout>]]" $@
                return 1
        fi
-
-       query="/ei-producer/v1/eiproducers/$2/status"
+       if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
+               query="/data-producer/v1/info-producers/$2/status"
+       else
+               query="/ei-producer/v1/eiproducers/$2/status"
+       fi
        start=$SECONDS
        for (( ; ; )); do
                res="$(__do_curl_to_api ECS GET $query)"
@@ -1012,6 +1074,7 @@ ecs_api_edp_get_producer_ids() {
 }
 
 # API Test function: GET /ei-producer/v1/eiproducers
+# API Test function: GET /data-producer/v1/info-producers
 # args (v1_2): <response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]
 # (Function for test scripts)
 ecs_api_edp_get_producer_ids_2() {
@@ -1021,10 +1084,16 @@ ecs_api_edp_get_producer_ids_2() {
                __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"
+    if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
+               query="/data-producer/v1/info-producers"
+               if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then
+                       query=$query"?info_type_id=$2"
+               fi
+       else
+               query="/ei-producer/v1/eiproducers"
+               if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then
+                       query=$query"?ei_type_id=$2"
+               fi
        fi
     res="$(__do_curl_to_api ECS GET $query)"
     status=${res:${#res}-3}
@@ -1121,7 +1190,8 @@ ecs_api_edp_get_type() {
 }
 
 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
-# args: (v1_2) <response-code> <type-id> [<job-schema-file> ]
+# API Test function: GET /data-producer/v1/info-types/{infoTypeId}
+# args: (v1_2) <response-code> <type-id> [<job-schema-file> [ <info-type-info> ]]
 # (Function for test scripts)
 ecs_api_edp_get_type_2() {
        __log_test_start $@
@@ -1133,12 +1203,21 @@ ecs_api_edp_get_type_2() {
        if [ $# -eq 3 ]; then
                paramError=0
        fi
+       if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then
+               if [ $# -eq 4 ]; then
+                       paramError=0
+               fi
+       fi
     if [ $paramError -ne 0 ]; then
-               __print_err "<response-code> <type-id> [<job-schema-file> ]" $@
+               __print_err "<response-code> <type-id> [<job-schema-file> [ <info-type-info> ]]" $@
                return 1
        fi
+       if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
+               query="/data-producer/v1/info-types/$2"
+       else
+               query="/ei-producer/v1/eitypes/$2"
+       fi
 
-       query="/ei-producer/v1/eitypes/$2"
     res="$(__do_curl_to_api ECS GET $query)"
     status=${res:${#res}-3}
 
@@ -1146,7 +1225,7 @@ ecs_api_edp_get_type_2() {
                __log_test_fail_status_code $1 $status
                return 1
        fi
-       if [ $# -eq 3 ]; then
+       if [ $# -ge 3 ]; then
                body=${res:0:${#res}-3}
 
                if [ -f $3 ]; then
@@ -1155,8 +1234,21 @@ ecs_api_edp_get_type_2() {
                        __log_test_fail_general "Job template file "$3", does not exist"
                        return 1
                fi
-
-               targetJson="{\"ei_job_data_schema\":$schema}"
+               info_data=""
+               if [ $# -gt 3 ]; then
+                       if [ -f $4 ]; then
+                               info_data=$(cat $4)
+                       else
+                               __log_test_fail_general "Info-data file "$4", does not exist"
+                               return 1
+                       fi
+                       info_data=",\"info_type_information\":$info_data"
+               fi
+               if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
+                       targetJson="{\"info_job_data_schema\":$schema $info_data}"
+               else
+                       targetJson="{\"ei_job_data_schema\":$schema}"
+               fi
 
                echo " TARGET JSON: $targetJson" >> $HTTPLOG
                res=$(python3 ../common/compare_json.py "$targetJson" "$body")
@@ -1171,26 +1263,55 @@ ecs_api_edp_get_type_2() {
 }
 
 # API Test function: PUT /ei-producer/v1/eitypes/{eiTypeId}
-# args: (v1_2) <response-code> <type-id> <job-schema-file>
+# API Test function: PUT /data-producer/v1/info-types/{infoTypeId}
+# args: (v1_2) <response-code> <type-id> <job-schema-file> [ <info-type-info> ]
 # (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
+       if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then
+               if [ $# -lt 3 ] || [ $# -gt 4 ]; then
+                       __print_err "<response-code> <type-id> <job-schema-file> [ <info-type-info> ]" $@
+                       return 1
+               fi
+       else
+               if [ $# -ne 3 ]; then
+                       __print_err "<response-code> <type-id> <job-schema-file>" $@
+                       return 1
+               fi
        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"
+       info_data=""
+       if [ $# -gt 3 ]; then
+               if [ -f $4 ]; then
+                       info_data=$(cat $4)
+               else
+                       __log_test_fail_general "Info-data file "$4", does not exist"
+                       return 1
+               fi
+               info_data=",\"info_type_information\":$info_data"
+       fi
+
+       if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
+               schema=$(cat $3)
+               input_json="{\"info_job_data_schema\":$schema $info_data}"
+               file="./tmp/put_type.json"
+               echo $input_json > $file
+
+               query="/data-producer/v1/info-types/$2"
+       else
+               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"
+       fi
     res="$(__do_curl_to_api ECS PUT $query $file)"
     status=${res:${#res}-3}
 
@@ -1204,6 +1325,7 @@ ecs_api_edp_put_type_2() {
 }
 
 # API Test function: DELETE /ei-producer/v1/eitypes/{eiTypeId}
+# API Test function: DELETE /data-producer/v1/info-types/{infoTypeId}
 # args: (v1_2) <response-code> <type-id>
 # (Function for test scripts)
 ecs_api_edp_delete_type_2() {
@@ -1214,7 +1336,11 @@ ecs_api_edp_delete_type_2() {
                return 1
        fi
 
-       query="/ei-producer/v1/eitypes/$2"
+       if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
+               query="/data-producer/v1/info-types/$2"
+       else
+               query="/ei-producer/v1/eitypes/$2"
+       fi
     res="$(__do_curl_to_api ECS DELETE $query)"
     status=${res:${#res}-3}
 
@@ -1272,7 +1398,7 @@ ecs_api_edp_get_producer() {
                                if [ -f ${arr[$i+1]} ]; then
                                        schema=$(cat ${arr[$i+1]})
                                else
-                                       _log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
+                                       __log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
                                        return 1
                                fi
 
@@ -1297,6 +1423,7 @@ ecs_api_edp_get_producer() {
 }
 
 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
+# API Test function: GET /data-producer/v1/info-producers/{infoProducerId}
 # args (v1_2): <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]
 # (Function for test scripts)
 ecs_api_edp_get_producer_2() {
@@ -1318,8 +1445,11 @@ ecs_api_edp_get_producer_2() {
                __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]" $@
                return 1
        fi
-
-       query="/ei-producer/v1/eiproducers/$2"
+       if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
+               query="/data-producer/v1/info-producers/$2"
+       else
+               query="/ei-producer/v1/eiproducers/$2"
+       fi
     res="$(__do_curl_to_api ECS GET $query)"
     status=${res:${#res}-3}
 
@@ -1342,7 +1472,11 @@ ecs_api_edp_get_producer_2() {
                fi
                targetJson=$targetJson"]"
                if [ $# -gt 4 ]; then
-                       targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
+                       if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
+                               targetJson="{\"supported_info_types\":$targetJson,\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\"}"
+                       else
+                               targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
+                       fi
                fi
                echo " TARGET JSON: $targetJson" >> $HTTPLOG
                res=$(python3 ../common/compare_json.py "$targetJson" "$body")
@@ -1358,6 +1492,7 @@ ecs_api_edp_get_producer_2() {
 }
 
 # API Test function: DELETE /ei-producer/v1/eiproducers/{eiProducerId}
+# API Test function: DELETE /data-producer/v1/info-producers/{infoProducerId}
 # args: <response-code> <producer-id>
 # (Function for test scripts)
 ecs_api_edp_delete_producer() {
@@ -1367,8 +1502,11 @@ ecs_api_edp_delete_producer() {
                __print_err "<response-code> <producer-id>" $@
                return 1
        fi
-
-       query="/ei-producer/v1/eiproducers/$2"
+       if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
+               query="/data-producer/v1/info-producers/$2"
+       else
+               query="/ei-producer/v1/eiproducers/$2"
+       fi
     res="$(__do_curl_to_api ECS DELETE $query)"
     status=${res:${#res}-3}
 
@@ -1409,7 +1547,7 @@ ecs_api_edp_put_producer() {
                        if [ -f ${arr[$i+1]} ]; then
                                schema=$(cat ${arr[$i+1]})
                        else
-                               _log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
+                               __log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
                                return 1
                        fi
                        inputJson=$inputJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
@@ -1437,6 +1575,7 @@ ecs_api_edp_put_producer() {
 }
 
 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
+# API Test function: PUT /data-producer/v1/info-producers/{infoProducerId}
 # args: (v1_2) <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]
 # (Function for test scripts)
 ecs_api_edp_put_producer_2() {
@@ -1464,15 +1603,27 @@ ecs_api_edp_put_producer_2() {
                        inputJson=$inputJson"\""${arr[$i]}"\""
                done
        fi
-       inputJson="\"supported_ei_types\":"$inputJson"]"
+       if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
+               inputJson="\"supported_info_types\":"$inputJson"]"
 
-       inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
+               inputJson=$inputJson",\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\""
 
-       inputJson="{"$inputJson"}"
+               inputJson="{"$inputJson"}"
 
-       file="./tmp/.p.json"
-       echo "$inputJson" > $file
-       query="/ei-producer/v1/eiproducers/$2"
+               file="./tmp/.p.json"
+               echo "$inputJson" > $file
+               query="/data-producer/v1/info-producers/$2"
+       else
+               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"
+       fi
     res="$(__do_curl_to_api ECS PUT $query $file)"
     status=${res:${#res}-3}
 
@@ -1528,7 +1679,7 @@ ecs_api_edp_get_producer_jobs() {
                                        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"
+                                       __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}"
@@ -1550,6 +1701,7 @@ ecs_api_edp_get_producer_jobs() {
 }
 
 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
+# API Test function: GET /data-producer/v1/info-producers/{infoProducerId}/info-jobs
 # 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() {
@@ -1571,8 +1723,11 @@ ecs_api_edp_get_producer_jobs_2() {
                __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"
+       if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
+               query="/data-producer/v1/info-producers/$2/info-jobs"
+       else
+               query="/ei-producer/v1/eiproducers/$2/eijobs"
+       fi
     res="$(__do_curl_to_api ECS GET $query)"
     status=${res:${#res}-3}
        if [ $status -ne $1 ]; then
@@ -1592,10 +1747,14 @@ ecs_api_edp_get_producer_jobs_2() {
                                        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"
+                                       __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\":\"????\"}"
+                               if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
+                                       targetJson=$targetJson"{\"info_job_identity\":\"${arr[$i]}\",\"info_type_identity\":\"${arr[$i+1]}\",\"target_uri\":\"${arr[$i+2]}\",\"owner\":\"${arr[$i+3]}\",\"info_job_data\":$jobfile, \"last_updated\":\"????\"}"
+                               else
+                                       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\":\"????\"}"
+                               fi
                        done
                fi
                targetJson=$targetJson"]"
@@ -1625,7 +1784,7 @@ ecs_api_service_status() {
        __log_test_start $@
 
     if [ $# -lt 1 ]; then
-               __print_err "<response-code> [<producer-id>]*|NOID" $@
+               __print_err "<response-code>" $@
                return 1
        fi
        res="$(__do_curl_to_api ECS GET /status)"
@@ -1638,53 +1797,648 @@ ecs_api_service_status() {
        return 0
 }
 
+###########################################
+######### Info data consumer API ##########
+###########################################
+#Function prefix: ecs_api_idc
 
-##########################################
-####          Reset jobs              ####
-##########################################
-# Function prefix: ecs_api_admin
 
-# Admin to remove all jobs
-# args: <response-code> [ <type> ]
+# API Test function: GET /data-consumer/v1/info-types
+# args: <response-code> [ (EMPTY | [<type-id>]+) ]
 # (Function for test scripts)
-
-ecs_api_admin_reset() {
+ecs_api_idc_get_type_ids() {
        __log_test_start $@
 
-       if [  -z "$FLAT_A1_EI" ]; then
-               query="/A1-EI/v1/eitypes/$2/eijobs"
-       else
-               query="/A1-EI/v1/eijobs"
+    if [ $# -lt 1 ]; then
+               __print_err "<response-code> [ (EMPTY | [<type-id>]+) ]" $@
+               return 1
        fi
+
+       query="/data-consumer/v1/info-types"
     res="$(__do_curl_to_api ECS GET $query)"
     status=${res:${#res}-3}
 
-       if [ $status -ne 200 ]; then
+       if [ $status -ne $1 ]; then
                __log_test_fail_status_code $1 $status
                return 1
        fi
-
-       #Remove brackets and response code
-       body=${res:1:${#res}-4}
-       list=$(echo ${body//,/ })
-       list=$(echo ${list//[/})
-       list=$(echo ${list//]/})
-       list=$(echo ${list//\"/})
-       list=$list" "
-       for job in $list; do
-               if [  -z "$FLAT_A1_EI" ]; then
-                       echo "Not supported for non-flat EI api"
-               else
-                       query="/A1-EI/v1/eijobs/$job"
-                       res="$(__do_curl_to_api ECS DELETE $query)"
-                       status=${res:${#res}-3}
-                       if [ $status -ne 204 ]; then
-                               __log_test_fail_status_code $1 $status
-                               return 1
-                       fi
-                       echo " Deleted job: "$job
+       if [ $# -gt 1 ]; then
+               body=${res:0:${#res}-3}
+               targetJson="["
+               if [ $2 != "EMPTY" ]; then
+                       for pid in ${@:2} ; do
+                               if [ "$targetJson" != "[" ]; then
+                                       targetJson=$targetJson","
+                               fi
+                               targetJson=$targetJson"\"$pid\""
+                       done
                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 /data-consumer/v1/info-jobs
+# args: <response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
+# (Function for test scripts)
+ecs_api_idc_get_job_ids() {
+       __log_test_start $@
+
+       # 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>+ ]" $@
+               return 1
+       fi
+       search=""
+       if [ $3 != "NOWNER" ]; then
+               search="?owner="$3
+       fi
+
+       if [ $2 != "NOTYPE" ]; then
+               if [ -z "$search" ]; then
+                       search="?infoTypeId="$2
+               else
+                       search=$search"&infoTypeId="$2
+               fi
+       fi
+       query="/data-consumer/v1/info-jobs$search"
+
+    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 3 ]; then
+               body=${res:0:${#res}-3}
+               targetJson="["
+
+               for pid in ${@:4} ; 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 /data-consumer/v1/info-jobs/{infoJobId}
+# args: <response-code> <job-id> [<type-id> <target-url> <owner-id> <template-job-file>]
+# (Function for test scripts)
+ecs_api_idc_get_job() {
+       __log_test_start $@
+
+       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
+       fi
+       query="/data-consumer/v1/info-jobs/$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 7 ]; then
+               body=${res:0:${#res}-3}
+
+               if [ -f $7 ]; then
+                       jobfile=$(cat $7)
+                       jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
+               else
+                       __log_test_fail_general "Job template file "$6", does not exist"
+                       return 1
+               fi
+               targetJson="{\"info_type_id\": \"$3\", \"job_result_uri\": \"$4\",\"job_owner\": \"$5\",\"status_notification_uri\": \"$6\",\"job_definition\": $jobfile}"
+               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 ​/data-consumer/v1/info-jobs/{infoJobId}
+# args: <response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file> [ VALIDATE ]
+# (Function for test scripts)
+ecs_api_idc_put_job() {
+       __log_test_start $@
+
+       if [ $# -lt 7 ] || [ $# -gt 8 ]; then
+               __print_err "<response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file> [ VALIDATE ]" $@
+               return 1
+       fi
+       if [ -f $7 ]; then
+               jobfile=$(cat $7)
+               jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
+       else
+               __log_test_fail_general "Job template file "$7", does not exist"
+               return 1
+       fi
+
+       inputJson="{\"info_type_id\": \"$3\", \"job_result_uri\": \"$4\",\"job_owner\": \"$5\",\"status_notification_uri\": \"$6\",\"job_definition\": $jobfile}"
+       file="./tmp/.p.json"
+       echo "$inputJson" > $file
+
+       query="/data-consumer/v1/info-jobs/$2"
+
+       if [ $# -eq 8 ]; then
+               if [ $8 == "VALIDATE" ]; then
+                       query=$query"?typeCheck=true"
+               fi
+       fi
+
+    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 ​/data-consumer/v1/info-jobs/{infoJobId}
+# args: <response-code> <job-id>
+# (Function for test scripts)
+ecs_api_idc_delete_job() {
+       __log_test_start $@
+
+       if [ $# -ne 2 ]; then
+               __print_err "<response-code> <job-id>" $@
+               return 1
+       fi
+       query="/data-consumer/v1/info-jobs/$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 ​/data-consumer/v1/info-types/{infoTypeId}
+# args: <response-code> <type-id> [<schema-file> [<type-status> <producers-count]]
+# (Function for test scripts)
+ecs_api_idc_get_type() {
+       __log_test_start $@
+
+    if [ $# -lt 2 ] || [ $# -gt 5 ]; then
+               __print_err "<response-code> <type-id> [<schema-file> [<type-status> <producers-count]]" $@
+               return 1
+       fi
+
+       query="/data-consumer/v1/info-types/$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}
+               if [ -f $3 ]; then
+                       schema=$(cat $3)
+               else
+                       __log_test_fail_general "Schema file "$3", does not exist"
+                       return 1
+               fi
+               if [ $# -eq 5 ]; then
+                       targetJson="{\"job_data_schema\":$schema, \"type_status\":\"$4\", \"no_of_producers\":$5}"
+               else
+                       targetJson="{\"job_data_schema\":$schema}"
+               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: GET /data-consumer/v1/info-jobs/{infoJobId}/status
+# This test only status during an optional timeout. No test of the list of producers
+# args: <response-code> <job-id> [<status> [<timeout>]]
+# (Function for test scripts)
+ecs_api_idc_get_job_status() {
+       __log_test_start $@
+
+       if [ $# -lt 2 ] && [ $# -gt 4 ]; then
+               __print_err "<response-code> <job-id> [<status> [<timeout>]]" $@
+               return 1
+       fi
+
+       query="/data-consumer/v1/info-jobs/$2/status"
+
+       start=$SECONDS
+       for (( ; ; )); do
+               res="$(__do_curl_to_api ECS GET $query)"
+               status=${res:${#res}-3}
+
+               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 [ $status -ne $1 ]; then
+                       if [ $duration -eq -1 ]; then
+                               __log_test_fail_status_code $1 $status
+                               return 1
+                       fi
+               fi
+               if [ $# -ge 3 ] && [ $status -eq $1 ]; then
+                       body=${res:0:${#res}-3}
+                       targetJson="{\"info_job_status\": \"$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
+
+       __log_test_pass
+       return 0
+}
+
+# API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}/status
+# This function test status and the list of producers with and optional timeout
+# args: <response-code> <job-id> [<status> EMPTYPROD|( <prod-count> <producer-id>+ ) [<timeout>]]
+# (Function for test scripts)
+ecs_api_idc_get_job_status2() {
+
+       __log_test_start $@
+       param_error=0
+       if [ $# -lt 2 ]; then
+               param_error=1
+       fi
+       args=("$@")
+       timeout=0
+       if [ $# -gt 2 ]; then
+               if [ $# -lt 4 ]; then
+                       param_error=1
+               fi
+               targetJson="{\"info_job_status\": \"$3\""
+               if [ "$4" == "EMPTYPROD" ]; then
+                       targetJson=$targetJson",\"producers\": []}"
+                       if [ $# -gt 4 ]; then
+                               timeout=$5
+                       fi
+               else
+                       targetJson=$targetJson",\"producers\": ["
+                       if [ $# -eq $(($4+5)) ]; then
+                               idx=$(($4+4))
+                               timeout=${args[$idx]}
+                       fi
+                       for ((ecs_i = 0 ; ecs_i < $4 ; ecs_i++)); do
+                               idx=$(($ecs_i+4))
+                               if [ $ecs_i -gt 0 ]; then
+                                       targetJson=$targetJson","
+                               fi
+                               targetJson=$targetJson"\""${args[$idx]}"\""
+                       done
+                       targetJson=$targetJson"]}"
+               fi
+       fi
+
+       if [ $param_error -ne 0 ]; then
+               __print_err "<response-code> <job-id> [<status> EMPTYPROD|( <prod-count> <producer-id>+ ) [<timeout>]]" $@
+               return 1
+       fi
+
+       query="/data-consumer/v1/info-jobs/$2/status"
+
+       start=$SECONDS
+       for (( ; ; )); do
+               res="$(__do_curl_to_api ECS GET $query)"
+               status=${res:${#res}-3}
+
+               if [ $# -gt 2 ]; then
+                       duration=$((SECONDS-start))
+                       echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
+                       if [ $duration -gt $timeout ]; then
+                               echo ""
+                               duration=-1  #Last iteration
+                       fi
+               else
+                       duration=-1 #single test, no wait
+               fi
+
+               if [ $status -ne $1 ]; then
+                       if [ $duration -eq -1 ]; then
+                               __log_test_fail_status_code $1 $status
+                               return 1
+                       fi
+               fi
+               if [ $# -gt 2 ] && [ $status -eq $1 ]; then
+                       body=${res:0:${#res}-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
+
+       __log_test_pass
+       return 0
+}
+
+##########################################
+####     Type subscriptions           ####
+##########################################
+
+# API Test function: GET /data-consumer/v1/info-type-subscription
+# args: <response-code>  <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]
+# (Function for test scripts)
+ecs_api_idc_get_subscription_ids() {
+       __log_test_start $@
+
+    if [ $# -lt 3 ]; then
+               __print_err "<response-code> <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]" $@
+               return 1
+       fi
+
+       query="/data-consumer/v1/info-type-subscription"
+       search=""
+       if [ $2 != "NOOWNER" ]; then
+               search="?owner="$2
+       fi
+
+    res="$(__do_curl_to_api ECS GET $query$search)"
+    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 [ $3 != "EMPTY" ]; then
+                       for pid in ${@:3} ; do
+                               if [ "$targetJson" != "[" ]; then
+                                       targetJson=$targetJson","
+                               fi
+                               targetJson=$targetJson"\"$pid\""
+                       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
+}
+
+# API Test function: GET /data-consumer/v1/info-type-subscription/{subscriptionId}
+# args: <response-code>  <subscription-id> [ <owner-id> <status-uri> ]
+# (Function for test scripts)
+ecs_api_idc_get_subscription() {
+       __log_test_start $@
+
+    if [ $# -ne 2 ] && [ $# -ne 4 ]; then
+               __print_err "<response-code>  <subscription-id> [ <owner-id> <status-uri> ]" $@
+               return 1
+       fi
+
+       query="/data-consumer/v1/info-type-subscription/$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="{\"owner\":\"$3\",\"status_result_uri\":\"$4\"}"
+               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 /data-consumer/v1/info-type-subscription/{subscriptionId}
+# args: <response-code>  <subscription-id> <owner-id> <status-uri>
+# (Function for test scripts)
+ecs_api_idc_put_subscription() {
+       __log_test_start $@
+
+    if [ $# -ne 4 ]; then
+               __print_err "<response-code>  <subscription-id> <owner-id> <status-uri>" $@
+               return 1
+       fi
+
+       inputJson="{\"owner\": \"$3\",\"status_result_uri\": \"$4\"}"
+       file="./tmp/.p.json"
+       echo "$inputJson" > $file
+
+       query="/data-consumer/v1/info-type-subscription/$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 /data-consumer/v1/info-type-subscription/{subscriptionId}
+# args: <response-code>  <subscription-id>
+# (Function for test scripts)
+ecs_api_idc_delete_subscription() {
+       __log_test_start $@
+
+       if [ $# -ne 2 ]; then
+               __print_err "<response-code>  <subscription-id> " $@
+               return 1
+       fi
+
+       query="/data-consumer/v1/info-type-subscription/$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
+}
+
+##########################################
+####          Reset jobs              ####
+##########################################
+# Function prefix: ecs_api_admin
+
+# Admin to remove all jobs
+# args: <response-code> [ <type> ]
+# (Function for test scripts)
+
+ecs_api_admin_reset() {
+       __log_test_start $@
+
+       if [  -z "$FLAT_A1_EI" ]; then
+               query="/A1-EI/v1/eitypes/$2/eijobs"
+       else
+               query="/A1-EI/v1/eijobs"
+       fi
+    res="$(__do_curl_to_api ECS GET $query)"
+    status=${res:${#res}-3}
+
+       if [ $status -ne 200 ]; then
+               __log_test_fail_status_code $1 $status
+               return 1
+       fi
+
+       #Remove brackets and response code
+       body=${res:1:${#res}-4}
+       list=$(echo ${body//,/ })
+       list=$(echo ${list//[/})
+       list=$(echo ${list//]/})
+       list=$(echo ${list//\"/})
+       list=$list" "
+       for job in $list; do
+               if [  -z "$FLAT_A1_EI" ]; then
+                       echo "Not supported for non-flat EI api"
+               else
+                       query="/A1-EI/v1/eijobs/$job"
+                       res="$(__do_curl_to_api ECS DELETE $query)"
+                       status=${res:${#res}-3}
+                       if [ $status -ne 204 ]; then
+                               __log_test_fail_status_code $1 $status
+                               return 1
+                       fi
+                       echo " Deleted job: "$job
+               fi
+       done
+
+       __log_test_pass
+       return 0
+}
+
+##########################################
+####     Reset jobs and producers     ####
+##########################################
+
+
+# Admin reset to remove all data in ecs; jobs, producers etc
+# NOTE - only works in kubernetes and the pod should not be running
+# args: -
+# (Function for test scripts)
+
+ecs_kube_pvc_reset() {
+       __log_test_start $@
+
+       pvc_name=$(kubectl get pvc -n $KUBE_NONRTRIC_NAMESPACE  --no-headers -o custom-columns=":metadata.name" | grep enrichment)
+       if [ -z "$pvc_name" ]; then
+               pvc_name=enrichmentservice-pvc
+       fi
+       echo " Trying to reset pvc: "$pvc_name
+
+       __kube_clean_pvc $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE $pvc_name $ECS_CONTAINER_MNT_DIR
 
        __log_test_pass
        return 0