3 # ============LICENSE_START===============================================
4 # Copyright (C) 2020 Nordix Foundation. All rights reserved.
5 # ========================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END=================================================
20 # This is a script that contains container/service management functions and test functions for ECS
22 ################ Test engine functions ################
24 # Create the image var used during the test
25 # arg: <image-tag-suffix> (selects staging, snapshot, release etc)
26 # <image-tag-suffix> is present only for images with staging, snapshot,release tags
28 __check_and_create_image_var ECS "ECS_IMAGE" "ECS_IMAGE_BASE" "ECS_IMAGE_TAG" $1 "$ECS_DISPLAY_NAME"
31 # Pull image from remote repo or use locally built image
32 # arg: <pull-policy-override> <pull-policy-original>
33 # <pull-policy-override> Shall be used for images allowing overriding. For example use a local image when test is started to use released images
34 # <pull-policy-original> Shall be used for images that does not allow overriding
35 # Both var may contain: 'remote', 'remote-remove' or 'local'
37 __check_and_pull_image $1 "$ECS_DISPLAY_NAME" $ECS_APP_NAME ECS_IMAGE
40 # Build image (only for simulator or interfaces stubs owned by the test environment)
41 # arg: <image-tag-suffix> (selects staging, snapshot, release etc)
42 # <image-tag-suffix> is present only for images with staging, snapshot,release tags
44 echo -e $RED" Image for app ECS shall never be built"$ERED
47 # Generate a string for each included image using the app display name and a docker images format string
48 # If a custom image repo is used then also the source image from the local repo is listed
49 # arg: <docker-images-format-string> <file-to-append>
51 echo -e "$ECS_DISPLAY_NAME\t$(docker images --format $1 $ECS_IMAGE)" >> $2
52 if [ ! -z "$ECS_IMAGE_SOURCE" ]; then
53 echo -e "-- source image --\t$(docker images --format $1 $ECS_IMAGE_SOURCE)" >> $2
57 # Scale kubernetes resources to zero
58 # All resources shall be ordered to be scaled to 0, if relevant. If not relevant to scale, then do no action.
59 # This function is called for apps fully managed by the test script
60 __ECS_kube_scale_zero() {
61 __kube_scale_all_resources $KUBE_NONRTRIC_NAMESPACE autotest ECS
64 # Scale kubernetes resources to zero and wait until this has been accomplished, if relevant. If not relevant to scale, then do no action.
65 # This function is called for prestarted apps not managed by the test script.
66 __ECS_kube_scale_zero_and_wait() {
67 __kube_scale_and_wait_all_resources $KUBE_NONRTRIC_NAMESPACE app "$KUBE_NONRTRIC_NAMESPACE"-enrichmentservice
70 # Delete all kube resouces for the app
71 # This function is called for apps managed by the test script.
72 __ECS_kube_delete_all() {
73 __kube_delete_all_resources $KUBE_NONRTRIC_NAMESPACE autotest ECS
77 # This function is called for apps managed by the test script.
78 # args: <log-dir> <file-prexix>
79 __ECS_store_docker_logs() {
80 if [ $RUNMODE == "KUBE" ]; then
81 kubectl logs -l "autotest=ECS" -n $KUBE_NONRTRIC_NAMESPACE --tail=-1 > $1$2_ecs.log 2>&1
83 docker logs $ECS_APP_NAME > $1$2_ecs.log 2>&1
87 # Initial setup of protocol, host and ports
88 # This function is called for apps managed by the test script.
90 __ECS_initial_setup() {
94 # Set app short-name, app name and namespace for logging runtime statistics of kubernets pods or docker containers
95 # For docker, the namespace shall be excluded
96 # This function is called for apps managed by the test script as well as for prestarted apps.
98 __ECS_statisics_setup() {
99 if [ $RUNMODE == "KUBE" ]; then
100 echo "ECS $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE"
102 echo "ECS $ECS_APP_NAME"
106 #######################################################
109 # Make curl retries towards ECS for http response codes set in this env var, space separated list of codes
112 #Save first worker node the pod is started on
115 ###########################
117 ###########################
119 # All calls to ECS will be directed to the ECS REST interface from now on
121 # (Function for test scripts)
122 use_ecs_rest_http() {
123 __ecs_set_protocoll "http" $ECS_INTERNAL_PORT $ECS_EXTERNAL_PORT
126 # All calls to ECS will be directed to the ECS REST interface from now on
128 # (Function for test scripts)
129 use_ecs_rest_https() {
130 __ecs_set_protocoll "https" $ECS_INTERNAL_SECURE_PORT $ECS_EXTERNAL_SECURE_PORT
133 # All calls to ECS will be directed to the ECS dmaap interface over http from now on
135 # (Function for test scripts)
136 use_ecs_dmaap_http() {
137 echo -e $BOLD"ECS dmaap protocol setting"$EBOLD
138 echo -e $RED" - NOT SUPPORTED - "$ERED
139 echo -e " Using $BOLD http $EBOLD and $BOLD DMAAP $EBOLD towards ECS"
140 ECS_ADAPTER_TYPE="MR-HTTP"
144 # Setup paths to svc/container for internal and external access
145 # args: <protocol> <internal-port> <external-port>
146 __ecs_set_protocoll() {
147 echo -e $BOLD"$ECS_DISPLAY_NAME protocol setting"$EBOLD
148 echo -e " Using $BOLD http $EBOLD towards $ECS_DISPLAY_NAME"
152 ECS_SERVICE_PATH=$1"://"$ECS_APP_NAME":"$2 # docker access, container->container and script->container via proxy
153 if [ $RUNMODE == "KUBE" ]; then
154 ECS_SERVICE_PATH=$1"://"$ECS_APP_NAME.$KUBE_NONRTRIC_NAMESPACE":"$3 # kube access, pod->svc and script->svc via proxy
157 # ECS_ADAPTER used for switching between REST and DMAAP (only REST supported currently)
158 ECS_ADAPTER_TYPE="REST"
159 ECS_ADAPTER=$ECS_SERVICE_PATH
164 # Export env vars for config files, docker compose and kube resources
165 # args: PROXY|NOPROXY
166 __ecs_export_vars() {
168 export ECS_APP_NAME_ALIAS
169 export KUBE_NONRTRIC_NAMESPACE
171 export ECS_INTERNAL_PORT
172 export ECS_INTERNAL_SECURE_PORT
173 export ECS_EXTERNAL_PORT
174 export ECS_EXTERNAL_SECURE_PORT
175 export ECS_CONFIG_MOUNT_PATH
176 export ECS_CONFIG_CONFIGMAP_NAME=$ECS_APP_NAME"-config"
177 export ECS_DATA_CONFIGMAP_NAME=$ECS_APP_NAME"-data"
178 export ECS_CONTAINER_MNT_DIR
179 export ECS_HOST_MNT_DIR
180 export ECS_CONFIG_FILE
181 export DOCKER_SIM_NWNAME
182 export ECS_DISPLAY_NAME
185 export ECS_DATA_PV_NAME=$ECS_APP_NAME"-pv"
186 export ECS_DATA_PVC_NAME=$ECS_APP_NAME"-pvc"
187 #Create a unique path for the pv each time to prevent a previous volume to be reused
188 export ECS_PV_PATH="ecsdata-"$(date +%s)
190 if [ $1 == "PROXY" ]; then
191 export ECS_HTTP_PROXY_CONFIG_PORT=$HTTP_PROXY_CONFIG_PORT #Set if proxy is started
192 export ECS_HTTP_PROXY_CONFIG_HOST_NAME=$HTTP_PROXY_CONFIG_HOST_NAME #Set if proxy is started
193 if [ $ECS_HTTP_PROXY_CONFIG_PORT -eq 0 ] || [ -z "$ECS_HTTP_PROXY_CONFIG_HOST_NAME" ]; then
194 echo -e $YELLOW" Warning: HTTP PROXY will not be configured, proxy app not started"$EYELLOW
196 echo " Configured with http proxy"
199 export ECS_HTTP_PROXY_CONFIG_PORT=0
200 export ECS_HTTP_PROXY_CONFIG_HOST_NAME=""
201 echo " Configured without http proxy"
207 # args: PROXY|NOPROXY <config-file>
208 # (Function for test scripts)
211 echo -e $BOLD"Starting $ECS_DISPLAY_NAME"$EBOLD
213 if [ $RUNMODE == "KUBE" ]; then
215 # Check if app shall be fully managed by the test script
216 __check_included_image "ECS"
219 # Check if app shall only be used by the testscipt
220 __check_prestarted_image "ECS"
223 if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then
224 echo -e $RED"The $ECS_APP_NAME app is not included as managed nor prestarted in this test script"$ERED
225 echo -e $RED"The $ECS_APP_NAME will not be started"$ERED
228 if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then
229 echo -e $RED"The $ECS_APP_NAME app is included both as managed and prestarted in this test script"$ERED
230 echo -e $RED"The $ECS_APP_NAME will not be started"$ERED
235 if [ $retcode_p -eq 0 ]; then
236 echo -e " Using existing $ECS_APP_NAME deployment and service"
237 echo " Setting ECS replicas=1"
238 res_type=$(__kube_get_resource_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
239 __kube_scale $res_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
242 # Check if app shall be fully managed by the test script
243 if [ $retcode_i -eq 0 ]; then
244 echo -e " Creating $ECS_APP_NAME app and expose service"
246 #Check if nonrtric namespace exists, if not create it
247 __kube_create_namespace $KUBE_NONRTRIC_NAMESPACE
251 # Create config map for config
252 datafile=$PWD/tmp/$ECS_CONFIG_FILE
254 output_yaml=$PWD/tmp/ecs_cfc.yaml
255 __kube_create_configmap $ECS_CONFIG_CONFIGMAP_NAME $KUBE_NONRTRIC_NAMESPACE autotest ECS $datafile $output_yaml
258 input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"pv.yaml
259 output_yaml=$PWD/tmp/ecs_pv.yaml
260 __kube_create_instance pv $ECS_APP_NAME $input_yaml $output_yaml
263 input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"pvc.yaml
264 output_yaml=$PWD/tmp/ecs_pvc.yaml
265 __kube_create_instance pvc $ECS_APP_NAME $input_yaml $output_yaml
268 input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"svc.yaml
269 output_yaml=$PWD/tmp/ecs_svc.yaml
270 __kube_create_instance service $ECS_APP_NAME $input_yaml $output_yaml
273 input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"app.yaml
274 output_yaml=$PWD/tmp/ecs_app.yaml
275 __kube_create_instance app $ECS_APP_NAME $input_yaml $output_yaml
278 # 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
279 # 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
281 # 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
282 if [ $retcode_i -eq 0 ]; then
283 __ECS_WORKER_NODE=$(kubectl get pod -l "autotest=ECS" -n $KUBE_NONRTRIC_NAMESPACE -o jsonpath='{.items[*].spec.nodeName}')
284 if [ -z "$__ECS_WORKER_NODE" ]; then
285 echo -e $YELLOW" Cannot find worker node for pod for $ECS_APP_NAME, persistency may not work"$EYELLOW
288 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
292 __check_service_start $ECS_APP_NAME $ECS_SERVICE_PATH$ECS_ALIVE_URL
295 __check_included_image 'ECS'
296 if [ $? -eq 1 ]; then
297 echo -e $RED"The ECS app is not included in this test script"$ERED
298 echo -e $RED"ECS will not be started"$ERED
308 if [ "$(ls -A $DIR)" ]; then
309 echo -e $BOLD" Cleaning files in mounted dir: $PWD/db"$EBOLD
310 rm -rf db/* &> /dev/null
311 if [ $? -ne 0 ]; then
312 echo -e $RED" Cannot remove database files in: $PWD"$ERED
317 echo " No files in mounted dir or dir does not exists"
324 dest_file=$SIM_GROUP/$ECS_COMPOSE_DIR/$ECS_HOST_MNT_DIR/$ECS_CONFIG_FILE
326 envsubst < $2 > $dest_file
328 __start_container $ECS_COMPOSE_DIR "" NODOCKERARGS 1 $ECS_APP_NAME
330 __check_service_start $ECS_APP_NAME $ECS_SERVICE_PATH$ECS_ALIVE_URL
339 # (Function for test scripts)
341 echo -e $BOLD"Stopping $ECS_DISPLAY_NAME"$EBOLD
343 if [ $RUNMODE == "KUBE" ]; then
345 __check_prestarted_image "ECS"
346 if [ $? -eq 0 ]; then
347 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
348 res_type=$(__kube_get_resource_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
349 __kube_scale $res_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 0
353 __kube_scale_all_resources $KUBE_NONRTRIC_NAMESPACE autotest ECS
354 echo " Deleting the replica set - a new will be started when the app is started"
355 tmp=$(kubectl delete rs -n $KUBE_NONRTRIC_NAMESPACE -l "autotest=ECS")
356 if [ $? -ne 0 ]; then
357 echo -e $RED" Could not delete replica set "$RED
362 docker stop $ECS_APP_NAME &> ./tmp/.dockererr
363 if [ $? -ne 0 ]; then
364 __print_err "Could not stop $ECS_APP_NAME" $@
370 echo -e $BOLD$GREEN"Stopped"$EGREEN$EBOLD
375 # Start a previously stopped ecs
377 # (Function for test scripts)
378 start_stopped_ecs() {
379 echo -e $BOLD"Starting (the previously stopped) $ECS_DISPLAY_NAME"$EBOLD
381 if [ $RUNMODE == "KUBE" ]; then
383 __check_prestarted_image "ECS"
384 if [ $? -eq 0 ]; then
385 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
386 res_type=$(__kube_get_resource_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
387 __kube_scale $res_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
388 __check_service_start $ECS_APP_NAME $ECS_SERVICE_PATH$ECS_ALIVE_URL
392 # Tie the PMS to the same worker node it was initially started on
393 # 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
394 if [ -z "$__ECS_WORKER_NODE" ]; then
395 echo -e $RED" No initial worker node found for pod "$RED
399 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
400 echo -e $BOLD" The mounted volume is mounted as hostPath and only available on that worker node."$BOLD
401 tmp=$(kubectl patch deployment $ECS_APP_NAME -n $KUBE_NONRTRIC_NAMESPACE --patch '{"spec": {"template": {"spec": {"nodeSelector": {"kubernetes.io/hostname": "'$__ECS_WORKER_NODE'"}}}}}')
402 if [ $? -ne 0 ]; then
403 echo -e $YELLOW" Cannot set nodeSelector to deployment for $ECS_APP_NAME, persistency may not work"$EYELLOW
405 __kube_scale deployment $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
408 docker start $ECS_APP_NAME &> ./tmp/.dockererr
409 if [ $? -ne 0 ]; then
410 __print_err "Could not start (the stopped) $ECS_APP_NAME" $@
416 __check_service_start $ECS_APP_NAME $ECS_SERVICE_PATH$ECS_ALIVE_URL
417 if [ $? -ne 0 ]; then
424 # Turn on debug level tracing in ECS
426 # (Function for test scripts)
428 echo -e $BOLD"Setting ecs debug logging"$EBOLD
429 curlString="$ECS_SERVICE_PATH$ECS_ACTUATOR -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"debug\"}"
430 result=$(__do_curl "$curlString")
431 if [ $? -ne 0 ]; then
432 __print_err "Could not set debug mode" $@
440 # Turn on trace level tracing in ECS
442 # (Function for test scripts)
444 echo -e $BOLD"Setting ecs trace logging"$EBOLD
445 curlString="$ECS_SERVICE_PATH/actuator/loggers/org.oransc.enrichment -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}"
446 result=$(__do_curl "$curlString")
447 if [ $? -ne 0 ]; then
448 __print_err "Could not set trace mode" $@
456 # Perform curl retries when making direct call to ECS for the specified http response codes
457 # Speace separated list of http response codes
458 # args: [<response-code>]*
460 echo -e $BOLD"Do curl retries to the ECS REST inteface for these response codes:$@"$EBOLD
466 # Check the ecs logs for WARNINGs and ERRORs
468 # (Function for test scripts)
470 __check_container_logs "ECS" $ECS_APP_NAME $ECS_LOGPATH WARN ERR
474 # Tests if a variable value in the ECS is equal to a target value and and optional timeout.
475 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
476 # equal to the target or not.
477 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
478 # before setting pass or fail depending on if the variable value becomes equal to the target
480 # (Function for test scripts)
482 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
483 __var_test ECS "$ECS_SERVICE_PATH/" $1 "=" $2 $3
485 __print_err "Wrong args to ecs_equal, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
490 ##########################################
491 ######### A1-E Enrichment API ##########
492 ##########################################
493 #Function prefix: ecs_api_a1
495 # API Test function: GET /A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs
496 # args: <response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
497 # args (flat uri structure): <response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
498 # (Function for test scripts)
499 ecs_api_a1_get_job_ids() {
502 if [ -z "$FLAT_A1_EI" ]; then
503 # Valid number of parameters 4,5,6 etc
504 if [ $# -lt 3 ]; then
505 __print_err "<response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
509 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
510 # Valid number of parameters 4,5,6 etc
511 if [ $# -lt 3 ]; then
512 __print_err "<response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
517 if [ $3 != "NOWNER" ]; then
521 if [ -z "$FLAT_A1_EI" ]; then
522 query="/A1-EI/v1/eitypes/$2/eijobs$search"
524 if [ $2 != "NOTYPE" ]; then
525 if [ -z "$search" ]; then
526 search="?eiTypeId="$2
528 search=$search"&eiTypeId="$2
531 query="/A1-EI/v1/eijobs$search"
533 res="$(__do_curl_to_api ECS GET $query)"
534 status=${res:${#res}-3}
536 if [ $status -ne $1 ]; then
537 __log_test_fail_status_code $1 $status
541 if [ $# -gt 3 ]; then
542 body=${res:0:${#res}-3}
545 for pid in ${@:4} ; do
546 if [ "$targetJson" != "[" ]; then
547 targetJson=$targetJson","
549 if [ $pid != "EMPTY" ]; then
550 targetJson=$targetJson"\"$pid\""
554 targetJson=$targetJson"]"
555 echo " TARGET JSON: $targetJson" >> $HTTPLOG
556 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
558 if [ $res -ne 0 ]; then
568 # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}
569 # args: <response-code> <type-id> [<schema-file>]
570 # (Function for test scripts)
571 ecs_api_a1_get_type() {
574 if [ $# -lt 2 ] || [ $# -gt 3 ]; then
575 __print_err "<response-code> <type-id> [<schema-file>]" $@
579 query="/A1-EI/v1/eitypes/$2"
580 res="$(__do_curl_to_api ECS GET $query)"
581 status=${res:${#res}-3}
583 if [ $status -ne $1 ]; then
584 __log_test_fail_status_code $1 $status
588 if [ $# -eq 3 ]; then
589 body=${res:0:${#res}-3}
593 __log_test_fail_general "Schema file "$3", does not exist"
596 if [ -z "$FLAT_A1_EI" ]; then
597 targetJson="{\"eiJobParametersSchema\":$schema}"
601 echo " TARGET JSON: $targetJson" >> $HTTPLOG
602 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
604 if [ $res -ne 0 ]; then
614 # API Test function: GET /A1-EI/v1/eitypes
615 # args: <response-code> [ (EMPTY | [<type-id>]+) ]
616 # (Function for test scripts)
617 ecs_api_a1_get_type_ids() {
620 if [ $# -lt 1 ]; then
621 __print_err "<response-code> [ (EMPTY | [<type-id>]+) ]" $@
625 query="/A1-EI/v1/eitypes"
626 res="$(__do_curl_to_api ECS GET $query)"
627 status=${res:${#res}-3}
629 if [ $status -ne $1 ]; then
630 __log_test_fail_status_code $1 $status
633 if [ $# -gt 1 ]; then
634 body=${res:0:${#res}-3}
636 if [ $2 != "EMPTY" ]; then
637 for pid in ${@:2} ; do
638 if [ "$targetJson" != "[" ]; then
639 targetJson=$targetJson","
641 targetJson=$targetJson"\"$pid\""
644 targetJson=$targetJson"]"
645 echo " TARGET JSON: $targetJson" >> $HTTPLOG
646 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
648 if [ $res -ne 0 ]; then
658 # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}​/status
659 # args: <response-code> <type-id> <job-id> [<status>]
660 # args (flat uri structure): <response-code> <job-id> [<status> [<timeout>]]
661 # (Function for test scripts)
662 ecs_api_a1_get_job_status() {
665 if [ -z "$FLAT_A1_EI" ]; then
666 if [ $# -ne 3 ] && [ $# -ne 4 ]; then
667 __print_err "<response-code> <type-id> <job-id> [<status>]" $@
671 query="/A1-EI/v1/eitypes/$2/eijobs/$3/status"
673 res="$(__do_curl_to_api ECS GET $query)"
674 status=${res:${#res}-3}
676 if [ $status -ne $1 ]; then
677 __log_test_fail_status_code $1 $status
680 if [ $# -eq 4 ]; then
681 body=${res:0:${#res}-3}
682 targetJson="{\"operationalState\": \"$4\"}"
683 echo " TARGET JSON: $targetJson" >> $HTTPLOG
684 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
686 if [ $res -ne 0 ]; then
692 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
693 if [ $# -lt 2 ] && [ $# -gt 4 ]; then
694 __print_err "<response-code> <job-id> [<status> [<timeout>]]" $@
698 query="/A1-EI/v1/eijobs/$2/status"
702 res="$(__do_curl_to_api ECS GET $query)"
703 status=${res:${#res}-3}
705 if [ $# -eq 4 ]; then
706 duration=$((SECONDS-start))
707 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
708 if [ $duration -gt $4 ]; then
710 duration=-1 #Last iteration
713 duration=-1 #single test, no wait
716 if [ $status -ne $1 ]; then
717 if [ $duration -eq -1 ]; then
718 __log_test_fail_status_code $1 $status
722 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
723 body=${res:0:${#res}-3}
724 targetJson="{\"eiJobStatus\": \"$3\"}"
725 echo " TARGET JSON: $targetJson" >> $HTTPLOG
726 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
728 if [ $res -ne 0 ]; then
729 if [ $duration -eq -1 ]; then
734 duration=-1 #Goto pass
737 if [ $duration -eq -1 ]; then
738 if [ $# -eq 4 ]; then
753 # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
754 # args: <response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]
755 # args (flat uri structure): <response-code> <job-id> [<type-id> <target-url> <owner-id> <template-job-file>]
756 # (Function for test scripts)
757 ecs_api_a1_get_job() {
760 if [ -z "$FLAT_A1_EI" ]; then
761 if [ $# -ne 3 ] && [ $# -ne 6 ]; then
762 __print_err "<response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]" $@
765 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
767 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
768 if [ $# -ne 2 ] && [ $# -ne 7 ]; then
769 __print_err "<response-code> <job-id> [<type-id> <target-url> <owner-id> <notification-url> <template-job-file>]" $@
772 query="/A1-EI/v1/eijobs/$2"
774 res="$(__do_curl_to_api ECS GET $query)"
775 status=${res:${#res}-3}
777 if [ $status -ne $1 ]; then
778 __log_test_fail_status_code $1 $status
782 if [ -z "$FLAT_A1_EI" ]; then
783 if [ $# -eq 6 ]; then
784 body=${res:0:${#res}-3}
788 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
790 __log_test_fail_general "Job template file "$6", does not exist"
793 targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
794 echo " TARGET JSON: $targetJson" >> $HTTPLOG
795 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
797 if [ $res -ne 0 ]; then
803 if [ $# -eq 7 ]; then
804 body=${res:0:${#res}-3}
808 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
810 __log_test_fail_general "Job template file "$6", does not exist"
813 targetJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
814 echo " TARGET JSON: $targetJson" >> $HTTPLOG
815 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
817 if [ $res -ne 0 ]; then
828 # API Test function: DELETE ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
829 # args: <response-code> <type-id> <job-id>
830 # args (flat uri structure): <response-code> <job-id>
831 # (Function for test scripts)
832 ecs_api_a1_delete_job() {
835 if [ -z "$FLAT_A1_EI" ]; then
836 if [ $# -ne 3 ]; then
837 __print_err "<response-code> <type-id> <job-id>" $@
841 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
843 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
844 if [ $# -ne 2 ]; then
845 __print_err "<response-code> <job-id>" $@
848 query="/A1-EI/v1/eijobs/$2"
850 res="$(__do_curl_to_api ECS DELETE $query)"
851 status=${res:${#res}-3}
853 if [ $status -ne $1 ]; then
854 __log_test_fail_status_code $1 $status
862 # API Test function: PUT ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
863 # args: <response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>
864 # args (flat uri structure): <response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file>
865 # (Function for test scripts)
866 ecs_api_a1_put_job() {
869 if [ -z "$FLAT_A1_EI" ]; then
870 if [ $# -lt 6 ]; then
871 __print_err "<response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>" $@
876 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
878 __log_test_fail_general "Job template file "$6", does not exist"
882 inputJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
884 echo "$inputJson" > $file
886 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
888 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
889 if [ $# -lt 7 ]; then
890 __print_err "<response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file>" $@
895 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
897 __log_test_fail_general "Job template file "$7", does not exist"
901 inputJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
903 echo "$inputJson" > $file
905 query="/A1-EI/v1/eijobs/$2"
908 res="$(__do_curl_to_api ECS PUT $query $file)"
909 status=${res:${#res}-3}
911 if [ $status -ne $1 ]; then
912 __log_test_fail_status_code $1 $status
921 ##########################################
922 #### Enrichment Data Producer API ####
923 ##########################################
924 # Function prefix: ecs_api_edp
926 # API Test function: GET /ei-producer/v1/eitypes
927 # API Test function: GET /data-producer/v1/info-types
928 # args: <response-code> [ EMPTY | <type-id>+]
929 # (Function for test scripts)
930 ecs_api_edp_get_type_ids() {
933 if [ $# -lt 1 ]; then
934 __print_err "<response-code> [ EMPTY | <type-id>+]" $@
937 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
938 query="/data-producer/v1/info-types"
940 query="/ei-producer/v1/eitypes"
942 res="$(__do_curl_to_api ECS GET $query)"
943 status=${res:${#res}-3}
945 if [ $status -ne $1 ]; then
946 __log_test_fail_status_code $1 $status
950 if [ $# -gt 1 ]; then
951 body=${res:0:${#res}-3}
953 if [ $2 != "EMPTY" ]; then
954 for pid in ${@:2} ; do
955 if [ "$targetJson" != "[" ]; then
956 targetJson=$targetJson","
958 targetJson=$targetJson"\"$pid\""
961 targetJson=$targetJson"]"
962 echo " TARGET JSON: $targetJson" >> $HTTPLOG
963 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
965 if [ $res -ne 0 ]; then
975 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/status
976 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}/status
977 # args: <response-code> <producer-id> [<status> [<timeout>]]
978 # (Function for test scripts)
979 ecs_api_edp_get_producer_status() {
982 if [ $# -lt 2 ] || [ $# -gt 4 ]; then
983 __print_err "<response-code> <producer-id> [<status> [<timeout>]]" $@
986 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
987 query="/data-producer/v1/info-producers/$2/status"
989 query="/ei-producer/v1/eiproducers/$2/status"
993 res="$(__do_curl_to_api ECS GET $query)"
994 status=${res:${#res}-3}
996 if [ $# -eq 4 ]; then
997 duration=$((SECONDS-start))
998 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
999 if [ $duration -gt $4 ]; then
1001 duration=-1 #Last iteration
1004 duration=-1 #single test, no wait
1007 if [ $status -ne $1 ]; then
1008 if [ $duration -eq -1 ]; then
1009 __log_test_fail_status_code $1 $status
1013 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
1014 body=${res:0:${#res}-3}
1015 targetJson="{\"operational_state\": \"$3\"}"
1016 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1017 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1019 if [ $res -ne 0 ]; then
1020 if [ $duration -eq -1 ]; then
1021 __log_test_fail_body
1025 duration=-1 #Goto pass
1028 if [ $duration -eq -1 ]; then
1029 if [ $# -eq 4 ]; then
1041 # API Test function: GET /ei-producer/v1/eiproducers
1042 # args (v1_1): <response-code> [ EMPTY | <producer-id>+]
1043 # (Function for test scripts)
1044 ecs_api_edp_get_producer_ids() {
1047 if [ $# -lt 1 ]; then
1048 __print_err "<response-code> [ EMPTY | <producer-id>+]" $@
1052 query="/ei-producer/v1/eiproducers"
1053 res="$(__do_curl_to_api ECS GET $query)"
1054 status=${res:${#res}-3}
1056 if [ $status -ne $1 ]; then
1057 __log_test_fail_status_code $1 $status
1061 if [ $# -gt 1 ]; then
1062 body=${res:0:${#res}-3}
1065 for pid in ${@:2} ; do
1066 if [ "$targetJson" != "[" ]; then
1067 targetJson=$targetJson","
1069 if [ $pid != "EMPTY" ]; then
1070 targetJson=$targetJson"\"$pid\""
1074 targetJson=$targetJson"]"
1075 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1076 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1078 if [ $res -ne 0 ]; then
1079 __log_test_fail_body
1088 # API Test function: GET /ei-producer/v1/eiproducers
1089 # API Test function: GET /data-producer/v1/info-producers
1090 # args (v1_2): <response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]
1091 # (Function for test scripts)
1092 ecs_api_edp_get_producer_ids_2() {
1095 if [ $# -lt 1 ]; then
1096 __print_err "<response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]" $@
1099 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1100 query="/data-producer/v1/info-producers"
1101 if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then
1102 query=$query"?info_type_id=$2"
1105 query="/ei-producer/v1/eiproducers"
1106 if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then
1107 query=$query"?ei_type_id=$2"
1110 res="$(__do_curl_to_api ECS GET $query)"
1111 status=${res:${#res}-3}
1113 if [ $status -ne $1 ]; then
1114 __log_test_fail_status_code $1 $status
1118 if [ $# -gt 2 ]; then
1119 body=${res:0:${#res}-3}
1122 for pid in ${@:3} ; do
1123 if [ "$targetJson" != "[" ]; then
1124 targetJson=$targetJson","
1126 if [ $pid != "EMPTY" ]; then
1127 targetJson=$targetJson"\"$pid\""
1131 targetJson=$targetJson"]"
1132 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1133 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1135 if [ $res -ne 0 ]; then
1136 __log_test_fail_body
1145 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
1146 # args: (v1_1) <response-code> <type-id> [<job-schema-file> (EMPTY | [<producer-id>]+)]
1147 # (Function for test scripts)
1148 ecs_api_edp_get_type() {
1152 if [ $# -eq 2 ]; then
1155 if [ $# -gt 3 ]; then
1158 if [ $paramError -ne 0 ]; then
1159 __print_err "<response-code> <type-id> [<job-schema-file> 'EMPTY' | ([<producer-id>]+)]" $@
1163 query="/ei-producer/v1/eitypes/$2"
1164 res="$(__do_curl_to_api ECS GET $query)"
1165 status=${res:${#res}-3}
1167 if [ $status -ne $1 ]; then
1168 __log_test_fail_status_code $1 $status
1171 if [ $# -gt 3 ]; then
1172 body=${res:0:${#res}-3}
1177 __log_test_fail_general "Job template file "$3", does not exist"
1182 if [ $4 != "EMPTY" ]; then
1183 for pid in ${@:4} ; do
1184 if [ "$targetJson" != "" ]; then
1185 targetJson=$targetJson","
1187 targetJson=$targetJson"\"$pid\""
1190 targetJson="{\"ei_job_data_schema\":$schema, \"ei_producer_ids\": [$targetJson]}"
1192 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1193 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1195 if [ $res -ne 0 ]; then
1196 __log_test_fail_body
1204 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
1205 # API Test function: GET /data-producer/v1/info-types/{infoTypeId}
1206 # args: (v1_2) <response-code> <type-id> [<job-schema-file> [ <info-type-info> ]]
1207 # (Function for test scripts)
1208 ecs_api_edp_get_type_2() {
1212 if [ $# -eq 2 ]; then
1215 if [ $# -eq 3 ]; then
1218 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then
1219 if [ $# -eq 4 ]; then
1223 if [ $paramError -ne 0 ]; then
1224 __print_err "<response-code> <type-id> [<job-schema-file> [ <info-type-info> ]]" $@
1227 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1228 query="/data-producer/v1/info-types/$2"
1230 query="/ei-producer/v1/eitypes/$2"
1233 res="$(__do_curl_to_api ECS GET $query)"
1234 status=${res:${#res}-3}
1236 if [ $status -ne $1 ]; then
1237 __log_test_fail_status_code $1 $status
1240 if [ $# -ge 3 ]; then
1241 body=${res:0:${#res}-3}
1246 __log_test_fail_general "Job template file "$3", does not exist"
1250 if [ $# -gt 3 ]; then
1254 __log_test_fail_general "Info-data file "$4", does not exist"
1257 info_data=",\"info_type_information\":$info_data"
1259 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1260 targetJson="{\"info_job_data_schema\":$schema $info_data}"
1262 targetJson="{\"ei_job_data_schema\":$schema}"
1265 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1266 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1268 if [ $res -ne 0 ]; then
1269 __log_test_fail_body
1277 # API Test function: PUT /ei-producer/v1/eitypes/{eiTypeId}
1278 # API Test function: PUT /data-producer/v1/info-types/{infoTypeId}
1279 # args: (v1_2) <response-code> <type-id> <job-schema-file> [ <info-type-info> ]
1280 # (Function for test scripts)
1281 ecs_api_edp_put_type_2() {
1284 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then
1285 if [ $# -lt 3 ] || [ $# -gt 4 ]; then
1286 __print_err "<response-code> <type-id> <job-schema-file> [ <info-type-info> ]" $@
1290 if [ $# -ne 3 ]; then
1291 __print_err "<response-code> <type-id> <job-schema-file>" $@
1296 if [ ! -f $3 ]; then
1297 __log_test_fail_general "Job schema file "$3", does not exist"
1302 if [ $# -gt 3 ]; then
1306 __log_test_fail_general "Info-data file "$4", does not exist"
1309 info_data=",\"info_type_information\":$info_data"
1312 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1314 input_json="{\"info_job_data_schema\":$schema $info_data}"
1315 file="./tmp/put_type.json"
1316 echo $input_json > $file
1318 query="/data-producer/v1/info-types/$2"
1321 input_json="{\"ei_job_data_schema\":$schema}"
1322 file="./tmp/put_type.json"
1323 echo $input_json > $file
1325 query="/ei-producer/v1/eitypes/$2"
1327 res="$(__do_curl_to_api ECS PUT $query $file)"
1328 status=${res:${#res}-3}
1330 if [ $status -ne $1 ]; then
1331 __log_test_fail_status_code $1 $status
1339 # API Test function: DELETE /ei-producer/v1/eitypes/{eiTypeId}
1340 # API Test function: DELETE /data-producer/v1/info-types/{infoTypeId}
1341 # args: (v1_2) <response-code> <type-id>
1342 # (Function for test scripts)
1343 ecs_api_edp_delete_type_2() {
1346 if [ $# -ne 2 ]; then
1347 __print_err "<response-code> <type-id>" $@
1351 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1352 query="/data-producer/v1/info-types/$2"
1354 query="/ei-producer/v1/eitypes/$2"
1356 res="$(__do_curl_to_api ECS DELETE $query)"
1357 status=${res:${#res}-3}
1359 if [ $status -ne $1 ]; then
1360 __log_test_fail_status_code $1 $status
1368 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
1369 # args: (v1_1) <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | [<type-id> <schema-file>]+) ]
1370 # (Function for test scripts)
1371 ecs_api_edp_get_producer() {
1374 #Possible arg count: 2, 5 6, 8, 10 etc
1376 if [ $# -eq 2 ]; then
1379 if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then
1382 variablecount=$(($#-4))
1383 if [ $# -gt 5 ] && [ $(($variablecount%2)) -eq 0 ]; then
1387 if [ $paramError -ne 0 ]; then
1388 __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (NOID | [<type-id> <schema-file>]+) ]" $@
1392 query="/ei-producer/v1/eiproducers/$2"
1393 res="$(__do_curl_to_api ECS GET $query)"
1394 status=${res:${#res}-3}
1396 if [ $status -ne $1 ]; then
1397 __log_test_fail_status_code $1 $status
1401 if [ $# -gt 2 ]; then
1402 body=${res:0:${#res}-3}
1404 if [ $# -gt 5 ]; then
1406 for ((i=0; i<$(($#-5)); i=i+2)); do
1407 if [ "$targetJson" != "[" ]; then
1408 targetJson=$targetJson","
1410 if [ -f ${arr[$i+1]} ]; then
1411 schema=$(cat ${arr[$i+1]})
1413 __log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
1417 targetJson=$targetJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
1420 targetJson=$targetJson"]"
1421 if [ $# -gt 4 ]; then
1422 targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
1424 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1425 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1427 if [ $res -ne 0 ]; then
1428 __log_test_fail_body
1437 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
1438 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}
1439 # args (v1_2): <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]
1440 # (Function for test scripts)
1441 ecs_api_edp_get_producer_2() {
1444 #Possible arg count: 2, 5, 6, 7, 8 etc
1446 if [ $# -eq 2 ]; then
1449 if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then
1452 if [ $# -ge 5 ]; then
1456 if [ $paramError -ne 0 ]; then
1457 __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]" $@
1460 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1461 query="/data-producer/v1/info-producers/$2"
1463 query="/ei-producer/v1/eiproducers/$2"
1465 res="$(__do_curl_to_api ECS GET $query)"
1466 status=${res:${#res}-3}
1468 if [ $status -ne $1 ]; then
1469 __log_test_fail_status_code $1 $status
1473 if [ $# -gt 2 ]; then
1474 body=${res:0:${#res}-3}
1476 if [ $# -gt 4 ] && [ "$5" != "EMPTY" ]; then
1478 for ((i=0; i<$(($#-4)); i=i+1)); do
1479 if [ "$targetJson" != "[" ]; then
1480 targetJson=$targetJson","
1482 targetJson=$targetJson"\"${arr[$i]}\""
1485 targetJson=$targetJson"]"
1486 if [ $# -gt 4 ]; then
1487 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1488 targetJson="{\"supported_info_types\":$targetJson,\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\"}"
1490 targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
1493 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1494 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1496 if [ $res -ne 0 ]; then
1497 __log_test_fail_body
1506 # API Test function: DELETE /ei-producer/v1/eiproducers/{eiProducerId}
1507 # API Test function: DELETE /data-producer/v1/info-producers/{infoProducerId}
1508 # args: <response-code> <producer-id>
1509 # (Function for test scripts)
1510 ecs_api_edp_delete_producer() {
1513 if [ $# -lt 2 ]; then
1514 __print_err "<response-code> <producer-id>" $@
1517 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1518 query="/data-producer/v1/info-producers/$2"
1520 query="/ei-producer/v1/eiproducers/$2"
1522 res="$(__do_curl_to_api ECS DELETE $query)"
1523 status=${res:${#res}-3}
1525 if [ $status -ne $1 ]; then
1526 __log_test_fail_status_code $1 $status
1534 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
1535 # args: (v1_1) <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+
1536 # (Function for test scripts)
1537 ecs_api_edp_put_producer() {
1540 #Valid number of parametrer 5,6,8,10,
1542 if [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then
1544 elif [ $# -gt 5 ] && [ $(($#%2)) -eq 0 ]; then
1547 if [ $paramError -ne 0 ]; then
1548 __print_err "<response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+" $@
1553 if [ $# -gt 5 ]; then
1555 for ((i=0; i<$(($#-5)); i=i+2)); do
1556 if [ "$inputJson" != "[" ]; then
1557 inputJson=$inputJson","
1559 if [ -f ${arr[$i+1]} ]; then
1560 schema=$(cat ${arr[$i+1]})
1562 __log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
1565 inputJson=$inputJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
1568 inputJson="\"supported_ei_types\":"$inputJson"]"
1570 inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
1572 inputJson="{"$inputJson"}"
1574 file="./tmp/.p.json"
1575 echo "$inputJson" > $file
1576 query="/ei-producer/v1/eiproducers/$2"
1577 res="$(__do_curl_to_api ECS PUT $query $file)"
1578 status=${res:${#res}-3}
1580 if [ $status -ne $1 ]; then
1581 __log_test_fail_status_code $1 $status
1589 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
1590 # API Test function: PUT /data-producer/v1/info-producers/{infoProducerId}
1591 # args: (v1_2) <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]
1592 # (Function for test scripts)
1593 ecs_api_edp_put_producer_2() {
1596 #Valid number of parametrer 5,6,8,10,
1598 if [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then
1600 elif [ $# -ge 5 ]; then
1603 if [ $paramError -ne 0 ]; then
1604 __print_err "<response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]" $@
1609 if [ $# -gt 4 ] && [ "$5" != "NOTYPE" ]; then
1611 for ((i=0; i<$(($#-4)); i=i+1)); do
1612 if [ "$inputJson" != "[" ]; then
1613 inputJson=$inputJson","
1615 inputJson=$inputJson"\""${arr[$i]}"\""
1618 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1619 inputJson="\"supported_info_types\":"$inputJson"]"
1621 inputJson=$inputJson",\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\""
1623 inputJson="{"$inputJson"}"
1625 file="./tmp/.p.json"
1626 echo "$inputJson" > $file
1627 query="/data-producer/v1/info-producers/$2"
1629 inputJson="\"supported_ei_types\":"$inputJson"]"
1631 inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
1633 inputJson="{"$inputJson"}"
1635 file="./tmp/.p.json"
1636 echo "$inputJson" > $file
1637 query="/ei-producer/v1/eiproducers/$2"
1639 res="$(__do_curl_to_api ECS PUT $query $file)"
1640 status=${res:${#res}-3}
1642 if [ $status -ne $1 ]; then
1643 __log_test_fail_status_code $1 $status
1651 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
1652 # args: (V1-1) <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)
1653 # (Function for test scripts)
1654 ecs_api_edp_get_producer_jobs() {
1657 #Valid number of parameter 2,3,7,11
1659 if [ $# -eq 2 ]; then
1662 if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
1665 variablecount=$(($#-2))
1666 if [ $# -gt 3 ] && [ $(($variablecount%5)) -eq 0 ]; then
1669 if [ $paramError -eq 1 ]; then
1670 __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)" $@
1674 query="/ei-producer/v1/eiproducers/$2/eijobs"
1675 res="$(__do_curl_to_api ECS GET $query)"
1676 status=${res:${#res}-3}
1677 if [ $status -ne $1 ]; then
1678 __log_test_fail_status_code $1 $status
1681 if [ $# -gt 2 ]; then
1682 body=${res:0:${#res}-3}
1684 if [ $# -gt 3 ]; then
1686 for ((i=0; i<$(($#-3)); i=i+5)); do
1687 if [ "$targetJson" != "[" ]; then
1688 targetJson=$targetJson","
1690 if [ -f ${arr[$i+4]} ]; then
1691 jobfile=$(cat ${arr[$i+4]})
1692 jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
1694 __log_test_fail_general "Job template file "${arr[$i+4]}", does not exist"
1697 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}"
1700 targetJson=$targetJson"]"
1702 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1703 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1705 if [ $res -ne 0 ]; then
1706 __log_test_fail_body
1715 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
1716 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}/info-jobs
1717 # args: (V1-2) <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)
1718 # (Function for test scripts)
1719 ecs_api_edp_get_producer_jobs_2() {
1722 #Valid number of parameter 2,3,7,11
1724 if [ $# -eq 2 ]; then
1727 if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
1730 variablecount=$(($#-2))
1731 if [ $# -gt 3 ] && [ $(($variablecount%5)) -eq 0 ]; then
1734 if [ $paramError -eq 1 ]; then
1735 __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)" $@
1738 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1739 query="/data-producer/v1/info-producers/$2/info-jobs"
1741 query="/ei-producer/v1/eiproducers/$2/eijobs"
1743 res="$(__do_curl_to_api ECS GET $query)"
1744 status=${res:${#res}-3}
1745 if [ $status -ne $1 ]; then
1746 __log_test_fail_status_code $1 $status
1749 if [ $# -gt 2 ]; then
1750 body=${res:0:${#res}-3}
1752 if [ $# -gt 3 ]; then
1754 for ((i=0; i<$(($#-3)); i=i+5)); do
1755 if [ "$targetJson" != "[" ]; then
1756 targetJson=$targetJson","
1758 if [ -f ${arr[$i+4]} ]; then
1759 jobfile=$(cat ${arr[$i+4]})
1760 jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
1762 __log_test_fail_general "Job template file "${arr[$i+4]}", does not exist"
1765 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1766 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\":\"????\"}"
1768 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\":\"????\"}"
1772 targetJson=$targetJson"]"
1774 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1775 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1777 if [ $res -ne 0 ]; then
1778 __log_test_fail_body
1787 ##########################################
1788 #### Service status ####
1789 ##########################################
1790 # Function prefix: ecs_api_service
1792 # API Test function: GET ​/status
1793 # args: <response-code>
1794 # (Function for test scripts)
1795 ecs_api_service_status() {
1798 if [ $# -lt 1 ]; then
1799 __print_err "<response-code>" $@
1802 res="$(__do_curl_to_api ECS GET /status)"
1803 status=${res:${#res}-3}
1804 if [ $status -ne $1 ]; then
1805 __log_test_fail_status_code $1 $status
1812 ###########################################
1813 ######### Info data consumer API ##########
1814 ###########################################
1815 #Function prefix: ecs_api_idc
1818 # API Test function: GET /data-consumer/v1/info-types
1819 # args: <response-code> [ (EMPTY | [<type-id>]+) ]
1820 # (Function for test scripts)
1821 ecs_api_idc_get_type_ids() {
1824 if [ $# -lt 1 ]; then
1825 __print_err "<response-code> [ (EMPTY | [<type-id>]+) ]" $@
1829 query="/data-consumer/v1/info-types"
1830 res="$(__do_curl_to_api ECS GET $query)"
1831 status=${res:${#res}-3}
1833 if [ $status -ne $1 ]; then
1834 __log_test_fail_status_code $1 $status
1837 if [ $# -gt 1 ]; then
1838 body=${res:0:${#res}-3}
1840 if [ $2 != "EMPTY" ]; then
1841 for pid in ${@:2} ; do
1842 if [ "$targetJson" != "[" ]; then
1843 targetJson=$targetJson","
1845 targetJson=$targetJson"\"$pid\""
1848 targetJson=$targetJson"]"
1849 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1850 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1852 if [ $res -ne 0 ]; then
1853 __log_test_fail_body
1862 # API Test function: GET /data-consumer/v1/info-jobs
1863 # args: <response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
1864 # (Function for test scripts)
1865 ecs_api_idc_get_job_ids() {
1868 # Valid number of parameters 4,5,6 etc
1869 if [ $# -lt 3 ]; then
1870 __print_err "<response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
1874 if [ $3 != "NOWNER" ]; then
1878 if [ $2 != "NOTYPE" ]; then
1879 if [ -z "$search" ]; then
1880 search="?infoTypeId="$2
1882 search=$search"&infoTypeId="$2
1885 query="/data-consumer/v1/info-jobs$search"
1887 res="$(__do_curl_to_api ECS GET $query)"
1888 status=${res:${#res}-3}
1890 if [ $status -ne $1 ]; then
1891 __log_test_fail_status_code $1 $status
1895 if [ $# -gt 3 ]; then
1896 body=${res:0:${#res}-3}
1899 for pid in ${@:4} ; do
1900 if [ "$targetJson" != "[" ]; then
1901 targetJson=$targetJson","
1903 if [ $pid != "EMPTY" ]; then
1904 targetJson=$targetJson"\"$pid\""
1908 targetJson=$targetJson"]"
1909 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1910 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1912 if [ $res -ne 0 ]; then
1913 __log_test_fail_body
1922 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}
1923 # args: <response-code> <job-id> [<type-id> <target-url> <owner-id> <template-job-file>]
1924 # (Function for test scripts)
1925 ecs_api_idc_get_job() {
1928 if [ $# -ne 2 ] && [ $# -ne 7 ]; then
1929 __print_err "<response-code> <job-id> [<type-id> <target-url> <owner-id> <notification-url> <template-job-file>]" $@
1932 query="/data-consumer/v1/info-jobs/$2"
1933 res="$(__do_curl_to_api ECS GET $query)"
1934 status=${res:${#res}-3}
1936 if [ $status -ne $1 ]; then
1937 __log_test_fail_status_code $1 $status
1941 if [ $# -eq 7 ]; then
1942 body=${res:0:${#res}-3}
1946 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
1948 __log_test_fail_general "Job template file "$6", does not exist"
1951 targetJson="{\"info_type_id\": \"$3\", \"job_result_uri\": \"$4\",\"job_owner\": \"$5\",\"status_notification_uri\": \"$6\",\"job_definition\": $jobfile}"
1952 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1953 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1955 if [ $res -ne 0 ]; then
1956 __log_test_fail_body
1966 # API Test function: PUT ​/data-consumer/v1/info-jobs/{infoJobId}
1967 # args: <response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file> [ VALIDATE ]
1968 # (Function for test scripts)
1969 ecs_api_idc_put_job() {
1972 if [ $# -lt 7 ] || [ $# -gt 8 ]; then
1973 __print_err "<response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file> [ VALIDATE ]" $@
1978 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
1980 __log_test_fail_general "Job template file "$7", does not exist"
1984 inputJson="{\"info_type_id\": \"$3\", \"job_result_uri\": \"$4\",\"job_owner\": \"$5\",\"status_notification_uri\": \"$6\",\"job_definition\": $jobfile}"
1985 file="./tmp/.p.json"
1986 echo "$inputJson" > $file
1988 query="/data-consumer/v1/info-jobs/$2"
1990 if [ $# -eq 8 ]; then
1991 if [ $8 == "VALIDATE" ]; then
1992 query=$query"?typeCheck=true"
1996 res="$(__do_curl_to_api ECS PUT $query $file)"
1997 status=${res:${#res}-3}
1999 if [ $status -ne $1 ]; then
2000 __log_test_fail_status_code $1 $status
2008 # API Test function: DELETE ​/data-consumer/v1/info-jobs/{infoJobId}
2009 # args: <response-code> <job-id>
2010 # (Function for test scripts)
2011 ecs_api_idc_delete_job() {
2014 if [ $# -ne 2 ]; then
2015 __print_err "<response-code> <job-id>" $@
2018 query="/data-consumer/v1/info-jobs/$2"
2019 res="$(__do_curl_to_api ECS DELETE $query)"
2020 status=${res:${#res}-3}
2022 if [ $status -ne $1 ]; then
2023 __log_test_fail_status_code $1 $status
2031 # API Test function: GET ​/data-consumer/v1/info-types/{infoTypeId}
2032 # args: <response-code> <type-id> [<schema-file> [<type-status> <producers-count]]
2033 # (Function for test scripts)
2034 ecs_api_idc_get_type() {
2037 if [ $# -lt 2 ] || [ $# -gt 5 ]; then
2038 __print_err "<response-code> <type-id> [<schema-file> [<type-status> <producers-count]]" $@
2042 query="/data-consumer/v1/info-types/$2"
2043 res="$(__do_curl_to_api ECS GET $query)"
2044 status=${res:${#res}-3}
2046 if [ $status -ne $1 ]; then
2047 __log_test_fail_status_code $1 $status
2051 if [ $# -gt 2 ]; then
2052 body=${res:0:${#res}-3}
2056 __log_test_fail_general "Schema file "$3", does not exist"
2059 if [ $# -eq 5 ]; then
2060 targetJson="{\"job_data_schema\":$schema, \"type_status\":\"$4\", \"no_of_producers\":$5}"
2062 targetJson="{\"job_data_schema\":$schema}"
2064 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2065 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2067 if [ $res -ne 0 ]; then
2068 __log_test_fail_body
2077 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}/status
2078 # This test only status during an optional timeout. No test of the list of producers
2079 # args: <response-code> <job-id> [<status> [<timeout>]]
2080 # (Function for test scripts)
2081 ecs_api_idc_get_job_status() {
2084 if [ $# -lt 2 ] && [ $# -gt 4 ]; then
2085 __print_err "<response-code> <job-id> [<status> [<timeout>]]" $@
2089 query="/data-consumer/v1/info-jobs/$2/status"
2093 res="$(__do_curl_to_api ECS GET $query)"
2094 status=${res:${#res}-3}
2096 if [ $# -eq 4 ]; then
2097 duration=$((SECONDS-start))
2098 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
2099 if [ $duration -gt $4 ]; then
2101 duration=-1 #Last iteration
2104 duration=-1 #single test, no wait
2107 if [ $status -ne $1 ]; then
2108 if [ $duration -eq -1 ]; then
2109 __log_test_fail_status_code $1 $status
2113 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
2114 body=${res:0:${#res}-3}
2115 targetJson="{\"info_job_status\": \"$3\"}"
2116 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2117 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2119 if [ $res -ne 0 ]; then
2120 if [ $duration -eq -1 ]; then
2121 __log_test_fail_body
2125 duration=-1 #Goto pass
2128 if [ $duration -eq -1 ]; then
2129 if [ $# -eq 4 ]; then
2143 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}/status
2144 # This function test status and the list of producers with and optional timeout
2145 # args: <response-code> <job-id> [<status> EMPTYPROD|( <prod-count> <producer-id>+ ) [<timeout>]]
2146 # (Function for test scripts)
2147 ecs_api_idc_get_job_status2() {
2151 if [ $# -lt 2 ]; then
2156 if [ $# -gt 2 ]; then
2157 if [ $# -lt 4 ]; then
2160 targetJson="{\"info_job_status\": \"$3\""
2161 if [ "$4" == "EMPTYPROD" ]; then
2162 targetJson=$targetJson",\"producers\": []}"
2163 if [ $# -gt 4 ]; then
2167 targetJson=$targetJson",\"producers\": ["
2168 if [ $# -eq $(($4+5)) ]; then
2170 timeout=${args[$idx]}
2172 for ((ecs_i = 0 ; ecs_i < $4 ; ecs_i++)); do
2174 if [ $ecs_i -gt 0 ]; then
2175 targetJson=$targetJson","
2177 targetJson=$targetJson"\""${args[$idx]}"\""
2179 targetJson=$targetJson"]}"
2183 if [ $param_error -ne 0 ]; then
2184 __print_err "<response-code> <job-id> [<status> EMPTYPROD|( <prod-count> <producer-id>+ ) [<timeout>]]" $@
2188 query="/data-consumer/v1/info-jobs/$2/status"
2192 res="$(__do_curl_to_api ECS GET $query)"
2193 status=${res:${#res}-3}
2195 if [ $# -gt 2 ]; then
2196 duration=$((SECONDS-start))
2197 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
2198 if [ $duration -gt $timeout ]; then
2200 duration=-1 #Last iteration
2203 duration=-1 #single test, no wait
2206 if [ $status -ne $1 ]; then
2207 if [ $duration -eq -1 ]; then
2208 __log_test_fail_status_code $1 $status
2212 if [ $# -gt 2 ] && [ $status -eq $1 ]; then
2213 body=${res:0:${#res}-3}
2214 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2215 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2217 if [ $res -ne 0 ]; then
2218 if [ $duration -eq -1 ]; then
2219 __log_test_fail_body
2223 duration=-1 #Goto pass
2226 if [ $duration -eq -1 ]; then
2227 if [ $# -eq 4 ]; then
2241 ##########################################
2242 #### Type subscriptions ####
2243 ##########################################
2245 # API Test function: GET /data-consumer/v1/info-type-subscription
2246 # args: <response-code> <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]
2247 # (Function for test scripts)
2248 ecs_api_idc_get_subscription_ids() {
2251 if [ $# -lt 3 ]; then
2252 __print_err "<response-code> <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]" $@
2256 query="/data-consumer/v1/info-type-subscription"
2258 if [ $2 != "NOOWNER" ]; then
2262 res="$(__do_curl_to_api ECS GET $query$search)"
2263 status=${res:${#res}-3}
2265 if [ $status -ne $1 ]; then
2266 __log_test_fail_status_code $1 $status
2270 if [ $# -gt 2 ]; then
2271 body=${res:0:${#res}-3}
2273 if [ $3 != "EMPTY" ]; then
2274 for pid in ${@:3} ; do
2275 if [ "$targetJson" != "[" ]; then
2276 targetJson=$targetJson","
2278 targetJson=$targetJson"\"$pid\""
2281 targetJson=$targetJson"]"
2282 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2283 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2285 if [ $res -ne 0 ]; then
2286 __log_test_fail_body
2295 # API Test function: GET /data-consumer/v1/info-type-subscription/{subscriptionId}
2296 # args: <response-code> <subscription-id> [ <owner-id> <status-uri> ]
2297 # (Function for test scripts)
2298 ecs_api_idc_get_subscription() {
2301 if [ $# -ne 2 ] && [ $# -ne 4 ]; then
2302 __print_err "<response-code> <subscription-id> [ <owner-id> <status-uri> ]" $@
2306 query="/data-consumer/v1/info-type-subscription/$2"
2307 res="$(__do_curl_to_api ECS GET $query)"
2308 status=${res:${#res}-3}
2310 if [ $status -ne $1 ]; then
2311 __log_test_fail_status_code $1 $status
2315 if [ $# -gt 2 ]; then
2316 body=${res:0:${#res}-3}
2317 targetJson="{\"owner\":\"$3\",\"status_result_uri\":\"$4\"}"
2318 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2319 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2321 if [ $res -ne 0 ]; then
2322 __log_test_fail_body
2331 # API Test function: PUT /data-consumer/v1/info-type-subscription/{subscriptionId}
2332 # args: <response-code> <subscription-id> <owner-id> <status-uri>
2333 # (Function for test scripts)
2334 ecs_api_idc_put_subscription() {
2337 if [ $# -ne 4 ]; then
2338 __print_err "<response-code> <subscription-id> <owner-id> <status-uri>" $@
2342 inputJson="{\"owner\": \"$3\",\"status_result_uri\": \"$4\"}"
2343 file="./tmp/.p.json"
2344 echo "$inputJson" > $file
2346 query="/data-consumer/v1/info-type-subscription/$2"
2347 res="$(__do_curl_to_api ECS PUT $query $file)"
2348 status=${res:${#res}-3}
2350 if [ $status -ne $1 ]; then
2351 __log_test_fail_status_code $1 $status
2359 # API Test function: DELETE /data-consumer/v1/info-type-subscription/{subscriptionId}
2360 # args: <response-code> <subscription-id>
2361 # (Function for test scripts)
2362 ecs_api_idc_delete_subscription() {
2365 if [ $# -ne 2 ]; then
2366 __print_err "<response-code> <subscription-id> " $@
2370 query="/data-consumer/v1/info-type-subscription/$2"
2371 res="$(__do_curl_to_api ECS DELETE $query)"
2372 status=${res:${#res}-3}
2374 if [ $status -ne $1 ]; then
2375 __log_test_fail_status_code $1 $status
2383 ##########################################
2384 #### Reset jobs ####
2385 ##########################################
2386 # Function prefix: ecs_api_admin
2388 # Admin to remove all jobs
2389 # args: <response-code> [ <type> ]
2390 # (Function for test scripts)
2392 ecs_api_admin_reset() {
2395 if [ -z "$FLAT_A1_EI" ]; then
2396 query="/A1-EI/v1/eitypes/$2/eijobs"
2398 query="/A1-EI/v1/eijobs"
2400 res="$(__do_curl_to_api ECS GET $query)"
2401 status=${res:${#res}-3}
2403 if [ $status -ne 200 ]; then
2404 __log_test_fail_status_code $1 $status
2408 #Remove brackets and response code
2409 body=${res:1:${#res}-4}
2410 list=$(echo ${body//,/ })
2411 list=$(echo ${list//[/})
2412 list=$(echo ${list//]/})
2413 list=$(echo ${list//\"/})
2415 for job in $list; do
2416 if [ -z "$FLAT_A1_EI" ]; then
2417 echo "Not supported for non-flat EI api"
2419 query="/A1-EI/v1/eijobs/$job"
2420 res="$(__do_curl_to_api ECS DELETE $query)"
2421 status=${res:${#res}-3}
2422 if [ $status -ne 204 ]; then
2423 __log_test_fail_status_code $1 $status
2426 echo " Deleted job: "$job
2434 ##########################################
2435 #### Reset jobs and producers ####
2436 ##########################################
2439 # Admin reset to remove all data in ecs; jobs, producers etc
2440 # NOTE - only works in kubernetes and the pod should not be running
2442 # (Function for test scripts)
2444 ecs_kube_pvc_reset() {
2447 pvc_name=$(kubectl get pvc -n $KUBE_NONRTRIC_NAMESPACE --no-headers -o custom-columns=":metadata.name" | grep enrichment)
2448 if [ -z "$pvc_name" ]; then
2449 pvc_name=enrichmentservice-pvc
2451 echo " Trying to reset pvc: "$pvc_name
2453 __kube_clean_pvc $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE $pvc_name $ECS_CONTAINER_MNT_DIR