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 1 ]; 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 if [ $# -gt 1 ]; then
170 body=${res:0:${#res}-3}
172 if [ $2 != "EMPTY" ]; then
173 for pid in ${@:2} ; do
174 if [ "$targetJson" != "[" ]; then
175 targetJson=$targetJson","
177 targetJson=$targetJson"\"$pid\""
180 targetJson=$targetJson"]"
181 echo " TARGET JSON: $targetJson" >> $HTTPLOG
182 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
184 if [ $res -ne 0 ]; then
185 echo -e $RED" FAIL, returned body not correct"$ERED
187 __check_stop_at_error
193 echo -e $GREEN" PASS"$EGREEN
197 # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}/status
198 # args: <response-code> <type-id> <job-id> [<status>]
199 # (Function for test scripts)
200 ecs_api_a1_get_job_status() {
201 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
202 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
205 if [ $# -ne 3 ] && [ $# -ne 4 ]; then
206 __print_err "<response-code> <type-id> <job-id>" $@
210 query="/A1-EI/v1/eitypes/$2/eijobs/$3/status"
211 res="$(__do_curl_to_api ECS GET $query)"
212 status=${res:${#res}-3}
214 if [ $status -ne $1 ]; then
215 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
217 __check_stop_at_error
220 if [ $# -eq 4 ]; then
221 body=${res:0:${#res}-3}
222 targetJson="{\"operationalState\": \"$4\"}"
223 echo " TARGET JSON: $targetJson" >> $HTTPLOG
224 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
226 if [ $res -ne 0 ]; then
227 echo -e $RED" FAIL, returned body not correct"$ERED
229 __check_stop_at_error
235 echo -e $GREEN" PASS"$EGREEN
239 # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}
240 # args: <response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]
241 # (Function for test scripts)
242 ecs_api_a1_get_job() {
243 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
244 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
247 if [ $# -ne 3 ] && [ $# -ne 6 ]; then
248 __print_err "<response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]" $@
252 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
253 res="$(__do_curl_to_api ECS GET $query)"
254 status=${res:${#res}-3}
256 if [ $status -ne $1 ]; then
257 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
259 __check_stop_at_error
263 if [ $# -eq 6 ]; then
264 body=${res:0:${#res}-3}
268 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
270 echo -e $RED" FAIL. Job template file "$6", does not exist"$ERED
272 __check_stop_at_error
275 targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
276 echo " TARGET JSON: $targetJson" >> $HTTPLOG
277 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
279 if [ $res -ne 0 ]; then
280 echo -e $RED" FAIL, returned body not correct"$ERED
282 __check_stop_at_error
288 echo -e $GREEN" PASS"$EGREEN
292 # API Test function: DELETE /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}
293 # args: <response-code> <type-id> <job-id>
294 # (Function for test scripts)
295 ecs_api_a1_delete_job() {
296 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
297 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
300 if [ $# -lt 3 ]; then
301 __print_err "<response-code> <type-id> <job-id>" $@
305 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
306 res="$(__do_curl_to_api ECS DELETE $query)"
307 status=${res:${#res}-3}
309 if [ $status -ne $1 ]; then
310 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
312 __check_stop_at_error
317 echo -e $GREEN" PASS"$EGREEN
321 # API Test function: PUT /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}
322 # args: <response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>
323 # (Function for test scripts)
324 ecs_api_a1_put_job() {
325 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
326 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
329 if [ $# -lt 6 ]; then
330 __print_err "<response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>" $@
335 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
337 echo -e $RED" FAIL. Job template file "$6", does not exist"$ERED
339 __check_stop_at_error
343 inputJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
345 echo "$inputJson" > $file
347 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
348 res="$(__do_curl_to_api ECS PUT $query $file)"
349 status=${res:${#res}-3}
351 if [ $status -ne $1 ]; then
352 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
354 __check_stop_at_error
359 echo -e $GREEN" PASS"$EGREEN
364 ##########################################
365 #### Enrichment Data Producer API ####
366 ##########################################
367 # Function prefix: ecs_api_edp
369 # API Test function: GET /ei-producer/v1/eitypes
370 # args: <response-code> [ EMPTY | <type-id>+]
371 # (Function for test scripts)
372 ecs_api_edp_get_type_ids() {
373 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
374 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
377 if [ $# -lt 1 ]; then
378 __print_err "<response-code> [ EMPTY | <type-id>+]" $@
382 query="/ei-producer/v1/eitypes"
383 res="$(__do_curl_to_api ECS GET $query)"
384 status=${res:${#res}-3}
386 if [ $status -ne $1 ]; then
387 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
389 __check_stop_at_error
393 if [ $# -gt 1 ]; then
394 body=${res:0:${#res}-3}
396 if [ $2 != "EMPTY" ]; then
397 for pid in ${@:2} ; do
398 if [ "$targetJson" != "[" ]; then
399 targetJson=$targetJson","
401 targetJson=$targetJson"\"$pid\""
404 targetJson=$targetJson"]"
405 echo " TARGET JSON: $targetJson" >> $HTTPLOG
406 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
408 if [ $res -ne 0 ]; then
409 echo -e $RED" FAIL, returned body not correct"$ERED
411 __check_stop_at_error
417 echo -e $GREEN" PASS"$EGREEN
421 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/status
422 # args: <response-code> <producer-id> [<status>]
423 # (Function for test scripts)
424 ecs_api_edp_get_producer_status() {
425 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
426 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
429 if [ $# -lt 2 ] || [ $# -gt 3 ]; then
430 __print_err "<response-code> <producer-id> [<status>]" $@
434 query="/ei-producer/v1/eiproducers/$2/status"
435 res="$(__do_curl_to_api ECS GET $query)"
436 status=${res:${#res}-3}
438 if [ $status -ne $1 ]; then
439 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
441 __check_stop_at_error
444 if [ $# -eq 3 ]; then
445 body=${res:0:${#res}-3}
446 targetJson="{\"operational_state\": \"$3\"}"
447 echo " TARGET JSON: $targetJson" >> $HTTPLOG
448 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
450 if [ $res -ne 0 ]; then
451 echo -e $RED" FAIL, returned body not correct"$ERED
453 __check_stop_at_error
459 echo -e $GREEN" PASS"$EGREEN
464 # API Test function: GET /ei-producer/v1/eiproducers
465 # args: <response-code> [ EMPTY | <producer-id>+]
466 # (Function for test scripts)
467 ecs_api_edp_get_producer_ids() {
468 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
469 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
472 if [ $# -lt 1 ]; then
473 __print_err "<response-code> [ EMPTY | <producer-id>+]" $@
477 query="/ei-producer/v1/eiproducers"
478 res="$(__do_curl_to_api ECS GET $query)"
479 status=${res:${#res}-3}
481 if [ $status -ne $1 ]; then
482 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
484 __check_stop_at_error
488 if [ $# -gt 1 ]; then
489 body=${res:0:${#res}-3}
492 for pid in ${@:2} ; do
493 if [ "$targetJson" != "[" ]; then
494 targetJson=$targetJson","
496 if [ $pid != "EMPTY" ]; then
497 targetJson=$targetJson"\"$pid\""
501 targetJson=$targetJson"]"
502 echo " TARGET JSON: $targetJson" >> $HTTPLOG
503 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
505 if [ $res -ne 0 ]; then
506 echo -e $RED" FAIL, returned body not correct"$ERED
508 __check_stop_at_error
514 echo -e $GREEN" PASS"$EGREEN
518 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
519 # args: <response-code> <type-id> [<job-schema-file> (EMPTY | [<producer-id>]+)]
520 # (Function for test scripts)
521 ecs_api_edp_get_type() {
522 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
523 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
527 if [ $# -eq 2 ]; then
530 if [ $# -gt 3 ]; then
533 if [ $paramError -ne 0 ]; then
534 __print_err "<response-code> <type-id> [<job-schema-file> 'EMPTY' | ([<producer-id>]+)]" $@
538 query="/ei-producer/v1/eitypes/$2"
539 res="$(__do_curl_to_api ECS GET $query)"
540 status=${res:${#res}-3}
542 if [ $status -ne $1 ]; then
543 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
545 __check_stop_at_error
548 if [ $# -gt 3 ]; then
549 body=${res:0:${#res}-3}
554 echo -e $RED" FAIL. Job template file "$3", does not exist"$ERED
556 __check_stop_at_error
561 if [ $4 != "EMPTY" ]; then
562 for pid in ${@:4} ; do
563 if [ "$targetJson" != "" ]; then
564 targetJson=$targetJson","
566 targetJson=$targetJson"\"$pid\""
569 targetJson="{\"ei_job_data_schema\":$schema, \"ei_producer_ids\": [$targetJson]}"
571 echo " TARGET JSON: $targetJson" >> $HTTPLOG
572 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
574 if [ $res -ne 0 ]; then
575 echo -e $RED" FAIL, returned body not correct"$ERED
577 __check_stop_at_error
582 echo -e $GREEN" PASS"$EGREEN
586 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
587 # args: <response-code> <producer-id> [<create-callback> <delete-callback> <supervision-callback> (EMPTY | [<type-id> <schema-file>]+) ]
588 # (Function for test scripts)
589 ecs_api_edp_get_producer() {
590 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
591 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
594 #Possible arg count: 2, 6 7, 9, 11 etc
596 if [ $# -eq 2 ]; then
599 if [ $# -eq 6 ] && [ "$6" == "EMPTY" ]; then
602 variablecount=$(($#-5))
603 if [ $# -gt 5 ] && [ $(($variablecount%2)) -eq 0 ]; then
607 if [ $paramError -ne 0 ]; then
608 __print_err "<response-code> <producer-id> [<create-callback> <delete-callback> <supervision-callback> (NOID | [<type-id> <schema-file>]+) ]" $@
612 query="/ei-producer/v1/eiproducers/$2"
613 res="$(__do_curl_to_api ECS GET $query)"
614 status=${res:${#res}-3}
616 if [ $status -ne $1 ]; then
617 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
619 __check_stop_at_error
623 if [ $# -gt 2 ]; then
624 body=${res:0:${#res}-3}
626 if [ $# -gt 6 ]; then
628 for ((i=0; i<$(($#-6)); i=i+2)); do
629 if [ "$targetJson" != "[" ]; then
630 targetJson=$targetJson","
632 if [ -f ${arr[$i+1]} ]; then
633 schema=$(cat ${arr[$i+1]})
635 echo -e $RED" FAIL. Schema file "${arr[$i+1]}", does not exist"$ERED
637 __check_stop_at_error
641 targetJson=$targetJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
644 targetJson=$targetJson"]"
645 if [ $# -gt 4 ]; then
646 targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_creation_callback_url\": \"$3\",\"ei_job_deletion_callback_url\": \"$4\",\"ei_producer_supervision_callback_url\": \"$5\"}"
648 echo " TARGET JSON: $targetJson" >> $HTTPLOG
649 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
651 if [ $res -ne 0 ]; then
652 echo -e $RED" FAIL, returned body not correct"$ERED
654 __check_stop_at_error
660 echo -e $GREEN" PASS"$EGREEN
664 # API Test function: DELETE /ei-producer/v1/eiproducers/{eiProducerId}
665 # args: <response-code> <producer-id>
666 # (Function for test scripts)
667 ecs_api_edp_delete_producer() {
668 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
669 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
672 if [ $# -lt 2 ]; then
673 __print_err "<response-code> <producer-id>" $@
677 query="/ei-producer/v1/eiproducers/$2"
678 res="$(__do_curl_to_api ECS DELETE $query)"
679 status=${res:${#res}-3}
681 if [ $status -ne $1 ]; then
682 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
684 __check_stop_at_error
689 echo -e $GREEN" PASS"$EGREEN
693 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
694 # args: <response-code> <producer-id> <create-callback> <delete-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+
695 # (Function for test scripts)
696 ecs_api_edp_put_producer() {
697 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
698 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
701 #Valid number of parametrer 6,7,9,11,
703 if [ $# -eq 6 ] && [ "$6" == "NOTYPE" ]; then
705 elif [ $# -gt 6 ] && [ $(($#%2)) -eq 1 ]; then
708 if [ $paramError -ne 0 ]; then
709 __print_err "<response-code> <producer-id> <create-callback> <delete-callback> <supervision-callback> [<type-id> <schema-file>]+" $@
714 if [ $# -gt 6 ]; then
716 for ((i=0; i<$(($#-6)); i=i+2)); do
717 if [ "$inputJson" != "[" ]; then
718 inputJson=$inputJson","
720 if [ -f ${arr[$i+1]} ]; then
721 schema=$(cat ${arr[$i+1]})
723 echo -e $RED" FAIL. Schema file "${arr[$i+1]}", does not exist"$ERED
725 __check_stop_at_error
728 inputJson=$inputJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
731 inputJson="\"supported_ei_types\":"$inputJson"]"
733 inputJson=$inputJson",\"ei_job_creation_callback_url\": \"$3\",\"ei_job_deletion_callback_url\": \"$4\",\"ei_producer_supervision_callback_url\": \"$5\""
735 inputJson="{"$inputJson"}"
738 echo "$inputJson" > $file
739 query="/ei-producer/v1/eiproducers/$2"
740 res="$(__do_curl_to_api ECS PUT $query $file)"
741 status=${res:${#res}-3}
743 if [ $status -ne $1 ]; then
744 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
746 __check_stop_at_error
751 echo -e $GREEN" PASS"$EGREEN
755 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
756 # args: <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <template-job-file>]+)
757 # (Function for test scripts)
758 ecs_api_edp_get_producer_jobs() {
759 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
760 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
763 #Valid number of parameter 2,3,6,10
765 if [ $# -eq 2 ]; then
768 if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
771 variablecount=$(($#-2))
772 if [ $# -gt 3 ] && [ $(($variablecount%4)) -eq 0 ]; then
775 if [ $paramError -eq 1 ]; then
776 __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <template-job-file>]+)" $@
780 query="/ei-producer/v1/eiproducers/$2/eijobs"
781 res="$(__do_curl_to_api ECS GET $query)"
782 status=${res:${#res}-3}
783 if [ $status -ne $1 ]; then
784 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
786 __check_stop_at_error
789 if [ $# -gt 2 ]; then
790 body=${res:0:${#res}-3}
792 if [ $# -gt 3 ]; then
794 for ((i=0; i<$(($#-3)); i=i+4)); do
795 if [ "$targetJson" != "[" ]; then
796 targetJson=$targetJson","
798 if [ -f ${arr[$i+3]} ]; then
799 jobfile=$(cat ${arr[$i+3]})
800 jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
802 echo -e $RED" FAIL. Job template file "${arr[$i+3]}", does not exist"$ERED
804 __check_stop_at_error
807 targetJson=$targetJson"{\"ei_job_identity\":\"${arr[$i]}\",\"ei_type_identity\":\"${arr[$i+1]}\",\"target_uri\":\"${arr[$i+2]}\",\"ei_job_data\":$jobfile}"
810 targetJson=$targetJson"]"
812 echo " TARGET JSON: $targetJson" >> $HTTPLOG
813 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
815 if [ $res -ne 0 ]; then
816 echo -e $RED" FAIL, returned body not correct"$ERED
818 __check_stop_at_error
824 echo -e $GREEN" PASS"$EGREEN
829 ##########################################
830 #### Service status ####
831 ##########################################
832 # Function prefix: ecs_api_service
834 # API Test function: GET /status
835 # args: <response-code>
836 # (Function for test scripts)
837 ecs_api_service_status() {
838 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
839 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
842 if [ $# -lt 1 ]; then
843 __print_err "<response-code> [<producer-id>]*|NOID" $@
848 echo -e $GREEN" PASS"$EGREEN