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 specific test functions for ECS NB/SB API
22 . ../common/api_curl.sh
24 ############### EXPERIMENTAL #############
26 ##########################################
27 ###### Mainly only function skeletons ####
28 ##########################################
30 ##########################################
31 ### A1-E Enrichment Data Consumer API ####
32 ##########################################
33 #Function prefix: ecs_api_a1
35 # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId}/eijobs
36 # args: <response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
37 # (Function for test scripts)
38 ecs_api_a1_get_job_ids() {
39 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
40 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
43 # Valid number of parameters 3,4,5,6 etc
45 __print_err "<response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
49 if [ $3 != "NOWNER" ]; then
53 query="/A1-EI/v1/eitypes/$2/eijobs$owner"
54 res="$(__do_curl_to_api ECS GET $query)"
55 status=${res:${#res}-3}
57 if [ $status -ne $1 ]; then
58 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
65 body=${res:0:${#res}-3}
68 for pid in ${@:4} ; do
69 if [ "$targetJson" != "[" ]; then
70 targetJson=$targetJson","
72 if [ $pid != "EMPTY" ]; then
73 targetJson=$targetJson"\"$pid\""
77 targetJson=$targetJson"]"
78 echo " TARGET JSON: $targetJson" >> $HTTPLOG
79 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
81 if [ $res -ne 0 ]; then
82 echo -e $RED" FAIL, returned body not correct"$ERED
90 echo -e $GREEN" PASS"$EGREEN
94 # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId}
95 # args: <response-code> <type-id> [<schema-file>]
96 # (Function for test scripts)
97 ecs_api_a1_get_type() {
98 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
99 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
102 if [ $# -lt 2 ] || [ $# -gt 3 ]; then
103 __print_err "<response-code> <type-id> [<schema-file>]" $@
107 query="/A1-EI/v1/eitypes/$2"
108 res="$(__do_curl_to_api ECS GET $query)"
109 status=${res:${#res}-3}
111 if [ $status -ne $1 ]; then
112 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
114 __check_stop_at_error
118 if [ $# -eq 3 ]; then
119 body=${res:0:${#res}-3}
123 echo -e $RED" FAIL. Schema file "$3", does not exist"$ERED
125 __check_stop_at_error
128 targetJson="{\"eiJobParametersSchema\":$schema}"
129 echo " TARGET JSON: $targetJson" >> $HTTPLOG
130 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
132 if [ $res -ne 0 ]; then
133 echo -e $RED" FAIL, returned body not correct"$ERED
135 __check_stop_at_error
142 echo -e $GREEN" PASS"$EGREEN
146 # API Test function: GET /A1-EI/v1/eitypes
147 # args: <response-code> (EMPTY | [<type-id>]+)
148 # (Function for test scripts)
149 ecs_api_a1_get_type_ids() {
150 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
151 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
154 if [ $# -lt 2 ]; then
155 __print_err "<response-code> (EMPTY | [<type-id>]+)" $@
159 query="/A1-EI/v1/eitypes"
160 res="$(__do_curl_to_api ECS GET $query)"
161 status=${res:${#res}-3}
163 if [ $status -ne $1 ]; then
164 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
166 __check_stop_at_error
169 body=${res:0:${#res}-3}
171 if [ $2 != "EMPTY" ]; then
172 for pid in ${@:2} ; do
173 if [ "$targetJson" != "[" ]; then
174 targetJson=$targetJson","
176 targetJson=$targetJson"\"$pid\""
179 targetJson=$targetJson"]"
180 echo " TARGET JSON: $targetJson" >> $HTTPLOG
181 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
183 if [ $res -ne 0 ]; then
184 echo -e $RED" FAIL, returned body not correct"$ERED
186 __check_stop_at_error
191 echo -e $GREEN" PASS"$EGREEN
195 # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}/status
196 # args: <response-code> <type-id> <job-id> [<status>]
197 # (Function for test scripts)
198 ecs_api_a1_get_job_status() {
199 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
200 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
203 if [ $# -ne 3 ] && [ $# -ne 4 ]; then
204 __print_err "<response-code> <type-id> <job-id>" $@
208 query="/A1-EI/v1/eitypes/$2/eijobs/$3/status"
209 res="$(__do_curl_to_api ECS GET $query)"
210 status=${res:${#res}-3}
212 if [ $status -ne $1 ]; then
213 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
215 __check_stop_at_error
218 if [ $# -eq 4 ]; then
219 body=${res:0:${#res}-3}
220 targetJson="{\"operationalState\": \"$4\"}"
221 echo " TARGET JSON: $targetJson" >> $HTTPLOG
222 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
224 if [ $res -ne 0 ]; then
225 echo -e $RED" FAIL, returned body not correct"$ERED
227 __check_stop_at_error
233 echo -e $GREEN" PASS"$EGREEN
237 # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}
238 # args: <response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]
239 # (Function for test scripts)
240 ecs_api_a1_get_job() {
241 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
242 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
245 if [ $# -ne 3 ] && [ $# -ne 6 ]; then
246 __print_err "<response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]" $@
250 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
251 res="$(__do_curl_to_api ECS GET $query)"
252 status=${res:${#res}-3}
254 if [ $status -ne $1 ]; then
255 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
257 __check_stop_at_error
261 if [ $# -eq 6 ]; then
262 body=${res:0:${#res}-3}
266 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
268 echo -e $RED" FAIL. Job template file "$6", does not exist"$ERED
270 __check_stop_at_error
273 targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
274 echo " TARGET JSON: $targetJson" >> $HTTPLOG
275 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
277 if [ $res -ne 0 ]; then
278 echo -e $RED" FAIL, returned body not correct"$ERED
280 __check_stop_at_error
286 echo -e $GREEN" PASS"$EGREEN
290 # API Test function: DELETE /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}
291 # args: <response-code> <type-id> <job-id>
292 # (Function for test scripts)
293 ecs_api_a1_delete_job() {
294 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
295 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
298 if [ $# -lt 3 ]; then
299 __print_err "<response-code> <type-id> <job-id>" $@
303 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
304 res="$(__do_curl_to_api ECS DELETE $query)"
305 status=${res:${#res}-3}
307 if [ $status -ne $1 ]; then
308 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
310 __check_stop_at_error
315 echo -e $GREEN" PASS"$EGREEN
319 # API Test function: PUT /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}
320 # args: <response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>
321 # (Function for test scripts)
322 ecs_api_a1_put_job() {
323 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
324 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
327 if [ $# -lt 6 ]; then
328 __print_err "<response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>" $@
333 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
335 echo -e $RED" FAIL. Job template file "$6", does not exist"$ERED
337 __check_stop_at_error
341 inputJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
343 echo "$inputJson" > $file
345 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
346 res="$(__do_curl_to_api ECS PUT $query $file)"
347 status=${res:${#res}-3}
349 if [ $status -ne $1 ]; then
350 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
352 __check_stop_at_error
357 echo -e $GREEN" PASS"$EGREEN
362 ##########################################
363 #### Enrichment Data Producer API ####
364 ##########################################
365 # Function prefix: ecs_api_edp
367 # API Test function: GET /ei-producer/v1/eitypes
368 # args: <response-code> [ EMPTY | <type-id>+]
369 # (Function for test scripts)
370 ecs_api_edp_get_type_ids() {
371 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
372 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
375 if [ $# -lt 1 ]; then
376 __print_err "<response-code> [ EMPTY | <type-id>+]" $@
380 query="/ei-producer/v1/eitypes"
381 res="$(__do_curl_to_api ECS GET $query)"
382 status=${res:${#res}-3}
384 if [ $status -ne $1 ]; then
385 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
387 __check_stop_at_error
391 if [ $# -gt 1 ]; then
392 body=${res:0:${#res}-3}
394 if [ $2 != "EMPTY" ]; then
395 for pid in ${@:2} ; do
396 if [ "$targetJson" != "[" ]; then
397 targetJson=$targetJson","
399 targetJson=$targetJson"\"$pid\""
402 targetJson=$targetJson"]"
403 echo " TARGET JSON: $targetJson" >> $HTTPLOG
404 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
406 if [ $res -ne 0 ]; then
407 echo -e $RED" FAIL, returned body not correct"$ERED
409 __check_stop_at_error
415 echo -e $GREEN" PASS"$EGREEN
419 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/status
420 # args: <response-code> <producer-id> [<status>]
421 # (Function for test scripts)
422 ecs_api_edp_get_producer_status() {
423 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
424 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
427 if [ $# -lt 2 ] || [ $# -gt 3 ]; then
428 __print_err "<response-code> <producer-id> <status>" $@
432 query="/ei-producer/v1/eiproducers/$2/status"
433 res="$(__do_curl_to_api ECS GET $query)"
434 status=${res:${#res}-3}
436 if [ $status -ne $1 ]; then
437 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
439 __check_stop_at_error
442 if [ $# -eq 3 ]; then
443 body=${res:0:${#res}-3}
444 targetJson="{\"operational_state\": \"$3\"}"
445 echo " TARGET JSON: $targetJson" >> $HTTPLOG
446 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
448 if [ $res -ne 0 ]; then
449 echo -e $RED" FAIL, returned body not correct"$ERED
451 __check_stop_at_error
457 echo -e $GREEN" PASS"$EGREEN
462 # API Test function: GET /ei-producer/v1/eiproducers
463 # args: <response-code> [ EMPTY | <producer-id>+]
464 # (Function for test scripts)
465 ecs_api_edp_get_producer_ids() {
466 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
467 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
470 if [ $# -lt 1 ]; then
471 __print_err "<response-code> [ EMPTY | <producer-id>+]" $@
475 query="/ei-producer/v1/eiproducers"
476 res="$(__do_curl_to_api ECS GET $query)"
477 status=${res:${#res}-3}
479 if [ $status -ne $1 ]; then
480 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
482 __check_stop_at_error
486 if [ $# -gt 1 ]; then
487 body=${res:0:${#res}-3}
490 for pid in ${@:2} ; do
491 if [ "$targetJson" != "[" ]; then
492 targetJson=$targetJson","
494 if [ $pid != "EMPTY" ]; then
495 targetJson=$targetJson"\"$pid\""
499 targetJson=$targetJson"]"
500 echo " TARGET JSON: $targetJson" >> $HTTPLOG
501 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
503 if [ $res -ne 0 ]; then
504 echo -e $RED" FAIL, returned body not correct"$ERED
506 __check_stop_at_error
512 echo -e $GREEN" PASS"$EGREEN
516 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
517 # args: <response-code> <type-id> [<job-schema-file> (NOID | [<producer-id>]+)]
518 # (Function for test scripts)
519 ecs_api_edp_get_type() {
520 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
521 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
525 if [ $# -eq 2 ]; then
528 if [ $# -gt 3 ]; then
531 if [ $paramError -ne 0 ]; then
532 __print_err "<response-code> <type-id> [<job-schema-file> NOID | ([<producer-id>]+)]" $@
536 query="/ei-producer/v1/eitypes/$2"
537 res="$(__do_curl_to_api ECS GET $query)"
538 status=${res:${#res}-3}
540 if [ $status -ne $1 ]; then
541 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
543 __check_stop_at_error
546 if [ $# -gt 3 ]; then
547 body=${res:0:${#res}-3}
552 echo -e $RED" FAIL. Job template file "$3", does not exist"$ERED
554 __check_stop_at_error
559 if [ $4 != "EMPTY" ]; then
560 for pid in ${@:4} ; do
561 if [ "$targetJson" != "" ]; then
562 targetJson=$targetJson","
564 targetJson=$targetJson"\"$pid\""
567 targetJson="{\"ei_job_data_schema\":$schema, \"ei_producer_ids\": [$targetJson]}"
569 echo " TARGET JSON: $targetJson" >> $HTTPLOG
570 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
572 if [ $res -ne 0 ]; then
573 echo -e $RED" FAIL, returned body not correct"$ERED
575 __check_stop_at_error
580 echo -e $GREEN" PASS"$EGREEN
584 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
585 # args: <response-code> <producer-id> [<create-callback> <delete-callback> <supervision-callback> (EMPTY | [<type-id> <schema-file>]+) ]
586 # (Function for test scripts)
587 ecs_api_edp_get_producer() {
588 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
589 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
592 #Possible arg count: 2, 6 7, 9, 11 etc
594 if [ $# -eq 2 ]; then
597 if [ $# -eq 6 ] && [ "$6" == "EMPTY" ]; then
600 variablecount=$(($#-5))
601 if [ $# -gt 5 ] && [ $(($variablecount%2)) -eq 0 ]; then
605 if [ $paramError -ne 0 ]; then
606 __print_err "<response-code> <producer-id> [<create-callback> <delete-callback> <supervision-callback> (NOID | [<type-id> <schema-file>]+) ]" $@
610 query="/ei-producer/v1/eiproducers/$2"
611 res="$(__do_curl_to_api ECS GET $query)"
612 status=${res:${#res}-3}
614 if [ $status -ne $1 ]; then
615 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
617 __check_stop_at_error
621 if [ $# -gt 2 ]; then
622 body=${res:0:${#res}-3}
624 if [ $# -gt 6 ]; then
626 for ((i=0; i<$(($#-6)); i=i+2)); do
627 if [ "$targetJson" != "[" ]; then
628 targetJson=$targetJson","
630 if [ -f ${arr[$i+1]} ]; then
631 schema=$(cat ${arr[$i+1]})
633 echo -e $RED" FAIL. Schema file "${arr[$i+1]}", does not exist"$ERED
635 __check_stop_at_error
639 targetJson=$targetJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
642 targetJson=$targetJson"]"
643 if [ $# -gt 4 ]; then
644 targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_creation_callback_url\": \"$3\",\"ei_job_deletion_callback_url\": \"$4\",\"ei_producer_supervision_callback_url\": \"$5\"}"
646 echo " TARGET JSON: $targetJson" >> $HTTPLOG
647 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
649 if [ $res -ne 0 ]; then
650 echo -e $RED" FAIL, returned body not correct"$ERED
652 __check_stop_at_error
658 echo -e $GREEN" PASS"$EGREEN
662 # API Test function: DELETE /ei-producer/v1/eiproducers/{eiProducerId}
663 # args: <response-code> <producer-id>
664 # (Function for test scripts)
665 ecs_api_edp_delete_producer() {
666 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
667 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
670 if [ $# -lt 2 ]; then
671 __print_err "<response-code> <producer-id>" $@
675 query="/ei-producer/v1/eiproducers/$2"
676 res="$(__do_curl_to_api ECS DELETE $query)"
677 status=${res:${#res}-3}
679 if [ $status -ne $1 ]; then
680 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
682 __check_stop_at_error
687 echo -e $GREEN" PASS"$EGREEN
691 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
692 # args: <response-code> <producer-id> <create-callback> <delete-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+
693 # (Function for test scripts)
694 ecs_api_edp_put_producer() {
695 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
696 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
699 #Valid number of parametrer 6,7,9,11,
701 if [ $# -eq 6 ] && [ "$6" == "NOTYPE" ]; then
703 elif [ $# -gt 6 ] && [ $(($#%2)) -eq 1 ]; then
706 if [ $paramError -ne 0 ]; then
707 __print_err "<response-code> <producer-id> <create-callback> <delete-callback> <supervision-callback> [<type-id> <schema-file>]+" $@
712 if [ $# -gt 6 ]; then
714 for ((i=0; i<$(($#-6)); i=i+2)); do
715 if [ "$inputJson" != "[" ]; then
716 inputJson=$inputJson","
718 if [ -f ${arr[$i+1]} ]; then
719 schema=$(cat ${arr[$i+1]})
721 echo -e $RED" FAIL. Schema file "${arr[$i+1]}", does not exist"$ERED
723 __check_stop_at_error
726 inputJson=$inputJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
729 inputJson="\"supported_ei_types\":"$inputJson"]"
731 inputJson=$inputJson",\"ei_job_creation_callback_url\": \"$3\",\"ei_job_deletion_callback_url\": \"$4\",\"ei_producer_supervision_callback_url\": \"$5\""
733 inputJson="{"$inputJson"}"
736 echo "$inputJson" > $file
737 query="/ei-producer/v1/eiproducers/$2"
738 res="$(__do_curl_to_api ECS PUT $query $file)"
739 status=${res:${#res}-3}
741 if [ $status -ne $1 ]; then
742 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
744 __check_stop_at_error
749 echo -e $GREEN" PASS"$EGREEN
753 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
754 # args: <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <template-job-file>]+)
755 # (Function for test scripts)
756 ecs_api_edp_get_producer_jobs() {
757 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
758 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
761 #Valid number of parameter 2,3,6,10
763 if [ $# -eq 2 ]; then
766 if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
769 variablecount=$(($#-2))
770 if [ $# -gt 3 ] && [ $(($variablecount%4)) -eq 0 ]; then
773 if [ $paramError -eq 1 ]; then
774 __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <template-job-file>]+)" $@
778 query="/ei-producer/v1/eiproducers/$2/eijobs"
779 res="$(__do_curl_to_api ECS GET $query)"
780 status=${res:${#res}-3}
781 if [ $status -ne $1 ]; then
782 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
784 __check_stop_at_error
787 if [ $# -gt 2 ]; then
788 body=${res:0:${#res}-3}
790 if [ $# -gt 3 ]; then
792 for ((i=0; i<$(($#-3)); i=i+4)); do
793 if [ "$targetJson" != "[" ]; then
794 targetJson=$targetJson","
796 if [ -f ${arr[$i+3]} ]; then
797 jobfile=$(cat ${arr[$i+3]})
798 jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
800 echo -e $RED" FAIL. Job template file "${arr[$i+3]}", does not exist"$ERED
802 __check_stop_at_error
805 targetJson=$targetJson"{\"ei_job_identity\":\"${arr[$i]}\",\"ei_type_identity\":\"${arr[$i+1]}\",\"target_uri\":\"${arr[$i+2]}\",\"ei_job_data\":$jobfile}"
808 targetJson=$targetJson"]"
810 echo " TARGET JSON: $targetJson" >> $HTTPLOG
811 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
813 if [ $res -ne 0 ]; then
814 echo -e $RED" FAIL, returned body not correct"$ERED
816 __check_stop_at_error
822 echo -e $GREEN" PASS"$EGREEN
827 ##########################################
828 #### Service status ####
829 ##########################################
830 # Function prefix: ecs_api_service
832 # API Test function: GET /status
833 # args: <response-code>
834 # (Function for test scripts)
835 ecs_api_service_status() {
836 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
837 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
840 if [ $# -lt 1 ]; then
841 __print_err "<response-code> [<producer-id>]*|NOID" $@
846 echo -e $GREEN" PASS"$EGREEN