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 nonrtric-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 docker logs $ECS_APP_NAME > $1$2_ecs.log 2>&1
82 #######################################################
86 # Host name may be changed if app started by kube
89 ECS_HOST_NAME=$LOCALHOST_NAME
90 ECS_PATH=$ECS_HTTPX"://"$ECS_HOST_NAME":"$ECS_EXTERNAL_PORT
92 # ECS_ADAPTER used for switch between REST and DMAAP (only REST supported currently)
93 ECS_ADAPTER_TYPE="REST"
96 # Make curl retries towards ECS for http response codes set in this env var, space separated list of codes
99 ###########################
101 ###########################
103 # All calls to ECS will be directed to the ECS REST interface from now on
105 # (Function for test scripts)
106 use_ecs_rest_http() {
107 echo -e $BOLD"ECS protocol setting"$EBOLD
108 echo -e " Using $BOLD http $EBOLD and $BOLD REST $EBOLD towards ECS"
110 ECS_PATH=$ECS_HTTPX"://"$ECS_HOST_NAME":"$ECS_EXTERNAL_PORT
112 ECS_ADAPTER_TYPE="REST"
113 ECS_ADAPTER=$ECS_PATH
117 # All calls to ECS will be directed to the ECS REST interface from now on
119 # (Function for test scripts)
120 use_ecs_rest_https() {
121 echo -e $BOLD"ECS protocol setting"$EBOLD
122 echo -e " Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards ECS"
124 ECS_PATH=$ECS_HTTPX"://"$ECS_HOST_NAME":"$ECS_EXTERNAL_SECURE_PORT
126 ECS_ADAPTER_TYPE="REST"
127 ECS_ADAPTER=$ECS_PATH
131 # All calls to ECS will be directed to the ECS dmaap interface over http from now on
133 # (Function for test scripts)
134 use_ecs_dmaap_http() {
135 echo -e $BOLD"ECS dmaap protocol setting"$EBOLD
136 echo -e $RED" - NOT SUPPORTED - "$ERED
137 echo -e " Using $BOLD http $EBOLD and $BOLD DMAAP $EBOLD towards ECS"
138 ECS_ADAPTER_TYPE="MR-HTTP"
142 # All calls to ECS will be directed to the ECS dmaap interface over https from now on
144 # (Function for test scripts)
145 use_ecs_dmaap_https() {
146 echo -e $BOLD"RICSIM protocol setting"$EBOLD
147 echo -e $RED" - NOT SUPPORTED - "$ERED
148 echo -e " Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards ECS"
149 ECS_ADAPTER_TYPE="MR-HTTPS"
154 # args: PROXY|NOPROXY <config-file>
155 # (Function for test scripts)
158 echo -e $BOLD"Starting $ECS_DISPLAY_NAME"$EBOLD
160 if [ $RUNMODE == "KUBE" ]; then
162 # Check if app shall be fully managed by the test script
163 __check_included_image "ECS"
166 # Check if app shall only be used by the testscipt
167 __check_prestarted_image "ECS"
170 if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then
171 echo -e $RED"The $ECS_APP_NAME app is not included as managed nor prestarted in this test script"$ERED
172 echo -e $RED"The $ECS_APP_NAME will not be started"$ERED
175 if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then
176 echo -e $RED"The $ECS_APP_NAME app is included both as managed and prestarted in this test script"$ERED
177 echo -e $RED"The $ECS_APP_NAME will not be started"$ERED
182 if [ $retcode_p -eq 0 ]; then
183 echo -e " Using existing $ECS_APP_NAME deployment and service"
184 echo " Setting ECS replicas=1"
185 __kube_scale deployment $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
188 # Check if app shall be fully managed by the test script
189 if [ $retcode_i -eq 0 ]; then
190 echo -e " Creating $ECS_APP_NAME app and expose service"
192 #Check if nonrtric namespace exists, if not create it
193 __kube_create_namespace $KUBE_NONRTRIC_NAMESPACE
196 export KUBE_NONRTRIC_NAMESPACE
198 export ECS_INTERNAL_PORT
199 export ECS_INTERNAL_SECURE_PORT
200 export ECS_EXTERNAL_PORT
201 export ECS_EXTERNAL_SECURE_PORT
202 export ECS_CONFIG_MOUNT_PATH
203 export ECS_CONFIG_CONFIGMAP_NAME=$ECS_APP_NAME"-config"
204 export ECS_DATA_CONFIGMAP_NAME=$ECS_APP_NAME"-data"
205 export ECS_CONTAINER_MNT_DIR
207 export ECS_DATA_PV_NAME=$ECS_APP_NAME"-pv"
208 #Create a unique path for the pv each time to prevent a previous volume to be reused
209 export ECS_PV_PATH="ecsdata-"$(date +%s)
211 if [ $1 == "PROXY" ]; then
212 ECS_HTTP_PROXY_CONFIG_PORT=$HTTP_PROXY_CONFIG_PORT #Set if proxy is started
213 ECS_HTTP_PROXY_CONFIG_HOST_NAME=$HTTP_PROXY_CONFIG_HOST_NAME #Set if proxy is started
214 if [ $ECS_HTTP_PROXY_CONFIG_PORT -eq 0 ] || [ -z "$ECS_HTTP_PROXY_CONFIG_HOST_NAME" ]; then
215 echo -e $YELLOW" Warning: HTTP PROXY will not be configured, proxy app not started"$EYELLOW
217 echo " Configured with http proxy"
220 ECS_HTTP_PROXY_CONFIG_PORT=0
221 ECS_HTTP_PROXY_CONFIG_HOST_NAME=""
222 echo " Configured without http proxy"
224 export ECS_HTTP_PROXY_CONFIG_PORT
225 export ECS_HTTP_PROXY_CONFIG_HOST_NAME
227 # Create config map for config
228 datafile=$PWD/tmp/$ECS_CONFIG_FILE
230 output_yaml=$PWD/tmp/ecs_cfc.yaml
231 __kube_create_configmap $ECS_CONFIG_CONFIGMAP_NAME $KUBE_NONRTRIC_NAMESPACE autotest ECS $datafile $output_yaml
234 input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"pv.yaml
235 output_yaml=$PWD/tmp/ecs_pv.yaml
236 __kube_create_instance pv $ECS_APP_NAME $input_yaml $output_yaml
239 input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"pvc.yaml
240 output_yaml=$PWD/tmp/ecs_pvc.yaml
241 __kube_create_instance pvc $ECS_APP_NAME $input_yaml $output_yaml
244 input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"svc.yaml
245 output_yaml=$PWD/tmp/ecs_svc.yaml
246 __kube_create_instance service $ECS_APP_NAME $input_yaml $output_yaml
249 input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"app.yaml
250 output_yaml=$PWD/tmp/ecs_app.yaml
251 __kube_create_instance app $ECS_APP_NAME $input_yaml $output_yaml
254 echo " Retrieving host and ports for service..."
255 ECS_HOST_NAME=$(__kube_get_service_host $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
256 ECS_EXTERNAL_PORT=$(__kube_get_service_port $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE "http")
257 ECS_EXTERNAL_SECURE_PORT=$(__kube_get_service_port $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE "https")
259 echo " Host IP, http port, https port: $ECS_HOST_NAME $ECS_EXTERNAL_PORT $ECS_EXTERNAL_SECURE_PORT"
261 if [ $ECS_HTTPX == "http" ]; then
262 ECS_PATH=$ECS_HTTPX"://"$ECS_HOST_NAME":"$ECS_EXTERNAL_PORT
264 ECS_PATH=$ECS_HTTPX"://"$ECS_HOST_NAME":"$ECS_EXTERNAL_SECURE_PORT
267 __check_service_start $ECS_APP_NAME $ECS_PATH$ECS_ALIVE_URL
269 if [ $ECS_ADAPTER_TYPE == "REST" ]; then
270 ECS_ADAPTER=$ECS_PATH
273 __check_included_image 'ECS'
274 if [ $? -eq 1 ]; then
275 echo -e $RED"The ECS app is not included in this test script"$ERED
276 echo -e $RED"ECS will not be started"$ERED
286 if [ "$(ls -A $DIR)" ]; then
287 echo -e $BOLD" Cleaning files in mounted dir: $PWD/db"$EBOLD
288 rm -rf db/* &> /dev/null
289 if [ $? -ne 0 ]; then
290 echo -e $RED" Cannot remove database files in: $PWD"$ERED
295 echo " No files in mounted dir or dir does not exists"
300 export ECS_APP_NAME_ALIAS
301 export ECS_HOST_MNT_DIR
302 export ECS_CONTAINER_MNT_DIR
303 export ECS_CONFIG_MOUNT_PATH
304 export ECS_CONFIG_FILE
305 export ECS_INTERNAL_PORT
306 export ECS_EXTERNAL_PORT
307 export ECS_INTERNAL_SECURE_PORT
308 export ECS_EXTERNAL_SECURE_PORT
309 export DOCKER_SIM_NWNAME
310 export ECS_DISPLAY_NAME
312 if [ $1 == "PROXY" ]; then
313 ECS_HTTP_PROXY_CONFIG_PORT=$HTTP_PROXY_CONFIG_PORT #Set if proxy is started
314 ECS_HTTP_PROXY_CONFIG_HOST_NAME=$HTTP_PROXY_CONFIG_HOST_NAME #Set if proxy is started
315 if [ $ECS_HTTP_PROXY_CONFIG_PORT -eq 0 ] || [ -z "$ECS_HTTP_PROXY_CONFIG_HOST_NAME" ]; then
316 echo -e $YELLOW" Warning: HTTP PROXY will not be configured, proxy app not started"$EYELLOW
318 echo " Configured with http proxy"
321 ECS_HTTP_PROXY_CONFIG_PORT=0
322 ECS_HTTP_PROXY_CONFIG_HOST_NAME=""
323 echo " Configured without http proxy"
325 export ECS_HTTP_PROXY_CONFIG_PORT
326 export ECS_HTTP_PROXY_CONFIG_HOST_NAME
328 dest_file=$SIM_GROUP/$ECS_COMPOSE_DIR/$ECS_HOST_MNT_DIR/$ECS_CONFIG_FILE
330 envsubst < $2 > $dest_file
332 __start_container $ECS_COMPOSE_DIR "" NODOCKERARGS 1 $ECS_APP_NAME
334 __check_service_start $ECS_APP_NAME $ECS_PATH$ECS_ALIVE_URL
342 # (Function for test scripts)
344 echo -e $BOLD"Re-starting ECS"$EBOLD
345 docker restart $ECS_APP_NAME &> ./tmp/.dockererr
346 if [ $? -ne 0 ]; then
347 __print_err "Could not restart $ECS_APP_NAME" $@
353 __check_service_start $ECS_APP_NAME $ECS_PATH$ECS_ALIVE_URL
358 # Turn on debug level tracing in ECS
360 # (Function for test scripts)
362 echo -e $BOLD"Setting ecs debug logging"$EBOLD
363 curlString="$ECS_PATH$ECS_ACTUATOR -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"debug\"}"
364 result=$(__do_curl "$curlString")
365 if [ $? -ne 0 ]; then
366 __print_err "Could not set debug mode" $@
374 # Turn on trace level tracing in ECS
376 # (Function for test scripts)
378 echo -e $BOLD"Setting ecs trace logging"$EBOLD
379 curlString="$ECS_PATH/actuator/loggers/org.oransc.enrichment -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}"
380 result=$(__do_curl "$curlString")
381 if [ $? -ne 0 ]; then
382 __print_err "Could not set trace mode" $@
390 # Perform curl retries when making direct call to ECS for the specified http response codes
391 # Speace separated list of http response codes
392 # args: [<response-code>]*
394 echo -e $BOLD"Do curl retries to the ECS REST inteface for these response codes:$@"$EBOLD
400 # Check the ecs logs for WARNINGs and ERRORs
402 # (Function for test scripts)
404 __check_container_logs "ECS" $ECS_APP_NAME $ECS_LOGPATH WARN ERR
408 # Tests if a variable value in the ECS is equal to a target value and and optional timeout.
409 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
410 # equal to the target or not.
411 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
412 # before setting pass or fail depending on if the variable value becomes equal to the target
414 # (Function for test scripts)
416 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
417 __var_test ECS "$ECS_PATH/" $1 "=" $2 $3
419 __print_err "Wrong args to ecs_equal, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
424 ##########################################
425 ######### A1-E Enrichment API ##########
426 ##########################################
427 #Function prefix: ecs_api_a1
429 # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId}/eijobs
430 # args: <response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
431 # args (flat uri structure): <response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
432 # (Function for test scripts)
433 ecs_api_a1_get_job_ids() {
436 if [ -z "$FLAT_A1_EI" ]; then
437 # Valid number of parameters 4,5,6 etc
438 if [ $# -lt 3 ]; then
439 __print_err "<response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
443 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
444 # Valid number of parameters 4,5,6 etc
445 if [ $# -lt 3 ]; then
446 __print_err "<response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
451 if [ $3 != "NOWNER" ]; then
455 if [ -z "$FLAT_A1_EI" ]; then
456 query="/A1-EI/v1/eitypes/$2/eijobs$search"
458 if [ $2 != "NOTYPE" ]; then
459 if [ -z "$search" ]; then
460 search="?eiTypeId="$2
462 search=$search"&eiTypeId="$2
465 query="/A1-EI/v1/eijobs$search"
467 res="$(__do_curl_to_api ECS GET $query)"
468 status=${res:${#res}-3}
470 if [ $status -ne $1 ]; then
471 __log_test_fail_status_code $1 $status
475 if [ $# -gt 3 ]; then
476 body=${res:0:${#res}-3}
479 for pid in ${@:4} ; do
480 if [ "$targetJson" != "[" ]; then
481 targetJson=$targetJson","
483 if [ $pid != "EMPTY" ]; then
484 targetJson=$targetJson"\"$pid\""
488 targetJson=$targetJson"]"
489 echo " TARGET JSON: $targetJson" >> $HTTPLOG
490 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
492 if [ $res -ne 0 ]; then
502 # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId}
503 # args: <response-code> <type-id> [<schema-file>]
504 # (Function for test scripts)
505 ecs_api_a1_get_type() {
508 if [ $# -lt 2 ] || [ $# -gt 3 ]; then
509 __print_err "<response-code> <type-id> [<schema-file>]" $@
513 query="/A1-EI/v1/eitypes/$2"
514 res="$(__do_curl_to_api ECS GET $query)"
515 status=${res:${#res}-3}
517 if [ $status -ne $1 ]; then
518 __log_test_fail_status_code $1 $status
522 if [ $# -eq 3 ]; then
523 body=${res:0:${#res}-3}
527 __log_test_fail_general "Schema file "$3", does not exist"
530 if [ -z "$FLAT_A1_EI" ]; then
531 targetJson="{\"eiJobParametersSchema\":$schema}"
535 echo " TARGET JSON: $targetJson" >> $HTTPLOG
536 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
538 if [ $res -ne 0 ]; then
548 # API Test function: GET /A1-EI/v1/eitypes
549 # args: <response-code> [ (EMPTY | [<type-id>]+) ]
550 # (Function for test scripts)
551 ecs_api_a1_get_type_ids() {
554 if [ $# -lt 1 ]; then
555 __print_err "<response-code> [ (EMPTY | [<type-id>]+) ]" $@
559 query="/A1-EI/v1/eitypes"
560 res="$(__do_curl_to_api ECS GET $query)"
561 status=${res:${#res}-3}
563 if [ $status -ne $1 ]; then
564 __log_test_fail_status_code $1 $status
567 if [ $# -gt 1 ]; then
568 body=${res:0:${#res}-3}
570 if [ $2 != "EMPTY" ]; then
571 for pid in ${@:2} ; do
572 if [ "$targetJson" != "[" ]; then
573 targetJson=$targetJson","
575 targetJson=$targetJson"\"$pid\""
578 targetJson=$targetJson"]"
579 echo " TARGET JSON: $targetJson" >> $HTTPLOG
580 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
582 if [ $res -ne 0 ]; then
592 # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}/status
593 # args: <response-code> <type-id> <job-id> [<status>]
594 # args (flat uri structure): <response-code> <job-id> [<status> [<timeout>]]
595 # (Function for test scripts)
596 ecs_api_a1_get_job_status() {
599 if [ -z "$FLAT_A1_EI" ]; then
600 if [ $# -ne 3 ] && [ $# -ne 4 ]; then
601 __print_err "<response-code> <type-id> <job-id> [<status>]" $@
605 query="/A1-EI/v1/eitypes/$2/eijobs/$3/status"
607 res="$(__do_curl_to_api ECS GET $query)"
608 status=${res:${#res}-3}
610 if [ $status -ne $1 ]; then
611 __log_test_fail_status_code $1 $status
614 if [ $# -eq 4 ]; then
615 body=${res:0:${#res}-3}
616 targetJson="{\"operationalState\": \"$4\"}"
617 echo " TARGET JSON: $targetJson" >> $HTTPLOG
618 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
620 if [ $res -ne 0 ]; then
626 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
627 if [ $# -lt 2 ] && [ $# -gt 4 ]; then
628 __print_err "<response-code> <job-id> [<status> [<timeout>]]" $@
632 query="/A1-EI/v1/eijobs/$2/status"
636 res="$(__do_curl_to_api ECS GET $query)"
637 status=${res:${#res}-3}
639 if [ $# -eq 4 ]; then
640 duration=$((SECONDS-start))
641 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
642 if [ $duration -gt $4 ]; then
644 duration=-1 #Last iteration
647 duration=-1 #single test, no wait
650 if [ $status -ne $1 ]; then
651 if [ $duration -eq -1 ]; then
652 __log_test_fail_status_code $1 $status
656 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
657 body=${res:0:${#res}-3}
658 targetJson="{\"eiJobStatus\": \"$3\"}"
659 echo " TARGET JSON: $targetJson" >> $HTTPLOG
660 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
662 if [ $res -ne 0 ]; then
663 if [ $duration -eq -1 ]; then
668 duration=-1 #Goto pass
671 if [ $duration -eq -1 ]; then
672 if [ $# -eq 4 ]; then
687 # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}
688 # args: <response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]
689 # args (flat uri structure): <response-code> <job-id> [<type-id> <target-url> <owner-id> <template-job-file>]
690 # (Function for test scripts)
691 ecs_api_a1_get_job() {
694 if [ -z "$FLAT_A1_EI" ]; then
695 if [ $# -ne 3 ] && [ $# -ne 6 ]; then
696 __print_err "<response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]" $@
699 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
701 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
702 if [ $# -ne 2 ] && [ $# -ne 7 ]; then
703 __print_err "<response-code> <job-id> [<type-id> <target-url> <owner-id> <notification-url> <template-job-file>]" $@
706 query="/A1-EI/v1/eijobs/$2"
708 res="$(__do_curl_to_api ECS GET $query)"
709 status=${res:${#res}-3}
711 if [ $status -ne $1 ]; then
712 __log_test_fail_status_code $1 $status
716 if [ -z "$FLAT_A1_EI" ]; then
717 if [ $# -eq 6 ]; then
718 body=${res:0:${#res}-3}
722 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
724 _log_test_fail_general "Job template file "$6", does not exist"
727 targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
728 echo " TARGET JSON: $targetJson" >> $HTTPLOG
729 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
731 if [ $res -ne 0 ]; then
737 if [ $# -eq 7 ]; then
738 body=${res:0:${#res}-3}
742 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
744 _log_test_fail_general "Job template file "$6", does not exist"
747 targetJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
748 echo " TARGET JSON: $targetJson" >> $HTTPLOG
749 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
751 if [ $res -ne 0 ]; then
762 # API Test function: DELETE /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}
763 # args: <response-code> <type-id> <job-id>
764 # args (flat uri structure): <response-code> <job-id>
765 # (Function for test scripts)
766 ecs_api_a1_delete_job() {
769 if [ -z "$FLAT_A1_EI" ]; then
770 if [ $# -ne 3 ]; then
771 __print_err "<response-code> <type-id> <job-id>" $@
775 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
777 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
778 if [ $# -ne 2 ]; then
779 __print_err "<response-code> <job-id>" $@
782 query="/A1-EI/v1/eijobs/$2"
784 res="$(__do_curl_to_api ECS DELETE $query)"
785 status=${res:${#res}-3}
787 if [ $status -ne $1 ]; then
788 __log_test_fail_status_code $1 $status
796 # API Test function: PUT /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}
797 # args: <response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>
798 # args (flat uri structure): <response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file>
799 # (Function for test scripts)
800 ecs_api_a1_put_job() {
803 if [ -z "$FLAT_A1_EI" ]; then
804 if [ $# -lt 6 ]; then
805 __print_err "<response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>" $@
810 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
812 _log_test_fail_general "Job template file "$6", does not exist"
816 inputJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
818 echo "$inputJson" > $file
820 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
822 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
823 if [ $# -lt 7 ]; then
824 __print_err "<response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file>" $@
829 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
831 _log_test_fail_general "Job template file "$7", does not exist"
835 inputJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
837 echo "$inputJson" > $file
839 query="/A1-EI/v1/eijobs/$2"
842 res="$(__do_curl_to_api ECS PUT $query $file)"
843 status=${res:${#res}-3}
845 if [ $status -ne $1 ]; then
846 __log_test_fail_status_code $1 $status
855 ##########################################
856 #### Enrichment Data Producer API ####
857 ##########################################
858 # Function prefix: ecs_api_edp
860 # API Test function: GET /ei-producer/v1/eitypes
861 # args: <response-code> [ EMPTY | <type-id>+]
862 # (Function for test scripts)
863 ecs_api_edp_get_type_ids() {
866 if [ $# -lt 1 ]; then
867 __print_err "<response-code> [ EMPTY | <type-id>+]" $@
871 query="/ei-producer/v1/eitypes"
872 res="$(__do_curl_to_api ECS GET $query)"
873 status=${res:${#res}-3}
875 if [ $status -ne $1 ]; then
876 __log_test_fail_status_code $1 $status
880 if [ $# -gt 1 ]; then
881 body=${res:0:${#res}-3}
883 if [ $2 != "EMPTY" ]; then
884 for pid in ${@:2} ; do
885 if [ "$targetJson" != "[" ]; then
886 targetJson=$targetJson","
888 targetJson=$targetJson"\"$pid\""
891 targetJson=$targetJson"]"
892 echo " TARGET JSON: $targetJson" >> $HTTPLOG
893 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
895 if [ $res -ne 0 ]; then
905 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/status
906 # args: <response-code> <producer-id> [<status> [<timeout>]]
907 # (Function for test scripts)
908 ecs_api_edp_get_producer_status() {
911 if [ $# -lt 2 ] || [ $# -gt 4 ]; then
912 __print_err "<response-code> <producer-id> [<status> [<timeout>]]" $@
916 query="/ei-producer/v1/eiproducers/$2/status"
919 res="$(__do_curl_to_api ECS GET $query)"
920 status=${res:${#res}-3}
922 if [ $# -eq 4 ]; then
923 duration=$((SECONDS-start))
924 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
925 if [ $duration -gt $4 ]; then
927 duration=-1 #Last iteration
930 duration=-1 #single test, no wait
933 if [ $status -ne $1 ]; then
934 if [ $duration -eq -1 ]; then
935 __log_test_fail_status_code $1 $status
939 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
940 body=${res:0:${#res}-3}
941 targetJson="{\"operational_state\": \"$3\"}"
942 echo " TARGET JSON: $targetJson" >> $HTTPLOG
943 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
945 if [ $res -ne 0 ]; then
946 if [ $duration -eq -1 ]; then
951 duration=-1 #Goto pass
954 if [ $duration -eq -1 ]; then
955 if [ $# -eq 4 ]; then
967 # API Test function: GET /ei-producer/v1/eiproducers
968 # args (v1_1): <response-code> [ EMPTY | <producer-id>+]
969 # (Function for test scripts)
970 ecs_api_edp_get_producer_ids() {
973 if [ $# -lt 1 ]; then
974 __print_err "<response-code> [ EMPTY | <producer-id>+]" $@
978 query="/ei-producer/v1/eiproducers"
979 res="$(__do_curl_to_api ECS GET $query)"
980 status=${res:${#res}-3}
982 if [ $status -ne $1 ]; then
983 __log_test_fail_status_code $1 $status
987 if [ $# -gt 1 ]; then
988 body=${res:0:${#res}-3}
991 for pid in ${@:2} ; do
992 if [ "$targetJson" != "[" ]; then
993 targetJson=$targetJson","
995 if [ $pid != "EMPTY" ]; then
996 targetJson=$targetJson"\"$pid\""
1000 targetJson=$targetJson"]"
1001 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1002 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1004 if [ $res -ne 0 ]; then
1005 __log_test_fail_body
1014 # API Test function: GET /ei-producer/v1/eiproducers
1015 # args (v1_2): <response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]
1016 # (Function for test scripts)
1017 ecs_api_edp_get_producer_ids_2() {
1020 if [ $# -lt 1 ]; then
1021 __print_err "<response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]" $@
1025 query="/ei-producer/v1/eiproducers"
1026 if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then
1027 query=$query"?ei_type_id=$2"
1029 res="$(__do_curl_to_api ECS GET $query)"
1030 status=${res:${#res}-3}
1032 if [ $status -ne $1 ]; then
1033 __log_test_fail_status_code $1 $status
1037 if [ $# -gt 2 ]; then
1038 body=${res:0:${#res}-3}
1041 for pid in ${@:3} ; do
1042 if [ "$targetJson" != "[" ]; then
1043 targetJson=$targetJson","
1045 if [ $pid != "EMPTY" ]; then
1046 targetJson=$targetJson"\"$pid\""
1050 targetJson=$targetJson"]"
1051 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1052 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1054 if [ $res -ne 0 ]; then
1055 __log_test_fail_body
1064 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
1065 # args: (v1_1) <response-code> <type-id> [<job-schema-file> (EMPTY | [<producer-id>]+)]
1066 # (Function for test scripts)
1067 ecs_api_edp_get_type() {
1071 if [ $# -eq 2 ]; then
1074 if [ $# -gt 3 ]; then
1077 if [ $paramError -ne 0 ]; then
1078 __print_err "<response-code> <type-id> [<job-schema-file> 'EMPTY' | ([<producer-id>]+)]" $@
1082 query="/ei-producer/v1/eitypes/$2"
1083 res="$(__do_curl_to_api ECS GET $query)"
1084 status=${res:${#res}-3}
1086 if [ $status -ne $1 ]; then
1087 __log_test_fail_status_code $1 $status
1090 if [ $# -gt 3 ]; then
1091 body=${res:0:${#res}-3}
1096 __log_test_fail_general "Job template file "$3", does not exist"
1101 if [ $4 != "EMPTY" ]; then
1102 for pid in ${@:4} ; do
1103 if [ "$targetJson" != "" ]; then
1104 targetJson=$targetJson","
1106 targetJson=$targetJson"\"$pid\""
1109 targetJson="{\"ei_job_data_schema\":$schema, \"ei_producer_ids\": [$targetJson]}"
1111 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1112 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1114 if [ $res -ne 0 ]; then
1115 __log_test_fail_body
1123 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
1124 # args: (v1_2) <response-code> <type-id> [<job-schema-file> ]
1125 # (Function for test scripts)
1126 ecs_api_edp_get_type_2() {
1130 if [ $# -eq 2 ]; then
1133 if [ $# -eq 3 ]; then
1136 if [ $paramError -ne 0 ]; then
1137 __print_err "<response-code> <type-id> [<job-schema-file> ]" $@
1141 query="/ei-producer/v1/eitypes/$2"
1142 res="$(__do_curl_to_api ECS GET $query)"
1143 status=${res:${#res}-3}
1145 if [ $status -ne $1 ]; then
1146 __log_test_fail_status_code $1 $status
1149 if [ $# -eq 3 ]; then
1150 body=${res:0:${#res}-3}
1155 __log_test_fail_general "Job template file "$3", does not exist"
1159 targetJson="{\"ei_job_data_schema\":$schema}"
1161 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1162 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1164 if [ $res -ne 0 ]; then
1165 __log_test_fail_body
1173 # API Test function: PUT /ei-producer/v1/eitypes/{eiTypeId}
1174 # args: (v1_2) <response-code> <type-id> <job-schema-file>
1175 # (Function for test scripts)
1176 ecs_api_edp_put_type_2() {
1179 if [ $# -ne 3 ]; then
1180 __print_err "<response-code> <type-id> <job-schema-file>" $@
1184 if [ ! -f $3 ]; then
1185 __log_test_fail_general "Job schema file "$3", does not exist"
1189 input_json="{\"ei_job_data_schema\":$schema}"
1190 file="./tmp/put_type.json"
1191 echo $input_json > $file
1193 query="/ei-producer/v1/eitypes/$2"
1194 res="$(__do_curl_to_api ECS PUT $query $file)"
1195 status=${res:${#res}-3}
1197 if [ $status -ne $1 ]; then
1198 __log_test_fail_status_code $1 $status
1206 # API Test function: DELETE /ei-producer/v1/eitypes/{eiTypeId}
1207 # args: (v1_2) <response-code> <type-id>
1208 # (Function for test scripts)
1209 ecs_api_edp_delete_type_2() {
1212 if [ $# -ne 2 ]; then
1213 __print_err "<response-code> <type-id>" $@
1217 query="/ei-producer/v1/eitypes/$2"
1218 res="$(__do_curl_to_api ECS DELETE $query)"
1219 status=${res:${#res}-3}
1221 if [ $status -ne $1 ]; then
1222 __log_test_fail_status_code $1 $status
1230 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
1231 # args: (v1_1) <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | [<type-id> <schema-file>]+) ]
1232 # (Function for test scripts)
1233 ecs_api_edp_get_producer() {
1236 #Possible arg count: 2, 5 6, 8, 10 etc
1238 if [ $# -eq 2 ]; then
1241 if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then
1244 variablecount=$(($#-4))
1245 if [ $# -gt 5 ] && [ $(($variablecount%2)) -eq 0 ]; then
1249 if [ $paramError -ne 0 ]; then
1250 __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (NOID | [<type-id> <schema-file>]+) ]" $@
1254 query="/ei-producer/v1/eiproducers/$2"
1255 res="$(__do_curl_to_api ECS GET $query)"
1256 status=${res:${#res}-3}
1258 if [ $status -ne $1 ]; then
1259 __log_test_fail_status_code $1 $status
1263 if [ $# -gt 2 ]; then
1264 body=${res:0:${#res}-3}
1266 if [ $# -gt 5 ]; then
1268 for ((i=0; i<$(($#-5)); i=i+2)); do
1269 if [ "$targetJson" != "[" ]; then
1270 targetJson=$targetJson","
1272 if [ -f ${arr[$i+1]} ]; then
1273 schema=$(cat ${arr[$i+1]})
1275 _log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
1279 targetJson=$targetJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
1282 targetJson=$targetJson"]"
1283 if [ $# -gt 4 ]; then
1284 targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
1286 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1287 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1289 if [ $res -ne 0 ]; then
1290 __log_test_fail_body
1299 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
1300 # args (v1_2): <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]
1301 # (Function for test scripts)
1302 ecs_api_edp_get_producer_2() {
1305 #Possible arg count: 2, 5, 6, 7, 8 etc
1307 if [ $# -eq 2 ]; then
1310 if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then
1313 if [ $# -ge 5 ]; then
1317 if [ $paramError -ne 0 ]; then
1318 __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]" $@
1322 query="/ei-producer/v1/eiproducers/$2"
1323 res="$(__do_curl_to_api ECS GET $query)"
1324 status=${res:${#res}-3}
1326 if [ $status -ne $1 ]; then
1327 __log_test_fail_status_code $1 $status
1331 if [ $# -gt 2 ]; then
1332 body=${res:0:${#res}-3}
1334 if [ $# -gt 4 ] && [ "$5" != "EMPTY" ]; then
1336 for ((i=0; i<$(($#-4)); i=i+1)); do
1337 if [ "$targetJson" != "[" ]; then
1338 targetJson=$targetJson","
1340 targetJson=$targetJson"\"${arr[$i]}\""
1343 targetJson=$targetJson"]"
1344 if [ $# -gt 4 ]; then
1345 targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
1347 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1348 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1350 if [ $res -ne 0 ]; then
1351 __log_test_fail_body
1360 # API Test function: DELETE /ei-producer/v1/eiproducers/{eiProducerId}
1361 # args: <response-code> <producer-id>
1362 # (Function for test scripts)
1363 ecs_api_edp_delete_producer() {
1366 if [ $# -lt 2 ]; then
1367 __print_err "<response-code> <producer-id>" $@
1371 query="/ei-producer/v1/eiproducers/$2"
1372 res="$(__do_curl_to_api ECS DELETE $query)"
1373 status=${res:${#res}-3}
1375 if [ $status -ne $1 ]; then
1376 __log_test_fail_status_code $1 $status
1384 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
1385 # args: (v1_1) <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+
1386 # (Function for test scripts)
1387 ecs_api_edp_put_producer() {
1390 #Valid number of parametrer 5,6,8,10,
1392 if [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then
1394 elif [ $# -gt 5 ] && [ $(($#%2)) -eq 0 ]; then
1397 if [ $paramError -ne 0 ]; then
1398 __print_err "<response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+" $@
1403 if [ $# -gt 5 ]; then
1405 for ((i=0; i<$(($#-5)); i=i+2)); do
1406 if [ "$inputJson" != "[" ]; then
1407 inputJson=$inputJson","
1409 if [ -f ${arr[$i+1]} ]; then
1410 schema=$(cat ${arr[$i+1]})
1412 _log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
1415 inputJson=$inputJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
1418 inputJson="\"supported_ei_types\":"$inputJson"]"
1420 inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
1422 inputJson="{"$inputJson"}"
1424 file="./tmp/.p.json"
1425 echo "$inputJson" > $file
1426 query="/ei-producer/v1/eiproducers/$2"
1427 res="$(__do_curl_to_api ECS PUT $query $file)"
1428 status=${res:${#res}-3}
1430 if [ $status -ne $1 ]; then
1431 __log_test_fail_status_code $1 $status
1439 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
1440 # args: (v1_2) <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]
1441 # (Function for test scripts)
1442 ecs_api_edp_put_producer_2() {
1445 #Valid number of parametrer 5,6,8,10,
1447 if [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then
1449 elif [ $# -ge 5 ]; then
1452 if [ $paramError -ne 0 ]; then
1453 __print_err "<response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]" $@
1458 if [ $# -gt 4 ] && [ "$5" != "NOTYPE" ]; then
1460 for ((i=0; i<$(($#-4)); i=i+1)); do
1461 if [ "$inputJson" != "[" ]; then
1462 inputJson=$inputJson","
1464 inputJson=$inputJson"\""${arr[$i]}"\""
1467 inputJson="\"supported_ei_types\":"$inputJson"]"
1469 inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
1471 inputJson="{"$inputJson"}"
1473 file="./tmp/.p.json"
1474 echo "$inputJson" > $file
1475 query="/ei-producer/v1/eiproducers/$2"
1476 res="$(__do_curl_to_api ECS PUT $query $file)"
1477 status=${res:${#res}-3}
1479 if [ $status -ne $1 ]; then
1480 __log_test_fail_status_code $1 $status
1488 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
1489 # args: (V1-1) <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)
1490 # (Function for test scripts)
1491 ecs_api_edp_get_producer_jobs() {
1494 #Valid number of parameter 2,3,7,11
1496 if [ $# -eq 2 ]; then
1499 if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
1502 variablecount=$(($#-2))
1503 if [ $# -gt 3 ] && [ $(($variablecount%5)) -eq 0 ]; then
1506 if [ $paramError -eq 1 ]; then
1507 __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)" $@
1511 query="/ei-producer/v1/eiproducers/$2/eijobs"
1512 res="$(__do_curl_to_api ECS GET $query)"
1513 status=${res:${#res}-3}
1514 if [ $status -ne $1 ]; then
1515 __log_test_fail_status_code $1 $status
1518 if [ $# -gt 2 ]; then
1519 body=${res:0:${#res}-3}
1521 if [ $# -gt 3 ]; then
1523 for ((i=0; i<$(($#-3)); i=i+5)); do
1524 if [ "$targetJson" != "[" ]; then
1525 targetJson=$targetJson","
1527 if [ -f ${arr[$i+4]} ]; then
1528 jobfile=$(cat ${arr[$i+4]})
1529 jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
1531 _log_test_fail_general "Job template file "${arr[$i+4]}", does not exist"
1534 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}"
1537 targetJson=$targetJson"]"
1539 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1540 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1542 if [ $res -ne 0 ]; then
1543 __log_test_fail_body
1552 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
1553 # args: (V1-2) <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)
1554 # (Function for test scripts)
1555 ecs_api_edp_get_producer_jobs_2() {
1558 #Valid number of parameter 2,3,7,11
1560 if [ $# -eq 2 ]; then
1563 if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
1566 variablecount=$(($#-2))
1567 if [ $# -gt 3 ] && [ $(($variablecount%5)) -eq 0 ]; then
1570 if [ $paramError -eq 1 ]; then
1571 __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)" $@
1575 query="/ei-producer/v1/eiproducers/$2/eijobs"
1576 res="$(__do_curl_to_api ECS GET $query)"
1577 status=${res:${#res}-3}
1578 if [ $status -ne $1 ]; then
1579 __log_test_fail_status_code $1 $status
1582 if [ $# -gt 2 ]; then
1583 body=${res:0:${#res}-3}
1585 if [ $# -gt 3 ]; then
1587 for ((i=0; i<$(($#-3)); i=i+5)); do
1588 if [ "$targetJson" != "[" ]; then
1589 targetJson=$targetJson","
1591 if [ -f ${arr[$i+4]} ]; then
1592 jobfile=$(cat ${arr[$i+4]})
1593 jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
1595 _log_test_fail_general "Job template file "${arr[$i+4]}", does not exist"
1598 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\":\"????\"}"
1601 targetJson=$targetJson"]"
1603 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1604 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1606 if [ $res -ne 0 ]; then
1607 __log_test_fail_body
1616 ##########################################
1617 #### Service status ####
1618 ##########################################
1619 # Function prefix: ecs_api_service
1621 # API Test function: GET /status
1622 # args: <response-code>
1623 # (Function for test scripts)
1624 ecs_api_service_status() {
1627 if [ $# -lt 1 ]; then
1628 __print_err "<response-code> [<producer-id>]*|NOID" $@
1631 res="$(__do_curl_to_api ECS GET /status)"
1632 status=${res:${#res}-3}
1633 if [ $status -ne $1 ]; then
1634 __log_test_fail_status_code $1 $status
1642 ##########################################
1643 #### Reset jobs ####
1644 ##########################################
1645 # Function prefix: ecs_api_admin
1647 # Admin to remove all jobs
1648 # args: <response-code> [ <type> ]
1649 # (Function for test scripts)
1651 ecs_api_admin_reset() {
1654 if [ -z "$FLAT_A1_EI" ]; then
1655 query="/A1-EI/v1/eitypes/$2/eijobs"
1657 query="/A1-EI/v1/eijobs"
1659 res="$(__do_curl_to_api ECS GET $query)"
1660 status=${res:${#res}-3}
1662 if [ $status -ne 200 ]; then
1663 __log_test_fail_status_code $1 $status
1667 #Remove brackets and response code
1668 body=${res:1:${#res}-4}
1669 list=$(echo ${body//,/ })
1670 list=$(echo ${list//[/})
1671 list=$(echo ${list//]/})
1672 list=$(echo ${list//\"/})
1674 for job in $list; do
1675 if [ -z "$FLAT_A1_EI" ]; then
1676 echo "Not supported for non-flat EI api"
1678 query="/A1-EI/v1/eijobs/$job"
1679 res="$(__do_curl_to_api ECS DELETE $query)"
1680 status=${res:${#res}-3}
1681 if [ $status -ne 204 ]; then
1682 __log_test_fail_status_code $1 $status
1685 echo " Deleted job: "$job