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 #######################################################
97 # Make curl retries towards ECS for http response codes set in this env var, space separated list of codes
100 #Save first worker node the pod is started on
103 ###########################
105 ###########################
107 # All calls to ECS will be directed to the ECS REST interface from now on
109 # (Function for test scripts)
110 use_ecs_rest_http() {
111 __ecs_set_protocoll "http" $ECS_INTERNAL_PORT $ECS_EXTERNAL_PORT
114 # All calls to ECS will be directed to the ECS REST interface from now on
116 # (Function for test scripts)
117 use_ecs_rest_https() {
118 __ecs_set_protocoll "https" $ECS_INTERNAL_SECURE_PORT $ECS_EXTERNAL_SECURE_PORT
121 # All calls to ECS will be directed to the ECS dmaap interface over http from now on
123 # (Function for test scripts)
124 use_ecs_dmaap_http() {
125 echo -e $BOLD"ECS dmaap protocol setting"$EBOLD
126 echo -e $RED" - NOT SUPPORTED - "$ERED
127 echo -e " Using $BOLD http $EBOLD and $BOLD DMAAP $EBOLD towards ECS"
128 ECS_ADAPTER_TYPE="MR-HTTP"
132 # Setup paths to svc/container for internal and external access
133 # args: <protocol> <internal-port> <external-port>
134 __ecs_set_protocoll() {
135 echo -e $BOLD"$ECS_DISPLAY_NAME protocol setting"$EBOLD
136 echo -e " Using $BOLD http $EBOLD towards $ECS_DISPLAY_NAME"
140 ECS_SERVICE_PATH=$1"://"$ECS_APP_NAME":"$2 # docker access, container->container and script->container via proxy
141 if [ $RUNMODE == "KUBE" ]; then
142 ECS_SERVICE_PATH=$1"://"$ECS_APP_NAME.$KUBE_NONRTRIC_NAMESPACE":"$3 # kube access, pod->svc and script->svc via proxy
145 # ECS_ADAPTER used for switching between REST and DMAAP (only REST supported currently)
146 ECS_ADAPTER_TYPE="REST"
147 ECS_ADAPTER=$ECS_SERVICE_PATH
152 # Export env vars for config files, docker compose and kube resources
153 # args: PROXY|NOPROXY
154 __ecs_export_vars() {
156 export ECS_APP_NAME_ALIAS
157 export KUBE_NONRTRIC_NAMESPACE
159 export ECS_INTERNAL_PORT
160 export ECS_INTERNAL_SECURE_PORT
161 export ECS_EXTERNAL_PORT
162 export ECS_EXTERNAL_SECURE_PORT
163 export ECS_CONFIG_MOUNT_PATH
164 export ECS_CONFIG_CONFIGMAP_NAME=$ECS_APP_NAME"-config"
165 export ECS_DATA_CONFIGMAP_NAME=$ECS_APP_NAME"-data"
166 export ECS_CONTAINER_MNT_DIR
167 export ECS_HOST_MNT_DIR
168 export ECS_CONFIG_FILE
169 export DOCKER_SIM_NWNAME
170 export ECS_DISPLAY_NAME
173 export ECS_DATA_PV_NAME=$ECS_APP_NAME"-pv"
174 export ECS_DATA_PVC_NAME=$ECS_APP_NAME"-pvc"
175 #Create a unique path for the pv each time to prevent a previous volume to be reused
176 export ECS_PV_PATH="ecsdata-"$(date +%s)
178 if [ $1 == "PROXY" ]; then
179 export ECS_HTTP_PROXY_CONFIG_PORT=$HTTP_PROXY_CONFIG_PORT #Set if proxy is started
180 export ECS_HTTP_PROXY_CONFIG_HOST_NAME=$HTTP_PROXY_CONFIG_HOST_NAME #Set if proxy is started
181 if [ $ECS_HTTP_PROXY_CONFIG_PORT -eq 0 ] || [ -z "$ECS_HTTP_PROXY_CONFIG_HOST_NAME" ]; then
182 echo -e $YELLOW" Warning: HTTP PROXY will not be configured, proxy app not started"$EYELLOW
184 echo " Configured with http proxy"
187 export ECS_HTTP_PROXY_CONFIG_PORT=0
188 export ECS_HTTP_PROXY_CONFIG_HOST_NAME=""
189 echo " Configured without http proxy"
195 # args: PROXY|NOPROXY <config-file>
196 # (Function for test scripts)
199 echo -e $BOLD"Starting $ECS_DISPLAY_NAME"$EBOLD
201 if [ $RUNMODE == "KUBE" ]; then
203 # Check if app shall be fully managed by the test script
204 __check_included_image "ECS"
207 # Check if app shall only be used by the testscipt
208 __check_prestarted_image "ECS"
211 if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then
212 echo -e $RED"The $ECS_APP_NAME app is not included as managed nor prestarted in this test script"$ERED
213 echo -e $RED"The $ECS_APP_NAME will not be started"$ERED
216 if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then
217 echo -e $RED"The $ECS_APP_NAME app is included both as managed and prestarted in this test script"$ERED
218 echo -e $RED"The $ECS_APP_NAME will not be started"$ERED
223 if [ $retcode_p -eq 0 ]; then
224 echo -e " Using existing $ECS_APP_NAME deployment and service"
225 echo " Setting ECS replicas=1"
226 res_type=$(__kube_get_resource_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
227 __kube_scale $res_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
230 # Check if app shall be fully managed by the test script
231 if [ $retcode_i -eq 0 ]; then
232 echo -e " Creating $ECS_APP_NAME app and expose service"
234 #Check if nonrtric namespace exists, if not create it
235 __kube_create_namespace $KUBE_NONRTRIC_NAMESPACE
239 # Create config map for config
240 datafile=$PWD/tmp/$ECS_CONFIG_FILE
242 output_yaml=$PWD/tmp/ecs_cfc.yaml
243 __kube_create_configmap $ECS_CONFIG_CONFIGMAP_NAME $KUBE_NONRTRIC_NAMESPACE autotest ECS $datafile $output_yaml
246 input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"pv.yaml
247 output_yaml=$PWD/tmp/ecs_pv.yaml
248 __kube_create_instance pv $ECS_APP_NAME $input_yaml $output_yaml
251 input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"pvc.yaml
252 output_yaml=$PWD/tmp/ecs_pvc.yaml
253 __kube_create_instance pvc $ECS_APP_NAME $input_yaml $output_yaml
256 input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"svc.yaml
257 output_yaml=$PWD/tmp/ecs_svc.yaml
258 __kube_create_instance service $ECS_APP_NAME $input_yaml $output_yaml
261 input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"app.yaml
262 output_yaml=$PWD/tmp/ecs_app.yaml
263 __kube_create_instance app $ECS_APP_NAME $input_yaml $output_yaml
266 # 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
267 # 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
269 # 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
270 if [ $retcode_i -eq 0 ]; then
271 __ECS_WORKER_NODE=$(kubectl get pod -l "autotest=ECS" -n $KUBE_NONRTRIC_NAMESPACE -o jsonpath='{.items[*].spec.nodeName}')
272 if [ -z "$__ECS_WORKER_NODE" ]; then
273 echo -e $YELLOW" Cannot find worker node for pod for $ECS_APP_NAME, persistency may not work"$EYELLOW
276 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
280 __check_service_start $ECS_APP_NAME $ECS_SERVICE_PATH$ECS_ALIVE_URL
283 __check_included_image 'ECS'
284 if [ $? -eq 1 ]; then
285 echo -e $RED"The ECS app is not included in this test script"$ERED
286 echo -e $RED"ECS will not be started"$ERED
296 if [ "$(ls -A $DIR)" ]; then
297 echo -e $BOLD" Cleaning files in mounted dir: $PWD/db"$EBOLD
298 rm -rf db/* &> /dev/null
299 if [ $? -ne 0 ]; then
300 echo -e $RED" Cannot remove database files in: $PWD"$ERED
305 echo " No files in mounted dir or dir does not exists"
312 dest_file=$SIM_GROUP/$ECS_COMPOSE_DIR/$ECS_HOST_MNT_DIR/$ECS_CONFIG_FILE
314 envsubst < $2 > $dest_file
316 __start_container $ECS_COMPOSE_DIR "" NODOCKERARGS 1 $ECS_APP_NAME
318 __check_service_start $ECS_APP_NAME $ECS_SERVICE_PATH$ECS_ALIVE_URL
327 # (Function for test scripts)
329 echo -e $BOLD"Stopping $ECS_DISPLAY_NAME"$EBOLD
331 if [ $RUNMODE == "KUBE" ]; then
333 __check_prestarted_image "ECS"
334 if [ $? -eq 0 ]; then
335 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
336 res_type=$(__kube_get_resource_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
337 __kube_scale $res_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 0
341 __kube_scale_all_resources $KUBE_NONRTRIC_NAMESPACE autotest ECS
342 echo " Deleting the replica set - a new will be started when the app is started"
343 tmp=$(kubectl delete rs -n $KUBE_NONRTRIC_NAMESPACE -l "autotest=ECS")
344 if [ $? -ne 0 ]; then
345 echo -e $RED" Could not delete replica set "$RED
350 docker stop $ECS_APP_NAME &> ./tmp/.dockererr
351 if [ $? -ne 0 ]; then
352 __print_err "Could not stop $ECS_APP_NAME" $@
358 echo -e $BOLD$GREEN"Stopped"$EGREEN$EBOLD
363 # Start a previously stopped ecs
365 # (Function for test scripts)
366 start_stopped_ecs() {
367 echo -e $BOLD"Starting (the previously stopped) $ECS_DISPLAY_NAME"$EBOLD
369 if [ $RUNMODE == "KUBE" ]; then
371 __check_prestarted_image "ECS"
372 if [ $? -eq 0 ]; then
373 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
374 res_type=$(__kube_get_resource_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
375 __kube_scale $res_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
376 __check_service_start $ECS_APP_NAME $ECS_SERVICE_PATH$ECS_ALIVE_URL
380 # Tie the PMS to the same worker node it was initially started on
381 # 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
382 if [ -z "$__ECS_WORKER_NODE" ]; then
383 echo -e $RED" No initial worker node found for pod "$RED
387 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
388 echo -e $BOLD" The mounted volume is mounted as hostPath and only available on that worker node."$BOLD
389 tmp=$(kubectl patch deployment $ECS_APP_NAME -n $KUBE_NONRTRIC_NAMESPACE --patch '{"spec": {"template": {"spec": {"nodeSelector": {"kubernetes.io/hostname": "'$__ECS_WORKER_NODE'"}}}}}')
390 if [ $? -ne 0 ]; then
391 echo -e $YELLOW" Cannot set nodeSelector to deployment for $ECS_APP_NAME, persistency may not work"$EYELLOW
393 __kube_scale deployment $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
396 docker start $ECS_APP_NAME &> ./tmp/.dockererr
397 if [ $? -ne 0 ]; then
398 __print_err "Could not start (the stopped) $ECS_APP_NAME" $@
404 __check_service_start $ECS_APP_NAME $ECS_SERVICE_PATH$ECS_ALIVE_URL
405 if [ $? -ne 0 ]; then
412 # Turn on debug level tracing in ECS
414 # (Function for test scripts)
416 echo -e $BOLD"Setting ecs debug logging"$EBOLD
417 curlString="$ECS_SERVICE_PATH$ECS_ACTUATOR -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"debug\"}"
418 result=$(__do_curl "$curlString")
419 if [ $? -ne 0 ]; then
420 __print_err "Could not set debug mode" $@
428 # Turn on trace level tracing in ECS
430 # (Function for test scripts)
432 echo -e $BOLD"Setting ecs trace logging"$EBOLD
433 curlString="$ECS_SERVICE_PATH/actuator/loggers/org.oransc.enrichment -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}"
434 result=$(__do_curl "$curlString")
435 if [ $? -ne 0 ]; then
436 __print_err "Could not set trace mode" $@
444 # Perform curl retries when making direct call to ECS for the specified http response codes
445 # Speace separated list of http response codes
446 # args: [<response-code>]*
448 echo -e $BOLD"Do curl retries to the ECS REST inteface for these response codes:$@"$EBOLD
454 # Check the ecs logs for WARNINGs and ERRORs
456 # (Function for test scripts)
458 __check_container_logs "ECS" $ECS_APP_NAME $ECS_LOGPATH WARN ERR
462 # Tests if a variable value in the ECS is equal to a target value and and optional timeout.
463 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
464 # equal to the target or not.
465 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
466 # before setting pass or fail depending on if the variable value becomes equal to the target
468 # (Function for test scripts)
470 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
471 __var_test ECS "$ECS_SERVICE_PATH/" $1 "=" $2 $3
473 __print_err "Wrong args to ecs_equal, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
478 ##########################################
479 ######### A1-E Enrichment API ##########
480 ##########################################
481 #Function prefix: ecs_api_a1
483 # API Test function: GET /A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs
484 # args: <response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
485 # args (flat uri structure): <response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
486 # (Function for test scripts)
487 ecs_api_a1_get_job_ids() {
490 if [ -z "$FLAT_A1_EI" ]; then
491 # Valid number of parameters 4,5,6 etc
492 if [ $# -lt 3 ]; then
493 __print_err "<response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
497 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
498 # Valid number of parameters 4,5,6 etc
499 if [ $# -lt 3 ]; then
500 __print_err "<response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
505 if [ $3 != "NOWNER" ]; then
509 if [ -z "$FLAT_A1_EI" ]; then
510 query="/A1-EI/v1/eitypes/$2/eijobs$search"
512 if [ $2 != "NOTYPE" ]; then
513 if [ -z "$search" ]; then
514 search="?eiTypeId="$2
516 search=$search"&eiTypeId="$2
519 query="/A1-EI/v1/eijobs$search"
521 res="$(__do_curl_to_api ECS GET $query)"
522 status=${res:${#res}-3}
524 if [ $status -ne $1 ]; then
525 __log_test_fail_status_code $1 $status
529 if [ $# -gt 3 ]; then
530 body=${res:0:${#res}-3}
533 for pid in ${@:4} ; do
534 if [ "$targetJson" != "[" ]; then
535 targetJson=$targetJson","
537 if [ $pid != "EMPTY" ]; then
538 targetJson=$targetJson"\"$pid\""
542 targetJson=$targetJson"]"
543 echo " TARGET JSON: $targetJson" >> $HTTPLOG
544 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
546 if [ $res -ne 0 ]; then
556 # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}
557 # args: <response-code> <type-id> [<schema-file>]
558 # (Function for test scripts)
559 ecs_api_a1_get_type() {
562 if [ $# -lt 2 ] || [ $# -gt 3 ]; then
563 __print_err "<response-code> <type-id> [<schema-file>]" $@
567 query="/A1-EI/v1/eitypes/$2"
568 res="$(__do_curl_to_api ECS GET $query)"
569 status=${res:${#res}-3}
571 if [ $status -ne $1 ]; then
572 __log_test_fail_status_code $1 $status
576 if [ $# -eq 3 ]; then
577 body=${res:0:${#res}-3}
581 __log_test_fail_general "Schema file "$3", does not exist"
584 if [ -z "$FLAT_A1_EI" ]; then
585 targetJson="{\"eiJobParametersSchema\":$schema}"
589 echo " TARGET JSON: $targetJson" >> $HTTPLOG
590 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
592 if [ $res -ne 0 ]; then
602 # API Test function: GET /A1-EI/v1/eitypes
603 # args: <response-code> [ (EMPTY | [<type-id>]+) ]
604 # (Function for test scripts)
605 ecs_api_a1_get_type_ids() {
608 if [ $# -lt 1 ]; then
609 __print_err "<response-code> [ (EMPTY | [<type-id>]+) ]" $@
613 query="/A1-EI/v1/eitypes"
614 res="$(__do_curl_to_api ECS GET $query)"
615 status=${res:${#res}-3}
617 if [ $status -ne $1 ]; then
618 __log_test_fail_status_code $1 $status
621 if [ $# -gt 1 ]; then
622 body=${res:0:${#res}-3}
624 if [ $2 != "EMPTY" ]; then
625 for pid in ${@:2} ; do
626 if [ "$targetJson" != "[" ]; then
627 targetJson=$targetJson","
629 targetJson=$targetJson"\"$pid\""
632 targetJson=$targetJson"]"
633 echo " TARGET JSON: $targetJson" >> $HTTPLOG
634 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
636 if [ $res -ne 0 ]; then
646 # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}​/status
647 # args: <response-code> <type-id> <job-id> [<status>]
648 # args (flat uri structure): <response-code> <job-id> [<status> [<timeout>]]
649 # (Function for test scripts)
650 ecs_api_a1_get_job_status() {
653 if [ -z "$FLAT_A1_EI" ]; then
654 if [ $# -ne 3 ] && [ $# -ne 4 ]; then
655 __print_err "<response-code> <type-id> <job-id> [<status>]" $@
659 query="/A1-EI/v1/eitypes/$2/eijobs/$3/status"
661 res="$(__do_curl_to_api ECS GET $query)"
662 status=${res:${#res}-3}
664 if [ $status -ne $1 ]; then
665 __log_test_fail_status_code $1 $status
668 if [ $# -eq 4 ]; then
669 body=${res:0:${#res}-3}
670 targetJson="{\"operationalState\": \"$4\"}"
671 echo " TARGET JSON: $targetJson" >> $HTTPLOG
672 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
674 if [ $res -ne 0 ]; then
680 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
681 if [ $# -lt 2 ] && [ $# -gt 4 ]; then
682 __print_err "<response-code> <job-id> [<status> [<timeout>]]" $@
686 query="/A1-EI/v1/eijobs/$2/status"
690 res="$(__do_curl_to_api ECS GET $query)"
691 status=${res:${#res}-3}
693 if [ $# -eq 4 ]; then
694 duration=$((SECONDS-start))
695 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
696 if [ $duration -gt $4 ]; then
698 duration=-1 #Last iteration
701 duration=-1 #single test, no wait
704 if [ $status -ne $1 ]; then
705 if [ $duration -eq -1 ]; then
706 __log_test_fail_status_code $1 $status
710 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
711 body=${res:0:${#res}-3}
712 targetJson="{\"eiJobStatus\": \"$3\"}"
713 echo " TARGET JSON: $targetJson" >> $HTTPLOG
714 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
716 if [ $res -ne 0 ]; then
717 if [ $duration -eq -1 ]; then
722 duration=-1 #Goto pass
725 if [ $duration -eq -1 ]; then
726 if [ $# -eq 4 ]; then
741 # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
742 # args: <response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]
743 # args (flat uri structure): <response-code> <job-id> [<type-id> <target-url> <owner-id> <template-job-file>]
744 # (Function for test scripts)
745 ecs_api_a1_get_job() {
748 if [ -z "$FLAT_A1_EI" ]; then
749 if [ $# -ne 3 ] && [ $# -ne 6 ]; then
750 __print_err "<response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]" $@
753 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
755 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
756 if [ $# -ne 2 ] && [ $# -ne 7 ]; then
757 __print_err "<response-code> <job-id> [<type-id> <target-url> <owner-id> <notification-url> <template-job-file>]" $@
760 query="/A1-EI/v1/eijobs/$2"
762 res="$(__do_curl_to_api ECS GET $query)"
763 status=${res:${#res}-3}
765 if [ $status -ne $1 ]; then
766 __log_test_fail_status_code $1 $status
770 if [ -z "$FLAT_A1_EI" ]; then
771 if [ $# -eq 6 ]; then
772 body=${res:0:${#res}-3}
776 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
778 __log_test_fail_general "Job template file "$6", does not exist"
781 targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
782 echo " TARGET JSON: $targetJson" >> $HTTPLOG
783 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
785 if [ $res -ne 0 ]; then
791 if [ $# -eq 7 ]; then
792 body=${res:0:${#res}-3}
796 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
798 __log_test_fail_general "Job template file "$6", does not exist"
801 targetJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
802 echo " TARGET JSON: $targetJson" >> $HTTPLOG
803 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
805 if [ $res -ne 0 ]; then
816 # API Test function: DELETE ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
817 # args: <response-code> <type-id> <job-id>
818 # args (flat uri structure): <response-code> <job-id>
819 # (Function for test scripts)
820 ecs_api_a1_delete_job() {
823 if [ -z "$FLAT_A1_EI" ]; then
824 if [ $# -ne 3 ]; then
825 __print_err "<response-code> <type-id> <job-id>" $@
829 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
831 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
832 if [ $# -ne 2 ]; then
833 __print_err "<response-code> <job-id>" $@
836 query="/A1-EI/v1/eijobs/$2"
838 res="$(__do_curl_to_api ECS DELETE $query)"
839 status=${res:${#res}-3}
841 if [ $status -ne $1 ]; then
842 __log_test_fail_status_code $1 $status
850 # API Test function: PUT ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
851 # args: <response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>
852 # args (flat uri structure): <response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file>
853 # (Function for test scripts)
854 ecs_api_a1_put_job() {
857 if [ -z "$FLAT_A1_EI" ]; then
858 if [ $# -lt 6 ]; then
859 __print_err "<response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>" $@
864 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
866 __log_test_fail_general "Job template file "$6", does not exist"
870 inputJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
872 echo "$inputJson" > $file
874 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
876 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
877 if [ $# -lt 7 ]; then
878 __print_err "<response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file>" $@
883 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
885 __log_test_fail_general "Job template file "$7", does not exist"
889 inputJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
891 echo "$inputJson" > $file
893 query="/A1-EI/v1/eijobs/$2"
896 res="$(__do_curl_to_api ECS PUT $query $file)"
897 status=${res:${#res}-3}
899 if [ $status -ne $1 ]; then
900 __log_test_fail_status_code $1 $status
909 ##########################################
910 #### Enrichment Data Producer API ####
911 ##########################################
912 # Function prefix: ecs_api_edp
914 # API Test function: GET /ei-producer/v1/eitypes
915 # API Test function: GET /data-producer/v1/info-types
916 # args: <response-code> [ EMPTY | <type-id>+]
917 # (Function for test scripts)
918 ecs_api_edp_get_type_ids() {
921 if [ $# -lt 1 ]; then
922 __print_err "<response-code> [ EMPTY | <type-id>+]" $@
925 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
926 query="/data-producer/v1/info-types"
928 query="/ei-producer/v1/eitypes"
930 res="$(__do_curl_to_api ECS GET $query)"
931 status=${res:${#res}-3}
933 if [ $status -ne $1 ]; then
934 __log_test_fail_status_code $1 $status
938 if [ $# -gt 1 ]; then
939 body=${res:0:${#res}-3}
941 if [ $2 != "EMPTY" ]; then
942 for pid in ${@:2} ; do
943 if [ "$targetJson" != "[" ]; then
944 targetJson=$targetJson","
946 targetJson=$targetJson"\"$pid\""
949 targetJson=$targetJson"]"
950 echo " TARGET JSON: $targetJson" >> $HTTPLOG
951 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
953 if [ $res -ne 0 ]; then
963 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/status
964 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}/status
965 # args: <response-code> <producer-id> [<status> [<timeout>]]
966 # (Function for test scripts)
967 ecs_api_edp_get_producer_status() {
970 if [ $# -lt 2 ] || [ $# -gt 4 ]; then
971 __print_err "<response-code> <producer-id> [<status> [<timeout>]]" $@
974 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
975 query="/data-producer/v1/info-producers/$2/status"
977 query="/ei-producer/v1/eiproducers/$2/status"
981 res="$(__do_curl_to_api ECS GET $query)"
982 status=${res:${#res}-3}
984 if [ $# -eq 4 ]; then
985 duration=$((SECONDS-start))
986 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
987 if [ $duration -gt $4 ]; then
989 duration=-1 #Last iteration
992 duration=-1 #single test, no wait
995 if [ $status -ne $1 ]; then
996 if [ $duration -eq -1 ]; then
997 __log_test_fail_status_code $1 $status
1001 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
1002 body=${res:0:${#res}-3}
1003 targetJson="{\"operational_state\": \"$3\"}"
1004 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1005 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1007 if [ $res -ne 0 ]; then
1008 if [ $duration -eq -1 ]; then
1009 __log_test_fail_body
1013 duration=-1 #Goto pass
1016 if [ $duration -eq -1 ]; then
1017 if [ $# -eq 4 ]; then
1029 # API Test function: GET /ei-producer/v1/eiproducers
1030 # args (v1_1): <response-code> [ EMPTY | <producer-id>+]
1031 # (Function for test scripts)
1032 ecs_api_edp_get_producer_ids() {
1035 if [ $# -lt 1 ]; then
1036 __print_err "<response-code> [ EMPTY | <producer-id>+]" $@
1040 query="/ei-producer/v1/eiproducers"
1041 res="$(__do_curl_to_api ECS GET $query)"
1042 status=${res:${#res}-3}
1044 if [ $status -ne $1 ]; then
1045 __log_test_fail_status_code $1 $status
1049 if [ $# -gt 1 ]; then
1050 body=${res:0:${#res}-3}
1053 for pid in ${@:2} ; do
1054 if [ "$targetJson" != "[" ]; then
1055 targetJson=$targetJson","
1057 if [ $pid != "EMPTY" ]; then
1058 targetJson=$targetJson"\"$pid\""
1062 targetJson=$targetJson"]"
1063 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1064 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1066 if [ $res -ne 0 ]; then
1067 __log_test_fail_body
1076 # API Test function: GET /ei-producer/v1/eiproducers
1077 # API Test function: GET /data-producer/v1/info-producers
1078 # args (v1_2): <response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]
1079 # (Function for test scripts)
1080 ecs_api_edp_get_producer_ids_2() {
1083 if [ $# -lt 1 ]; then
1084 __print_err "<response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]" $@
1087 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1088 query="/data-producer/v1/info-producers"
1089 if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then
1090 query=$query"?info_type_id=$2"
1093 query="/ei-producer/v1/eiproducers"
1094 if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then
1095 query=$query"?ei_type_id=$2"
1098 res="$(__do_curl_to_api ECS GET $query)"
1099 status=${res:${#res}-3}
1101 if [ $status -ne $1 ]; then
1102 __log_test_fail_status_code $1 $status
1106 if [ $# -gt 2 ]; then
1107 body=${res:0:${#res}-3}
1110 for pid in ${@:3} ; do
1111 if [ "$targetJson" != "[" ]; then
1112 targetJson=$targetJson","
1114 if [ $pid != "EMPTY" ]; then
1115 targetJson=$targetJson"\"$pid\""
1119 targetJson=$targetJson"]"
1120 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1121 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1123 if [ $res -ne 0 ]; then
1124 __log_test_fail_body
1133 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
1134 # args: (v1_1) <response-code> <type-id> [<job-schema-file> (EMPTY | [<producer-id>]+)]
1135 # (Function for test scripts)
1136 ecs_api_edp_get_type() {
1140 if [ $# -eq 2 ]; then
1143 if [ $# -gt 3 ]; then
1146 if [ $paramError -ne 0 ]; then
1147 __print_err "<response-code> <type-id> [<job-schema-file> 'EMPTY' | ([<producer-id>]+)]" $@
1151 query="/ei-producer/v1/eitypes/$2"
1152 res="$(__do_curl_to_api ECS GET $query)"
1153 status=${res:${#res}-3}
1155 if [ $status -ne $1 ]; then
1156 __log_test_fail_status_code $1 $status
1159 if [ $# -gt 3 ]; then
1160 body=${res:0:${#res}-3}
1165 __log_test_fail_general "Job template file "$3", does not exist"
1170 if [ $4 != "EMPTY" ]; then
1171 for pid in ${@:4} ; do
1172 if [ "$targetJson" != "" ]; then
1173 targetJson=$targetJson","
1175 targetJson=$targetJson"\"$pid\""
1178 targetJson="{\"ei_job_data_schema\":$schema, \"ei_producer_ids\": [$targetJson]}"
1180 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1181 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1183 if [ $res -ne 0 ]; then
1184 __log_test_fail_body
1192 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
1193 # API Test function: GET /data-producer/v1/info-types/{infoTypeId}
1194 # args: (v1_2) <response-code> <type-id> [<job-schema-file> [ <info-type-info> ]]
1195 # (Function for test scripts)
1196 ecs_api_edp_get_type_2() {
1200 if [ $# -eq 2 ]; then
1203 if [ $# -eq 3 ]; then
1206 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then
1207 if [ $# -eq 4 ]; then
1211 if [ $paramError -ne 0 ]; then
1212 __print_err "<response-code> <type-id> [<job-schema-file> [ <info-type-info> ]]" $@
1215 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1216 query="/data-producer/v1/info-types/$2"
1218 query="/ei-producer/v1/eitypes/$2"
1221 res="$(__do_curl_to_api ECS GET $query)"
1222 status=${res:${#res}-3}
1224 if [ $status -ne $1 ]; then
1225 __log_test_fail_status_code $1 $status
1228 if [ $# -ge 3 ]; then
1229 body=${res:0:${#res}-3}
1234 __log_test_fail_general "Job template file "$3", does not exist"
1238 if [ $# -gt 3 ]; then
1242 __log_test_fail_general "Info-data file "$4", does not exist"
1245 info_data=",\"info_type_information\":$info_data"
1247 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1248 targetJson="{\"info_job_data_schema\":$schema $info_data}"
1250 targetJson="{\"ei_job_data_schema\":$schema}"
1253 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1254 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1256 if [ $res -ne 0 ]; then
1257 __log_test_fail_body
1265 # API Test function: PUT /ei-producer/v1/eitypes/{eiTypeId}
1266 # API Test function: PUT /data-producer/v1/info-types/{infoTypeId}
1267 # args: (v1_2) <response-code> <type-id> <job-schema-file> [ <info-type-info> ]
1268 # (Function for test scripts)
1269 ecs_api_edp_put_type_2() {
1272 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then
1273 if [ $# -lt 3 ] || [ $# -gt 4 ]; then
1274 __print_err "<response-code> <type-id> <job-schema-file> [ <info-type-info> ]" $@
1278 if [ $# -ne 3 ]; then
1279 __print_err "<response-code> <type-id> <job-schema-file>" $@
1284 if [ ! -f $3 ]; then
1285 __log_test_fail_general "Job schema file "$3", does not exist"
1290 if [ $# -gt 3 ]; then
1294 __log_test_fail_general "Info-data file "$4", does not exist"
1297 info_data=",\"info_type_information\":$info_data"
1300 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1302 input_json="{\"info_job_data_schema\":$schema $info_data}"
1303 file="./tmp/put_type.json"
1304 echo $input_json > $file
1306 query="/data-producer/v1/info-types/$2"
1309 input_json="{\"ei_job_data_schema\":$schema}"
1310 file="./tmp/put_type.json"
1311 echo $input_json > $file
1313 query="/ei-producer/v1/eitypes/$2"
1315 res="$(__do_curl_to_api ECS PUT $query $file)"
1316 status=${res:${#res}-3}
1318 if [ $status -ne $1 ]; then
1319 __log_test_fail_status_code $1 $status
1327 # API Test function: DELETE /ei-producer/v1/eitypes/{eiTypeId}
1328 # API Test function: DELETE /data-producer/v1/info-types/{infoTypeId}
1329 # args: (v1_2) <response-code> <type-id>
1330 # (Function for test scripts)
1331 ecs_api_edp_delete_type_2() {
1334 if [ $# -ne 2 ]; then
1335 __print_err "<response-code> <type-id>" $@
1339 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1340 query="/data-producer/v1/info-types/$2"
1342 query="/ei-producer/v1/eitypes/$2"
1344 res="$(__do_curl_to_api ECS DELETE $query)"
1345 status=${res:${#res}-3}
1347 if [ $status -ne $1 ]; then
1348 __log_test_fail_status_code $1 $status
1356 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
1357 # args: (v1_1) <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | [<type-id> <schema-file>]+) ]
1358 # (Function for test scripts)
1359 ecs_api_edp_get_producer() {
1362 #Possible arg count: 2, 5 6, 8, 10 etc
1364 if [ $# -eq 2 ]; then
1367 if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then
1370 variablecount=$(($#-4))
1371 if [ $# -gt 5 ] && [ $(($variablecount%2)) -eq 0 ]; then
1375 if [ $paramError -ne 0 ]; then
1376 __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (NOID | [<type-id> <schema-file>]+) ]" $@
1380 query="/ei-producer/v1/eiproducers/$2"
1381 res="$(__do_curl_to_api ECS GET $query)"
1382 status=${res:${#res}-3}
1384 if [ $status -ne $1 ]; then
1385 __log_test_fail_status_code $1 $status
1389 if [ $# -gt 2 ]; then
1390 body=${res:0:${#res}-3}
1392 if [ $# -gt 5 ]; then
1394 for ((i=0; i<$(($#-5)); i=i+2)); do
1395 if [ "$targetJson" != "[" ]; then
1396 targetJson=$targetJson","
1398 if [ -f ${arr[$i+1]} ]; then
1399 schema=$(cat ${arr[$i+1]})
1401 __log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
1405 targetJson=$targetJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
1408 targetJson=$targetJson"]"
1409 if [ $# -gt 4 ]; then
1410 targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
1412 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1413 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1415 if [ $res -ne 0 ]; then
1416 __log_test_fail_body
1425 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
1426 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}
1427 # args (v1_2): <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]
1428 # (Function for test scripts)
1429 ecs_api_edp_get_producer_2() {
1432 #Possible arg count: 2, 5, 6, 7, 8 etc
1434 if [ $# -eq 2 ]; then
1437 if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then
1440 if [ $# -ge 5 ]; then
1444 if [ $paramError -ne 0 ]; then
1445 __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]" $@
1448 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1449 query="/data-producer/v1/info-producers/$2"
1451 query="/ei-producer/v1/eiproducers/$2"
1453 res="$(__do_curl_to_api ECS GET $query)"
1454 status=${res:${#res}-3}
1456 if [ $status -ne $1 ]; then
1457 __log_test_fail_status_code $1 $status
1461 if [ $# -gt 2 ]; then
1462 body=${res:0:${#res}-3}
1464 if [ $# -gt 4 ] && [ "$5" != "EMPTY" ]; then
1466 for ((i=0; i<$(($#-4)); i=i+1)); do
1467 if [ "$targetJson" != "[" ]; then
1468 targetJson=$targetJson","
1470 targetJson=$targetJson"\"${arr[$i]}\""
1473 targetJson=$targetJson"]"
1474 if [ $# -gt 4 ]; then
1475 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1476 targetJson="{\"supported_info_types\":$targetJson,\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\"}"
1478 targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
1481 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1482 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1484 if [ $res -ne 0 ]; then
1485 __log_test_fail_body
1494 # API Test function: DELETE /ei-producer/v1/eiproducers/{eiProducerId}
1495 # API Test function: DELETE /data-producer/v1/info-producers/{infoProducerId}
1496 # args: <response-code> <producer-id>
1497 # (Function for test scripts)
1498 ecs_api_edp_delete_producer() {
1501 if [ $# -lt 2 ]; then
1502 __print_err "<response-code> <producer-id>" $@
1505 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1506 query="/data-producer/v1/info-producers/$2"
1508 query="/ei-producer/v1/eiproducers/$2"
1510 res="$(__do_curl_to_api ECS DELETE $query)"
1511 status=${res:${#res}-3}
1513 if [ $status -ne $1 ]; then
1514 __log_test_fail_status_code $1 $status
1522 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
1523 # args: (v1_1) <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+
1524 # (Function for test scripts)
1525 ecs_api_edp_put_producer() {
1528 #Valid number of parametrer 5,6,8,10,
1530 if [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then
1532 elif [ $# -gt 5 ] && [ $(($#%2)) -eq 0 ]; then
1535 if [ $paramError -ne 0 ]; then
1536 __print_err "<response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+" $@
1541 if [ $# -gt 5 ]; then
1543 for ((i=0; i<$(($#-5)); i=i+2)); do
1544 if [ "$inputJson" != "[" ]; then
1545 inputJson=$inputJson","
1547 if [ -f ${arr[$i+1]} ]; then
1548 schema=$(cat ${arr[$i+1]})
1550 __log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
1553 inputJson=$inputJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
1556 inputJson="\"supported_ei_types\":"$inputJson"]"
1558 inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
1560 inputJson="{"$inputJson"}"
1562 file="./tmp/.p.json"
1563 echo "$inputJson" > $file
1564 query="/ei-producer/v1/eiproducers/$2"
1565 res="$(__do_curl_to_api ECS PUT $query $file)"
1566 status=${res:${#res}-3}
1568 if [ $status -ne $1 ]; then
1569 __log_test_fail_status_code $1 $status
1577 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
1578 # API Test function: PUT /data-producer/v1/info-producers/{infoProducerId}
1579 # args: (v1_2) <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]
1580 # (Function for test scripts)
1581 ecs_api_edp_put_producer_2() {
1584 #Valid number of parametrer 5,6,8,10,
1586 if [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then
1588 elif [ $# -ge 5 ]; then
1591 if [ $paramError -ne 0 ]; then
1592 __print_err "<response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]" $@
1597 if [ $# -gt 4 ] && [ "$5" != "NOTYPE" ]; then
1599 for ((i=0; i<$(($#-4)); i=i+1)); do
1600 if [ "$inputJson" != "[" ]; then
1601 inputJson=$inputJson","
1603 inputJson=$inputJson"\""${arr[$i]}"\""
1606 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1607 inputJson="\"supported_info_types\":"$inputJson"]"
1609 inputJson=$inputJson",\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\""
1611 inputJson="{"$inputJson"}"
1613 file="./tmp/.p.json"
1614 echo "$inputJson" > $file
1615 query="/data-producer/v1/info-producers/$2"
1617 inputJson="\"supported_ei_types\":"$inputJson"]"
1619 inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
1621 inputJson="{"$inputJson"}"
1623 file="./tmp/.p.json"
1624 echo "$inputJson" > $file
1625 query="/ei-producer/v1/eiproducers/$2"
1627 res="$(__do_curl_to_api ECS PUT $query $file)"
1628 status=${res:${#res}-3}
1630 if [ $status -ne $1 ]; then
1631 __log_test_fail_status_code $1 $status
1639 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
1640 # args: (V1-1) <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)
1641 # (Function for test scripts)
1642 ecs_api_edp_get_producer_jobs() {
1645 #Valid number of parameter 2,3,7,11
1647 if [ $# -eq 2 ]; then
1650 if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
1653 variablecount=$(($#-2))
1654 if [ $# -gt 3 ] && [ $(($variablecount%5)) -eq 0 ]; then
1657 if [ $paramError -eq 1 ]; then
1658 __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)" $@
1662 query="/ei-producer/v1/eiproducers/$2/eijobs"
1663 res="$(__do_curl_to_api ECS GET $query)"
1664 status=${res:${#res}-3}
1665 if [ $status -ne $1 ]; then
1666 __log_test_fail_status_code $1 $status
1669 if [ $# -gt 2 ]; then
1670 body=${res:0:${#res}-3}
1672 if [ $# -gt 3 ]; then
1674 for ((i=0; i<$(($#-3)); i=i+5)); do
1675 if [ "$targetJson" != "[" ]; then
1676 targetJson=$targetJson","
1678 if [ -f ${arr[$i+4]} ]; then
1679 jobfile=$(cat ${arr[$i+4]})
1680 jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
1682 __log_test_fail_general "Job template file "${arr[$i+4]}", does not exist"
1685 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}"
1688 targetJson=$targetJson"]"
1690 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1691 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1693 if [ $res -ne 0 ]; then
1694 __log_test_fail_body
1703 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
1704 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}/info-jobs
1705 # args: (V1-2) <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)
1706 # (Function for test scripts)
1707 ecs_api_edp_get_producer_jobs_2() {
1710 #Valid number of parameter 2,3,7,11
1712 if [ $# -eq 2 ]; then
1715 if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
1718 variablecount=$(($#-2))
1719 if [ $# -gt 3 ] && [ $(($variablecount%5)) -eq 0 ]; then
1722 if [ $paramError -eq 1 ]; then
1723 __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)" $@
1726 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1727 query="/data-producer/v1/info-producers/$2/info-jobs"
1729 query="/ei-producer/v1/eiproducers/$2/eijobs"
1731 res="$(__do_curl_to_api ECS GET $query)"
1732 status=${res:${#res}-3}
1733 if [ $status -ne $1 ]; then
1734 __log_test_fail_status_code $1 $status
1737 if [ $# -gt 2 ]; then
1738 body=${res:0:${#res}-3}
1740 if [ $# -gt 3 ]; then
1742 for ((i=0; i<$(($#-3)); i=i+5)); do
1743 if [ "$targetJson" != "[" ]; then
1744 targetJson=$targetJson","
1746 if [ -f ${arr[$i+4]} ]; then
1747 jobfile=$(cat ${arr[$i+4]})
1748 jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
1750 __log_test_fail_general "Job template file "${arr[$i+4]}", does not exist"
1753 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1754 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\":\"????\"}"
1756 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\":\"????\"}"
1760 targetJson=$targetJson"]"
1762 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1763 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1765 if [ $res -ne 0 ]; then
1766 __log_test_fail_body
1775 ##########################################
1776 #### Service status ####
1777 ##########################################
1778 # Function prefix: ecs_api_service
1780 # API Test function: GET ​/status
1781 # args: <response-code>
1782 # (Function for test scripts)
1783 ecs_api_service_status() {
1786 if [ $# -lt 1 ]; then
1787 __print_err "<response-code>" $@
1790 res="$(__do_curl_to_api ECS GET /status)"
1791 status=${res:${#res}-3}
1792 if [ $status -ne $1 ]; then
1793 __log_test_fail_status_code $1 $status
1800 ###########################################
1801 ######### Info data consumer API ##########
1802 ###########################################
1803 #Function prefix: ecs_api_idc
1806 # API Test function: GET /data-consumer/v1/info-types
1807 # args: <response-code> [ (EMPTY | [<type-id>]+) ]
1808 # (Function for test scripts)
1809 ecs_api_idc_get_type_ids() {
1812 if [ $# -lt 1 ]; then
1813 __print_err "<response-code> [ (EMPTY | [<type-id>]+) ]" $@
1817 query="/data-consumer/v1/info-types"
1818 res="$(__do_curl_to_api ECS GET $query)"
1819 status=${res:${#res}-3}
1821 if [ $status -ne $1 ]; then
1822 __log_test_fail_status_code $1 $status
1825 if [ $# -gt 1 ]; then
1826 body=${res:0:${#res}-3}
1828 if [ $2 != "EMPTY" ]; then
1829 for pid in ${@:2} ; do
1830 if [ "$targetJson" != "[" ]; then
1831 targetJson=$targetJson","
1833 targetJson=$targetJson"\"$pid\""
1836 targetJson=$targetJson"]"
1837 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1838 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1840 if [ $res -ne 0 ]; then
1841 __log_test_fail_body
1850 # API Test function: GET /data-consumer/v1/info-jobs
1851 # args: <response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
1852 # (Function for test scripts)
1853 ecs_api_idc_get_job_ids() {
1856 # Valid number of parameters 4,5,6 etc
1857 if [ $# -lt 3 ]; then
1858 __print_err "<response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
1862 if [ $3 != "NOWNER" ]; then
1866 if [ $2 != "NOTYPE" ]; then
1867 if [ -z "$search" ]; then
1868 search="?infoTypeId="$2
1870 search=$search"&infoTypeId="$2
1873 query="/data-consumer/v1/info-jobs$search"
1875 res="$(__do_curl_to_api ECS GET $query)"
1876 status=${res:${#res}-3}
1878 if [ $status -ne $1 ]; then
1879 __log_test_fail_status_code $1 $status
1883 if [ $# -gt 3 ]; then
1884 body=${res:0:${#res}-3}
1887 for pid in ${@:4} ; do
1888 if [ "$targetJson" != "[" ]; then
1889 targetJson=$targetJson","
1891 if [ $pid != "EMPTY" ]; then
1892 targetJson=$targetJson"\"$pid\""
1896 targetJson=$targetJson"]"
1897 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1898 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1900 if [ $res -ne 0 ]; then
1901 __log_test_fail_body
1910 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}
1911 # args: <response-code> <job-id> [<type-id> <target-url> <owner-id> <template-job-file>]
1912 # (Function for test scripts)
1913 ecs_api_idc_get_job() {
1916 if [ $# -ne 2 ] && [ $# -ne 7 ]; then
1917 __print_err "<response-code> <job-id> [<type-id> <target-url> <owner-id> <notification-url> <template-job-file>]" $@
1920 query="/data-consumer/v1/info-jobs/$2"
1921 res="$(__do_curl_to_api ECS GET $query)"
1922 status=${res:${#res}-3}
1924 if [ $status -ne $1 ]; then
1925 __log_test_fail_status_code $1 $status
1929 if [ $# -eq 7 ]; then
1930 body=${res:0:${#res}-3}
1934 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
1936 __log_test_fail_general "Job template file "$6", does not exist"
1939 targetJson="{\"info_type_id\": \"$3\", \"job_result_uri\": \"$4\",\"job_owner\": \"$5\",\"status_notification_uri\": \"$6\",\"job_definition\": $jobfile}"
1940 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1941 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1943 if [ $res -ne 0 ]; then
1944 __log_test_fail_body
1954 # API Test function: PUT ​/data-consumer/v1/info-jobs/{infoJobId}
1955 # args: <response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file> [ VALIDATE ]
1956 # (Function for test scripts)
1957 ecs_api_idc_put_job() {
1960 if [ $# -lt 7 ] || [ $# -gt 8 ]; then
1961 __print_err "<response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file> [ VALIDATE ]" $@
1966 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
1968 __log_test_fail_general "Job template file "$7", does not exist"
1972 inputJson="{\"info_type_id\": \"$3\", \"job_result_uri\": \"$4\",\"job_owner\": \"$5\",\"status_notification_uri\": \"$6\",\"job_definition\": $jobfile}"
1973 file="./tmp/.p.json"
1974 echo "$inputJson" > $file
1976 query="/data-consumer/v1/info-jobs/$2"
1978 if [ $# -eq 8 ]; then
1979 if [ $8 == "VALIDATE" ]; then
1980 query=$query"?typeCheck=true"
1984 res="$(__do_curl_to_api ECS PUT $query $file)"
1985 status=${res:${#res}-3}
1987 if [ $status -ne $1 ]; then
1988 __log_test_fail_status_code $1 $status
1996 # API Test function: DELETE ​/data-consumer/v1/info-jobs/{infoJobId}
1997 # args: <response-code> <job-id>
1998 # (Function for test scripts)
1999 ecs_api_idc_delete_job() {
2002 if [ $# -ne 2 ]; then
2003 __print_err "<response-code> <job-id>" $@
2006 query="/data-consumer/v1/info-jobs/$2"
2007 res="$(__do_curl_to_api ECS DELETE $query)"
2008 status=${res:${#res}-3}
2010 if [ $status -ne $1 ]; then
2011 __log_test_fail_status_code $1 $status
2019 # API Test function: GET ​/data-consumer/v1/info-types/{infoTypeId}
2020 # args: <response-code> <type-id> [<schema-file> [<type-status> <producers-count]]
2021 # (Function for test scripts)
2022 ecs_api_idc_get_type() {
2025 if [ $# -lt 2 ] || [ $# -gt 5 ]; then
2026 __print_err "<response-code> <type-id> [<schema-file> [<type-status> <producers-count]]" $@
2030 query="/data-consumer/v1/info-types/$2"
2031 res="$(__do_curl_to_api ECS GET $query)"
2032 status=${res:${#res}-3}
2034 if [ $status -ne $1 ]; then
2035 __log_test_fail_status_code $1 $status
2039 if [ $# -gt 2 ]; then
2040 body=${res:0:${#res}-3}
2044 __log_test_fail_general "Schema file "$3", does not exist"
2047 if [ $# -eq 5 ]; then
2048 targetJson="{\"job_data_schema\":$schema, \"type_status\":\"$4\", \"no_of_producers\":$5}"
2050 targetJson="{\"job_data_schema\":$schema}"
2052 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2053 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2055 if [ $res -ne 0 ]; then
2056 __log_test_fail_body
2065 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}/status
2066 # This test only status during an optional timeout. No test of the list of producers
2067 # args: <response-code> <job-id> [<status> [<timeout>]]
2068 # (Function for test scripts)
2069 ecs_api_idc_get_job_status() {
2072 if [ $# -lt 2 ] && [ $# -gt 4 ]; then
2073 __print_err "<response-code> <job-id> [<status> [<timeout>]]" $@
2077 query="/data-consumer/v1/info-jobs/$2/status"
2081 res="$(__do_curl_to_api ECS GET $query)"
2082 status=${res:${#res}-3}
2084 if [ $# -eq 4 ]; then
2085 duration=$((SECONDS-start))
2086 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
2087 if [ $duration -gt $4 ]; then
2089 duration=-1 #Last iteration
2092 duration=-1 #single test, no wait
2095 if [ $status -ne $1 ]; then
2096 if [ $duration -eq -1 ]; then
2097 __log_test_fail_status_code $1 $status
2101 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
2102 body=${res:0:${#res}-3}
2103 targetJson="{\"info_job_status\": \"$3\"}"
2104 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2105 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2107 if [ $res -ne 0 ]; then
2108 if [ $duration -eq -1 ]; then
2109 __log_test_fail_body
2113 duration=-1 #Goto pass
2116 if [ $duration -eq -1 ]; then
2117 if [ $# -eq 4 ]; then
2131 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}/status
2132 # This function test status and the list of producers with and optional timeout
2133 # args: <response-code> <job-id> [<status> EMPTYPROD|( <prod-count> <producer-id>+ ) [<timeout>]]
2134 # (Function for test scripts)
2135 ecs_api_idc_get_job_status2() {
2139 if [ $# -lt 2 ]; then
2144 if [ $# -gt 2 ]; then
2145 if [ $# -lt 4 ]; then
2148 targetJson="{\"info_job_status\": \"$3\""
2149 if [ "$4" == "EMPTYPROD" ]; then
2150 targetJson=$targetJson",\"producers\": []}"
2151 if [ $# -gt 4 ]; then
2155 targetJson=$targetJson",\"producers\": ["
2156 if [ $# -eq $(($4+5)) ]; then
2158 timeout=${args[$idx]}
2160 for ((ecs_i = 0 ; ecs_i < $4 ; ecs_i++)); do
2162 if [ $ecs_i -gt 0 ]; then
2163 targetJson=$targetJson","
2165 targetJson=$targetJson"\""${args[$idx]}"\""
2167 targetJson=$targetJson"]}"
2171 if [ $param_error -ne 0 ]; then
2172 __print_err "<response-code> <job-id> [<status> EMPTYPROD|( <prod-count> <producer-id>+ ) [<timeout>]]" $@
2176 query="/data-consumer/v1/info-jobs/$2/status"
2180 res="$(__do_curl_to_api ECS GET $query)"
2181 status=${res:${#res}-3}
2183 if [ $# -gt 2 ]; then
2184 duration=$((SECONDS-start))
2185 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
2186 if [ $duration -gt $timeout ]; then
2188 duration=-1 #Last iteration
2191 duration=-1 #single test, no wait
2194 if [ $status -ne $1 ]; then
2195 if [ $duration -eq -1 ]; then
2196 __log_test_fail_status_code $1 $status
2200 if [ $# -gt 2 ] && [ $status -eq $1 ]; then
2201 body=${res:0:${#res}-3}
2202 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2203 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2205 if [ $res -ne 0 ]; then
2206 if [ $duration -eq -1 ]; then
2207 __log_test_fail_body
2211 duration=-1 #Goto pass
2214 if [ $duration -eq -1 ]; then
2215 if [ $# -eq 4 ]; then
2229 ##########################################
2230 #### Type subscriptions ####
2231 ##########################################
2233 # API Test function: GET /data-consumer/v1/info-type-subscription
2234 # args: <response-code> <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]
2235 # (Function for test scripts)
2236 ecs_api_idc_get_subscription_ids() {
2239 if [ $# -lt 3 ]; then
2240 __print_err "<response-code> <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]" $@
2244 query="/data-consumer/v1/info-type-subscription"
2246 if [ $2 != "NOOWNER" ]; then
2250 res="$(__do_curl_to_api ECS GET $query$search)"
2251 status=${res:${#res}-3}
2253 if [ $status -ne $1 ]; then
2254 __log_test_fail_status_code $1 $status
2258 if [ $# -gt 2 ]; then
2259 body=${res:0:${#res}-3}
2261 if [ $3 != "EMPTY" ]; then
2262 for pid in ${@:3} ; do
2263 if [ "$targetJson" != "[" ]; then
2264 targetJson=$targetJson","
2266 targetJson=$targetJson"\"$pid\""
2269 targetJson=$targetJson"]"
2270 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2271 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2273 if [ $res -ne 0 ]; then
2274 __log_test_fail_body
2283 # API Test function: GET /data-consumer/v1/info-type-subscription/{subscriptionId}
2284 # args: <response-code> <subscription-id> [ <owner-id> <status-uri> ]
2285 # (Function for test scripts)
2286 ecs_api_idc_get_subscription() {
2289 if [ $# -ne 2 ] && [ $# -ne 4 ]; then
2290 __print_err "<response-code> <subscription-id> [ <owner-id> <status-uri> ]" $@
2294 query="/data-consumer/v1/info-type-subscription/$2"
2295 res="$(__do_curl_to_api ECS GET $query)"
2296 status=${res:${#res}-3}
2298 if [ $status -ne $1 ]; then
2299 __log_test_fail_status_code $1 $status
2303 if [ $# -gt 2 ]; then
2304 body=${res:0:${#res}-3}
2305 targetJson="{\"owner\":\"$3\",\"status_result_uri\":\"$4\"}"
2306 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2307 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2309 if [ $res -ne 0 ]; then
2310 __log_test_fail_body
2319 # API Test function: PUT /data-consumer/v1/info-type-subscription/{subscriptionId}
2320 # args: <response-code> <subscription-id> <owner-id> <status-uri>
2321 # (Function for test scripts)
2322 ecs_api_idc_put_subscription() {
2325 if [ $# -ne 4 ]; then
2326 __print_err "<response-code> <subscription-id> <owner-id> <status-uri>" $@
2330 inputJson="{\"owner\": \"$3\",\"status_result_uri\": \"$4\"}"
2331 file="./tmp/.p.json"
2332 echo "$inputJson" > $file
2334 query="/data-consumer/v1/info-type-subscription/$2"
2335 res="$(__do_curl_to_api ECS PUT $query $file)"
2336 status=${res:${#res}-3}
2338 if [ $status -ne $1 ]; then
2339 __log_test_fail_status_code $1 $status
2347 # API Test function: DELETE /data-consumer/v1/info-type-subscription/{subscriptionId}
2348 # args: <response-code> <subscription-id>
2349 # (Function for test scripts)
2350 ecs_api_idc_delete_subscription() {
2353 if [ $# -ne 2 ]; then
2354 __print_err "<response-code> <subscription-id> " $@
2358 query="/data-consumer/v1/info-type-subscription/$2"
2359 res="$(__do_curl_to_api ECS DELETE $query)"
2360 status=${res:${#res}-3}
2362 if [ $status -ne $1 ]; then
2363 __log_test_fail_status_code $1 $status
2371 ##########################################
2372 #### Reset jobs ####
2373 ##########################################
2374 # Function prefix: ecs_api_admin
2376 # Admin to remove all jobs
2377 # args: <response-code> [ <type> ]
2378 # (Function for test scripts)
2380 ecs_api_admin_reset() {
2383 if [ -z "$FLAT_A1_EI" ]; then
2384 query="/A1-EI/v1/eitypes/$2/eijobs"
2386 query="/A1-EI/v1/eijobs"
2388 res="$(__do_curl_to_api ECS GET $query)"
2389 status=${res:${#res}-3}
2391 if [ $status -ne 200 ]; then
2392 __log_test_fail_status_code $1 $status
2396 #Remove brackets and response code
2397 body=${res:1:${#res}-4}
2398 list=$(echo ${body//,/ })
2399 list=$(echo ${list//[/})
2400 list=$(echo ${list//]/})
2401 list=$(echo ${list//\"/})
2403 for job in $list; do
2404 if [ -z "$FLAT_A1_EI" ]; then
2405 echo "Not supported for non-flat EI api"
2407 query="/A1-EI/v1/eijobs/$job"
2408 res="$(__do_curl_to_api ECS DELETE $query)"
2409 status=${res:${#res}-3}
2410 if [ $status -ne 204 ]; then
2411 __log_test_fail_status_code $1 $status
2414 echo " Deleted job: "$job
2422 ##########################################
2423 #### Reset jobs and producers ####
2424 ##########################################
2427 # Admin reset to remove all data in ecs; jobs, producers etc
2428 # NOTE - only works in kubernetes and the pod should not be running
2430 # (Function for test scripts)
2432 ecs_kube_pvc_reset() {
2435 pvc_name=$(kubectl get pvc -n $KUBE_NONRTRIC_NAMESPACE --no-headers -o custom-columns=":metadata.name" | grep enrichment)
2436 if [ -z "$pvc_name" ]; then
2437 pvc_name=enrichmentservice-pvc
2439 echo " Trying to reset pvc: "$pvc_name
2441 __kube_clean_pvc $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE $pvc_name $ECS_CONTAINER_MNT_DIR