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 ICS
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 ICS "ICS_IMAGE" "ICS_IMAGE_BASE" "ICS_IMAGE_TAG" $1 "$ICS_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 "$ICS_DISPLAY_NAME" $ICS_APP_NAME ICS_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 ICS 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 "$ICS_DISPLAY_NAME\t$(docker images --format $1 $ICS_IMAGE)" >> $2
52 if [ ! -z "$ICS_IMAGE_SOURCE" ]; then
53 echo -e "-- source image --\t$(docker images --format $1 $ICS_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 __ICS_kube_scale_zero() {
61 __kube_scale_all_resources $KUBE_NONRTRIC_NAMESPACE autotest ICS
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 __ICS_kube_scale_zero_and_wait() {
67 __kube_scale_and_wait_all_resources $KUBE_NONRTRIC_NAMESPACE app "$KUBE_NONRTRIC_NAMESPACE"-informationservice
70 # Delete all kube resouces for the app
71 # This function is called for apps managed by the test script.
72 __ICS_kube_delete_all() {
73 __kube_delete_all_resources $KUBE_NONRTRIC_NAMESPACE autotest ICS
77 # This function is called for apps managed by the test script.
78 # args: <log-dir> <file-prexix>
79 __ICS_store_docker_logs() {
80 if [ $RUNMODE == "KUBE" ]; then
81 kubectl logs -l "autotest=ICS" -n $KUBE_NONRTRIC_NAMESPACE --tail=-1 > $1$2_ics.log 2>&1
83 docker logs $ICS_APP_NAME > $1$2_ics.log 2>&1
87 # Initial setup of protocol, host and ports
88 # This function is called for apps managed by the test script.
90 __ICS_initial_setup() {
94 # Set app short-name, app name and namespace for logging runtime statistics of kubernets pods or docker containers
95 # For docker, the namespace shall be excluded
96 # This function is called for apps managed by the test script as well as for prestarted apps.
98 __ICS_statisics_setup() {
99 if [ $RUNMODE == "KUBE" ]; then
100 echo "ICS $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE"
102 echo "ICS $ICS_APP_NAME"
106 #######################################################
109 # Make curl retries towards ICS for http response codes set in this env var, space separated list of codes
112 #Save first worker node the pod is started on
115 ###########################
117 ###########################
119 # All calls to ICS will be directed to the ICS REST interface from now on
121 # (Function for test scripts)
122 use_ics_rest_http() {
123 __ics_set_protocoll "http" $ICS_INTERNAL_PORT $ICS_EXTERNAL_PORT
126 # All calls to ICS will be directed to the ICS REST interface from now on
128 # (Function for test scripts)
129 use_ics_rest_https() {
130 __ics_set_protocoll "https" $ICS_INTERNAL_SECURE_PORT $ICS_EXTERNAL_SECURE_PORT
133 # All calls to ICS will be directed to the ICS dmaap interface over http from now on
135 # (Function for test scripts)
136 use_ics_dmaap_http() {
137 echo -e $BOLD"ICS dmaap protocol setting"$EBOLD
138 echo -e $RED" - NOT SUPPORTED - "$ERED
139 echo -e " Using $BOLD http $EBOLD and $BOLD DMAAP $EBOLD towards ICS"
140 ICS_ADAPTER_TYPE="MR-HTTP"
144 # Setup paths to svc/container for internal and external access
145 # args: <protocol> <internal-port> <external-port>
146 __ics_set_protocoll() {
147 echo -e $BOLD"$ICS_DISPLAY_NAME protocol setting"$EBOLD
148 echo -e " Using $BOLD $1 $EBOLD towards $ICS_DISPLAY_NAME"
152 ICS_SERVICE_PATH=$1"://"$ICS_APP_NAME":"$2 # docker access, container->container and script->container via proxy
153 if [ $RUNMODE == "KUBE" ]; then
154 ICS_SERVICE_PATH=$1"://"$ICS_APP_NAME.$KUBE_NONRTRIC_NAMESPACE":"$3 # kube access, pod->svc and script->svc via proxy
157 # ICS_ADAPTER used for switching between REST and DMAAP (only REST supported currently)
158 ICS_ADAPTER_TYPE="REST"
159 ICS_ADAPTER=$ICS_SERVICE_PATH
164 # Export env vars for config files, docker compose and kube resources
165 # args: PROXY|NOPROXY
166 __ics_export_vars() {
168 export ICS_APP_NAME_ALIAS
169 export KUBE_NONRTRIC_NAMESPACE
171 export ICS_INTERNAL_PORT
172 export ICS_INTERNAL_SECURE_PORT
173 export ICS_EXTERNAL_PORT
174 export ICS_EXTERNAL_SECURE_PORT
175 export ICS_CONFIG_MOUNT_PATH
176 export ICS_CONFIG_CONFIGMAP_NAME=$ICS_APP_NAME"-config"
177 export ICS_DATA_CONFIGMAP_NAME=$ICS_APP_NAME"-data"
178 export ICS_CONTAINER_MNT_DIR
179 export ICS_HOST_MNT_DIR
180 export ICS_CONFIG_FILE
181 export DOCKER_SIM_NWNAME
182 export ICS_DISPLAY_NAME
185 export ICS_DATA_PV_NAME=$ICS_APP_NAME"-pv"
186 export ICS_DATA_PVC_NAME=$ICS_APP_NAME"-pvc"
187 #Create a unique path for the pv each time to prevent a previous volume to be reused
188 export ICS_PV_PATH="icsdata-"$(date +%s)
190 if [ $1 == "PROXY" ]; then
191 export ICS_HTTP_PROXY_CONFIG_PORT=$HTTP_PROXY_CONFIG_PORT #Set if proxy is started
192 export ICS_HTTP_PROXY_CONFIG_HOST_NAME=$HTTP_PROXY_CONFIG_HOST_NAME #Set if proxy is started
193 if [ $ICS_HTTP_PROXY_CONFIG_PORT -eq 0 ] || [ -z "$ICS_HTTP_PROXY_CONFIG_HOST_NAME" ]; then
194 echo -e $YELLOW" Warning: HTTP PROXY will not be configured, proxy app not started"$EYELLOW
196 echo " Configured with http proxy"
199 export ICS_HTTP_PROXY_CONFIG_PORT=0
200 export ICS_HTTP_PROXY_CONFIG_HOST_NAME=""
201 echo " Configured without http proxy"
207 # args: PROXY|NOPROXY <config-file>
208 # (Function for test scripts)
211 echo -e $BOLD"Starting $ICS_DISPLAY_NAME"$EBOLD
213 if [ $RUNMODE == "KUBE" ]; then
215 # Check if app shall be fully managed by the test script
216 __check_included_image "ICS"
219 # Check if app shall only be used by the testscipt
220 __check_prestarted_image "ICS"
223 if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then
224 echo -e $RED"The $ICS_APP_NAME app is not included as managed nor prestarted in this test script"$ERED
225 echo -e $RED"The $ICS_APP_NAME will not be started"$ERED
228 if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then
229 echo -e $RED"The $ICS_APP_NAME app is included both as managed and prestarted in this test script"$ERED
230 echo -e $RED"The $ICS_APP_NAME will not be started"$ERED
234 if [ $retcode_p -eq 0 ]; then
235 echo -e " Using existing $ICS_APP_NAME deployment and service"
236 echo " Setting ICS replicas=1"
237 res_type=$(__kube_get_resource_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
238 __kube_scale $res_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
241 # Check if app shall be fully managed by the test script
242 if [ $retcode_i -eq 0 ]; then
243 echo -e " Creating $ICS_APP_NAME app and expose service"
245 #Check if nonrtric namespace exists, if not create it
246 __kube_create_namespace $KUBE_NONRTRIC_NAMESPACE
250 # Create config map for config
251 datafile=$PWD/tmp/$ICS_CONFIG_FILE
253 output_yaml=$PWD/tmp/ics_cfc.yaml
254 __kube_create_configmap $ICS_CONFIG_CONFIGMAP_NAME $KUBE_NONRTRIC_NAMESPACE autotest ICS $datafile $output_yaml
257 input_yaml=$SIM_GROUP"/"$ICS_COMPOSE_DIR"/"pv.yaml
258 output_yaml=$PWD/tmp/ics_pv.yaml
259 __kube_create_instance pv $ICS_APP_NAME $input_yaml $output_yaml
262 input_yaml=$SIM_GROUP"/"$ICS_COMPOSE_DIR"/"pvc.yaml
263 output_yaml=$PWD/tmp/ics_pvc.yaml
264 __kube_create_instance pvc $ICS_APP_NAME $input_yaml $output_yaml
267 input_yaml=$SIM_GROUP"/"$ICS_COMPOSE_DIR"/"svc.yaml
268 output_yaml=$PWD/tmp/ics_svc.yaml
269 __kube_create_instance service $ICS_APP_NAME $input_yaml $output_yaml
272 input_yaml=$SIM_GROUP"/"$ICS_COMPOSE_DIR"/"app.yaml
273 output_yaml=$PWD/tmp/ics_app.yaml
274 __kube_create_instance app $ICS_APP_NAME $input_yaml $output_yaml
277 # Tie the ICS to a worker node so that ICS will always be scheduled to the same worker node if the ICS pod is restarted
278 # A PVC of type hostPath is mounted to ICS, for persistent storage, so the ICS must always be on the node which mounted the volume
280 # 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
281 if [ $retcode_i -eq 0 ]; then
282 __ICS_WORKER_NODE=$(kubectl get pod -l "autotest=ICS" -n $KUBE_NONRTRIC_NAMESPACE -o jsonpath='{.items[*].spec.nodeName}')
283 if [ -z "$__ICS_WORKER_NODE" ]; then
284 echo -e $YELLOW" Cannot find worker node for pod for $ICS_APP_NAME, persistency may not work"$EYELLOW
287 echo -e $YELLOW" Persistency may not work for app $ICS_APP_NAME in multi-worker node config when running it as a prestarted app"$EYELLOW
291 __check_service_start $ICS_APP_NAME $ICS_SERVICE_PATH$ICS_ALIVE_URL
294 __check_included_image 'ICS'
295 if [ $? -eq 1 ]; then
296 echo -e $RED"The ICS app is not included in this test script"$ERED
297 echo -e $RED"ICS will not be started"$ERED
307 if [ "$(ls -A $DIR)" ]; then
308 echo -e $BOLD" Cleaning files in mounted dir: $PWD/db"$EBOLD
309 rm -rf db/* &> /dev/null
310 if [ $? -ne 0 ]; then
311 echo -e $RED" Cannot remove database files in: $PWD"$ERED
316 echo " No files in mounted dir or dir does not exists"
323 dest_file=$SIM_GROUP/$ICS_COMPOSE_DIR/$ICS_HOST_MNT_DIR/$ICS_CONFIG_FILE
325 envsubst < $2 > $dest_file
327 __start_container $ICS_COMPOSE_DIR "" NODOCKERARGS 1 $ICS_APP_NAME
329 __check_service_start $ICS_APP_NAME $ICS_SERVICE_PATH$ICS_ALIVE_URL
338 # (Function for test scripts)
340 echo -e $BOLD"Stopping $ICS_DISPLAY_NAME"$EBOLD
342 if [ $RUNMODE == "KUBE" ]; then
344 __check_prestarted_image "ICS"
345 if [ $? -eq 0 ]; then
346 echo -e $YELLOW" Persistency may not work for app $ICS_APP_NAME in multi-worker node config when running it as a prestarted app"$EYELLOW
347 res_type=$(__kube_get_resource_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
348 __kube_scale $res_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 0
352 __kube_scale_all_resources $KUBE_NONRTRIC_NAMESPACE autotest ICS
353 echo " Deleting the replica set - a new will be started when the app is started"
354 tmp=$(kubectl delete rs -n $KUBE_NONRTRIC_NAMESPACE -l "autotest=ICS")
355 if [ $? -ne 0 ]; then
356 echo -e $RED" Could not delete replica set "$RED
361 docker stop $ICS_APP_NAME &> ./tmp/.dockererr
362 if [ $? -ne 0 ]; then
363 __print_err "Could not stop $ICS_APP_NAME" $@
369 echo -e $BOLD$GREEN"Stopped"$EGREEN$EBOLD
374 # Start a previously stopped ics
376 # (Function for test scripts)
377 start_stopped_ics() {
378 echo -e $BOLD"Starting (the previously stopped) $ICS_DISPLAY_NAME"$EBOLD
380 if [ $RUNMODE == "KUBE" ]; then
382 __check_prestarted_image "ICS"
383 if [ $? -eq 0 ]; then
384 echo -e $YELLOW" Persistency may not work for app $ICS_APP_NAME in multi-worker node config when running it as a prestarted app"$EYELLOW
385 res_type=$(__kube_get_resource_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
386 __kube_scale $res_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
387 __check_service_start $ICS_APP_NAME $ICS_SERVICE_PATH$ICS_ALIVE_URL
391 # Tie the PMS to the same worker node it was initially started on
392 # 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
393 if [ -z "$__ICS_WORKER_NODE" ]; then
394 echo -e $RED" No initial worker node found for pod "$RED
398 echo -e $BOLD" Setting nodeSelector kubernetes.io/hostname=$__ICS_WORKER_NODE to deployment for $ICS_APP_NAME. Pod will always run on this worker node: $__PA_WORKER_NODE"$BOLD
399 echo -e $BOLD" The mounted volume is mounted as hostPath and only available on that worker node."$BOLD
400 tmp=$(kubectl patch deployment $ICS_APP_NAME -n $KUBE_NONRTRIC_NAMESPACE --patch '{"spec": {"template": {"spec": {"nodeSelector": {"kubernetes.io/hostname": "'$__ICS_WORKER_NODE'"}}}}}')
401 if [ $? -ne 0 ]; then
402 echo -e $YELLOW" Cannot set nodeSelector to deployment for $ICS_APP_NAME, persistency may not work"$EYELLOW
404 __kube_scale deployment $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
407 docker start $ICS_APP_NAME &> ./tmp/.dockererr
408 if [ $? -ne 0 ]; then
409 __print_err "Could not start (the stopped) $ICS_APP_NAME" $@
415 __check_service_start $ICS_APP_NAME $ICS_SERVICE_PATH$ICS_ALIVE_URL
416 if [ $? -ne 0 ]; then
423 # Turn on debug level tracing in ICS
425 # (Function for test scripts)
427 echo -e $BOLD"Setting ics debug logging"$EBOLD
428 curlString="$ICS_SERVICE_PATH$ICS_ACTUATOR -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"debug\"}"
429 result=$(__do_curl "$curlString")
430 if [ $? -ne 0 ]; then
431 __print_err "Could not set debug mode" $@
439 # Turn on trace level tracing in ICS
441 # (Function for test scripts)
443 echo -e $BOLD"Setting ics trace logging"$EBOLD
444 curlString="$ICS_SERVICE_PATH/actuator/loggers/org.oransc.information -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}"
445 result=$(__do_curl "$curlString")
446 if [ $? -ne 0 ]; then
447 __print_err "Could not set trace mode" $@
455 # Perform curl retries when making direct call to ICS for the specified http response codes
456 # Speace separated list of http response codes
457 # args: [<response-code>]*
459 echo -e $BOLD"Do curl retries to the ICS REST inteface for these response codes:$@"$EBOLD
465 # Check the ics logs for WARNINGs and ERRORs
467 # (Function for test scripts)
469 __check_container_logs "ICS" $ICS_APP_NAME $ICS_LOGPATH WARN ERR
473 # Tests if a variable value in the ICS is equal to a target value and and optional timeout.
474 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
475 # equal to the target or not.
476 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
477 # before setting pass or fail depending on if the variable value becomes equal to the target
479 # (Function for test scripts)
481 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
482 __var_test ICS "$ICS_SERVICE_PATH/" $1 "=" $2 $3
484 __print_err "Wrong args to ics_equal, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
489 ##########################################
490 ######### A1-E information API ##########
491 ##########################################
492 #Function prefix: ics_api_a1
494 # API Test function: GET /A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs
495 # args: <response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
496 # args (flat uri structure): <response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
497 # (Function for test scripts)
498 ics_api_a1_get_job_ids() {
501 if [ -z "$FLAT_A1_EI" ]; then
502 # Valid number of parameters 4,5,6 etc
503 if [ $# -lt 3 ]; then
504 __print_err "<response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
508 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
509 # Valid number of parameters 4,5,6 etc
510 if [ $# -lt 3 ]; then
511 __print_err "<response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
516 if [ $3 != "NOWNER" ]; then
520 if [ -z "$FLAT_A1_EI" ]; then
521 query="/A1-EI/v1/eitypes/$2/eijobs$search"
523 if [ $2 != "NOTYPE" ]; then
524 if [ -z "$search" ]; then
525 search="?eiTypeId="$2
527 search=$search"&eiTypeId="$2
530 query="/A1-EI/v1/eijobs$search"
532 res="$(__do_curl_to_api ICS GET $query)"
533 status=${res:${#res}-3}
535 if [ $status -ne $1 ]; then
536 __log_test_fail_status_code $1 $status
540 if [ $# -gt 3 ]; then
541 body=${res:0:${#res}-3}
544 for pid in ${@:4} ; do
545 if [ "$targetJson" != "[" ]; then
546 targetJson=$targetJson","
548 if [ $pid != "EMPTY" ]; then
549 targetJson=$targetJson"\"$pid\""
553 targetJson=$targetJson"]"
554 echo " TARGET JSON: $targetJson" >> $HTTPLOG
555 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
557 if [ $res -ne 0 ]; then
567 # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}
568 # args: <response-code> <type-id> [<schema-file>]
569 # (Function for test scripts)
570 ics_api_a1_get_type() {
573 if [ $# -lt 2 ] || [ $# -gt 3 ]; then
574 __print_err "<response-code> <type-id> [<schema-file>]" $@
578 query="/A1-EI/v1/eitypes/$2"
579 res="$(__do_curl_to_api ICS GET $query)"
580 status=${res:${#res}-3}
582 if [ $status -ne $1 ]; then
583 __log_test_fail_status_code $1 $status
587 if [ $# -eq 3 ]; then
588 body=${res:0:${#res}-3}
592 __log_test_fail_general "Schema file "$3", does not exist"
595 if [ -z "$FLAT_A1_EI" ]; then
596 targetJson="{\"eiJobParametersSchema\":$schema}"
600 echo " TARGET JSON: $targetJson" >> $HTTPLOG
601 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
603 if [ $res -ne 0 ]; then
613 # API Test function: GET /A1-EI/v1/eitypes
614 # args: <response-code> [ (EMPTY | [<type-id>]+) ]
615 # (Function for test scripts)
616 ics_api_a1_get_type_ids() {
619 if [ $# -lt 1 ]; then
620 __print_err "<response-code> [ (EMPTY | [<type-id>]+) ]" $@
624 query="/A1-EI/v1/eitypes"
625 res="$(__do_curl_to_api ICS GET $query)"
626 status=${res:${#res}-3}
628 if [ $status -ne $1 ]; then
629 __log_test_fail_status_code $1 $status
632 if [ $# -gt 1 ]; then
633 body=${res:0:${#res}-3}
635 if [ $2 != "EMPTY" ]; then
636 for pid in ${@:2} ; do
637 if [ "$targetJson" != "[" ]; then
638 targetJson=$targetJson","
640 targetJson=$targetJson"\"$pid\""
643 targetJson=$targetJson"]"
644 echo " TARGET JSON: $targetJson" >> $HTTPLOG
645 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
647 if [ $res -ne 0 ]; then
657 # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}​/status
658 # args: <response-code> <type-id> <job-id> [<status>]
659 # args (flat uri structure): <response-code> <job-id> [<status> [<timeout>]]
660 # (Function for test scripts)
661 ics_api_a1_get_job_status() {
664 if [ -z "$FLAT_A1_EI" ]; then
665 if [ $# -ne 3 ] && [ $# -ne 4 ]; then
666 __print_err "<response-code> <type-id> <job-id> [<status>]" $@
670 query="/A1-EI/v1/eitypes/$2/eijobs/$3/status"
672 res="$(__do_curl_to_api ICS GET $query)"
673 status=${res:${#res}-3}
675 if [ $status -ne $1 ]; then
676 __log_test_fail_status_code $1 $status
679 if [ $# -eq 4 ]; then
680 body=${res:0:${#res}-3}
681 targetJson="{\"operationalState\": \"$4\"}"
682 echo " TARGET JSON: $targetJson" >> $HTTPLOG
683 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
685 if [ $res -ne 0 ]; then
691 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
692 if [ $# -lt 2 ] && [ $# -gt 4 ]; then
693 __print_err "<response-code> <job-id> [<status> [<timeout>]]" $@
697 query="/A1-EI/v1/eijobs/$2/status"
701 res="$(__do_curl_to_api ICS GET $query)"
702 status=${res:${#res}-3}
704 if [ $# -eq 4 ]; then
705 duration=$((SECONDS-start))
706 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
707 if [ $duration -gt $4 ]; then
709 duration=-1 #Last iteration
712 duration=-1 #single test, no wait
715 if [ $status -ne $1 ]; then
716 if [ $duration -eq -1 ]; then
717 __log_test_fail_status_code $1 $status
721 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
722 body=${res:0:${#res}-3}
723 targetJson="{\"eiJobStatus\": \"$3\"}"
724 echo " TARGET JSON: $targetJson" >> $HTTPLOG
725 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
727 if [ $res -ne 0 ]; then
728 if [ $duration -eq -1 ]; then
733 duration=-1 #Goto pass
736 if [ $duration -eq -1 ]; then
737 if [ $# -eq 4 ]; then
752 # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
753 # args: <response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]
754 # args (flat uri structure): <response-code> <job-id> [<type-id> <target-url> <owner-id> <template-job-file>]
755 # (Function for test scripts)
756 ics_api_a1_get_job() {
759 if [ -z "$FLAT_A1_EI" ]; then
760 if [ $# -ne 3 ] && [ $# -ne 6 ]; then
761 __print_err "<response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]" $@
764 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
766 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
767 if [ $# -ne 2 ] && [ $# -ne 7 ]; then
768 __print_err "<response-code> <job-id> [<type-id> <target-url> <owner-id> <notification-url> <template-job-file>]" $@
771 query="/A1-EI/v1/eijobs/$2"
773 res="$(__do_curl_to_api ICS GET $query)"
774 status=${res:${#res}-3}
776 if [ $status -ne $1 ]; then
777 __log_test_fail_status_code $1 $status
781 if [ -z "$FLAT_A1_EI" ]; then
782 if [ $# -eq 6 ]; then
783 body=${res:0:${#res}-3}
787 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
789 __log_test_fail_general "Job template file "$6", does not exist"
792 targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
793 echo " TARGET JSON: $targetJson" >> $HTTPLOG
794 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
796 if [ $res -ne 0 ]; then
802 if [ $# -eq 7 ]; then
803 body=${res:0:${#res}-3}
807 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
809 __log_test_fail_general "Job template file "$6", does not exist"
812 targetJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
813 echo " TARGET JSON: $targetJson" >> $HTTPLOG
814 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
816 if [ $res -ne 0 ]; then
827 # API Test function: DELETE ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
828 # args: <response-code> <type-id> <job-id>
829 # args (flat uri structure): <response-code> <job-id>
830 # (Function for test scripts)
831 ics_api_a1_delete_job() {
834 if [ -z "$FLAT_A1_EI" ]; then
835 if [ $# -ne 3 ]; then
836 __print_err "<response-code> <type-id> <job-id>" $@
840 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
842 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
843 if [ $# -ne 2 ]; then
844 __print_err "<response-code> <job-id>" $@
847 query="/A1-EI/v1/eijobs/$2"
849 res="$(__do_curl_to_api ICS DELETE $query)"
850 status=${res:${#res}-3}
852 if [ $status -ne $1 ]; then
853 __log_test_fail_status_code $1 $status
861 # API Test function: PUT ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
862 # args: <response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>
863 # args (flat uri structure): <response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file>
864 # (Function for test scripts)
865 ics_api_a1_put_job() {
868 if [ -z "$FLAT_A1_EI" ]; then
869 if [ $# -lt 6 ]; then
870 __print_err "<response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>" $@
875 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
877 __log_test_fail_general "Job template file "$6", does not exist"
881 inputJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
883 echo "$inputJson" > $file
885 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
887 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
888 if [ $# -lt 7 ]; then
889 __print_err "<response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file>" $@
894 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
896 __log_test_fail_general "Job template file "$7", does not exist"
900 inputJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
902 echo "$inputJson" > $file
904 query="/A1-EI/v1/eijobs/$2"
907 res="$(__do_curl_to_api ICS PUT $query $file)"
908 status=${res:${#res}-3}
910 if [ $status -ne $1 ]; then
911 __log_test_fail_status_code $1 $status
920 ##########################################
921 #### information Data Producer API ####
922 ##########################################
923 # Function prefix: ics_api_edp
925 # API Test function: GET /ei-producer/v1/eitypes
926 # API Test function: GET /data-producer/v1/info-types
927 # args: <response-code> [ EMPTY | <type-id>+]
928 # (Function for test scripts)
929 ics_api_edp_get_type_ids() {
932 if [ $# -lt 1 ]; then
933 __print_err "<response-code> [ EMPTY | <type-id>+]" $@
936 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
937 query="/data-producer/v1/info-types"
939 query="/ei-producer/v1/eitypes"
941 res="$(__do_curl_to_api ICS GET $query)"
942 status=${res:${#res}-3}
944 if [ $status -ne $1 ]; then
945 __log_test_fail_status_code $1 $status
949 if [ $# -gt 1 ]; then
950 body=${res:0:${#res}-3}
952 if [ $2 != "EMPTY" ]; then
953 for pid in ${@:2} ; do
954 if [ "$targetJson" != "[" ]; then
955 targetJson=$targetJson","
957 targetJson=$targetJson"\"$pid\""
960 targetJson=$targetJson"]"
961 echo " TARGET JSON: $targetJson" >> $HTTPLOG
962 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
964 if [ $res -ne 0 ]; then
974 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/status
975 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}/status
976 # args: <response-code> <producer-id> [<status> [<timeout>]]
977 # (Function for test scripts)
978 ics_api_edp_get_producer_status() {
981 if [ $# -lt 2 ] || [ $# -gt 4 ]; then
982 __print_err "<response-code> <producer-id> [<status> [<timeout>]]" $@
985 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
986 query="/data-producer/v1/info-producers/$2/status"
988 query="/ei-producer/v1/eiproducers/$2/status"
992 res="$(__do_curl_to_api ICS GET $query)"
993 status=${res:${#res}-3}
995 if [ $# -eq 4 ]; then
996 duration=$((SECONDS-start))
997 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
998 if [ $duration -gt $4 ]; then
1000 duration=-1 #Last iteration
1003 duration=-1 #single test, no wait
1006 if [ $status -ne $1 ]; then
1007 if [ $duration -eq -1 ]; then
1008 __log_test_fail_status_code $1 $status
1012 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
1013 body=${res:0:${#res}-3}
1014 targetJson="{\"operational_state\": \"$3\"}"
1015 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1016 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1018 if [ $res -ne 0 ]; then
1019 if [ $duration -eq -1 ]; then
1020 __log_test_fail_body
1024 duration=-1 #Goto pass
1027 if [ $duration -eq -1 ]; then
1028 if [ $# -eq 4 ]; then
1040 # API Test function: GET /ei-producer/v1/eiproducers
1041 # args (v1_1): <response-code> [ EMPTY | <producer-id>+]
1042 # (Function for test scripts)
1043 ics_api_edp_get_producer_ids() {
1046 if [ $# -lt 1 ]; then
1047 __print_err "<response-code> [ EMPTY | <producer-id>+]" $@
1051 query="/ei-producer/v1/eiproducers"
1052 res="$(__do_curl_to_api ICS GET $query)"
1053 status=${res:${#res}-3}
1055 if [ $status -ne $1 ]; then
1056 __log_test_fail_status_code $1 $status
1060 if [ $# -gt 1 ]; then
1061 body=${res:0:${#res}-3}
1064 for pid in ${@:2} ; do
1065 if [ "$targetJson" != "[" ]; then
1066 targetJson=$targetJson","
1068 if [ $pid != "EMPTY" ]; then
1069 targetJson=$targetJson"\"$pid\""
1073 targetJson=$targetJson"]"
1074 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1075 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1077 if [ $res -ne 0 ]; then
1078 __log_test_fail_body
1087 # API Test function: GET /ei-producer/v1/eiproducers
1088 # API Test function: GET /data-producer/v1/info-producers
1089 # args (v1_2): <response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]
1090 # (Function for test scripts)
1091 ics_api_edp_get_producer_ids_2() {
1094 if [ $# -lt 1 ]; then
1095 __print_err "<response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]" $@
1098 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1099 query="/data-producer/v1/info-producers"
1100 if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then
1101 query=$query"?info_type_id=$2"
1104 query="/ei-producer/v1/eiproducers"
1105 if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then
1106 query=$query"?ei_type_id=$2"
1109 res="$(__do_curl_to_api ICS GET $query)"
1110 status=${res:${#res}-3}
1112 if [ $status -ne $1 ]; then
1113 __log_test_fail_status_code $1 $status
1117 if [ $# -gt 2 ]; then
1118 body=${res:0:${#res}-3}
1121 for pid in ${@:3} ; do
1122 if [ "$targetJson" != "[" ]; then
1123 targetJson=$targetJson","
1125 if [ $pid != "EMPTY" ]; then
1126 targetJson=$targetJson"\"$pid\""
1130 targetJson=$targetJson"]"
1131 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1132 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1134 if [ $res -ne 0 ]; then
1135 __log_test_fail_body
1144 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
1145 # args: (v1_1) <response-code> <type-id> [<job-schema-file> (EMPTY | [<producer-id>]+)]
1146 # (Function for test scripts)
1147 ics_api_edp_get_type() {
1151 if [ $# -eq 2 ]; then
1154 if [ $# -gt 3 ]; then
1157 if [ $paramError -ne 0 ]; then
1158 __print_err "<response-code> <type-id> [<job-schema-file> 'EMPTY' | ([<producer-id>]+)]" $@
1162 query="/ei-producer/v1/eitypes/$2"
1163 res="$(__do_curl_to_api ICS GET $query)"
1164 status=${res:${#res}-3}
1166 if [ $status -ne $1 ]; then
1167 __log_test_fail_status_code $1 $status
1170 if [ $# -gt 3 ]; then
1171 body=${res:0:${#res}-3}
1176 __log_test_fail_general "Job template file "$3", does not exist"
1181 if [ $4 != "EMPTY" ]; then
1182 for pid in ${@:4} ; do
1183 if [ "$targetJson" != "" ]; then
1184 targetJson=$targetJson","
1186 targetJson=$targetJson"\"$pid\""
1189 targetJson="{\"ei_job_data_schema\":$schema, \"ei_producer_ids\": [$targetJson]}"
1191 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1192 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1194 if [ $res -ne 0 ]; then
1195 __log_test_fail_body
1203 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
1204 # API Test function: GET /data-producer/v1/info-types/{infoTypeId}
1205 # args: (v1_2) <response-code> <type-id> [<job-schema-file> [ <info-type-info> ]]
1206 # (Function for test scripts)
1207 ics_api_edp_get_type_2() {
1211 if [ $# -eq 2 ]; then
1214 if [ $# -eq 3 ]; then
1217 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then
1218 if [ $# -eq 4 ]; then
1222 if [ $paramError -ne 0 ]; then
1223 __print_err "<response-code> <type-id> [<job-schema-file> [ <info-type-info> ]]" $@
1226 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1227 query="/data-producer/v1/info-types/$2"
1229 query="/ei-producer/v1/eitypes/$2"
1232 res="$(__do_curl_to_api ICS GET $query)"
1233 status=${res:${#res}-3}
1235 if [ $status -ne $1 ]; then
1236 __log_test_fail_status_code $1 $status
1239 if [ $# -ge 3 ]; then
1240 body=${res:0:${#res}-3}
1245 __log_test_fail_general "Job template file "$3", does not exist"
1249 if [ $# -gt 3 ]; then
1253 __log_test_fail_general "Info-data file "$4", does not exist"
1256 info_data=",\"info_type_information\":$info_data"
1258 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1259 targetJson="{\"info_job_data_schema\":$schema $info_data}"
1261 targetJson="{\"ei_job_data_schema\":$schema}"
1264 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1265 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1267 if [ $res -ne 0 ]; then
1268 __log_test_fail_body
1276 # API Test function: PUT /ei-producer/v1/eitypes/{eiTypeId}
1277 # API Test function: PUT /data-producer/v1/info-types/{infoTypeId}
1278 # args: (v1_2) <response-code> <type-id> <job-schema-file> [ <info-type-info> ]
1279 # (Function for test scripts)
1280 ics_api_edp_put_type_2() {
1283 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then
1284 if [ $# -lt 3 ] || [ $# -gt 4 ]; then
1285 __print_err "<response-code> <type-id> <job-schema-file> [ <info-type-info> ]" $@
1289 if [ $# -ne 3 ]; then
1290 __print_err "<response-code> <type-id> <job-schema-file>" $@
1295 if [ ! -f $3 ]; then
1296 __log_test_fail_general "Job schema file "$3", does not exist"
1301 if [ $# -gt 3 ]; then
1305 __log_test_fail_general "Info-data file "$4", does not exist"
1308 info_data=",\"info_type_information\":$info_data"
1311 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1313 input_json="{\"info_job_data_schema\":$schema $info_data}"
1314 file="./tmp/put_type.json"
1315 echo $input_json > $file
1317 query="/data-producer/v1/info-types/$2"
1320 input_json="{\"ei_job_data_schema\":$schema}"
1321 file="./tmp/put_type.json"
1322 echo $input_json > $file
1324 query="/ei-producer/v1/eitypes/$2"
1326 res="$(__do_curl_to_api ICS PUT $query $file)"
1327 status=${res:${#res}-3}
1329 if [ $status -ne $1 ]; then
1330 __log_test_fail_status_code $1 $status
1338 # API Test function: DELETE /ei-producer/v1/eitypes/{eiTypeId}
1339 # API Test function: DELETE /data-producer/v1/info-types/{infoTypeId}
1340 # args: (v1_2) <response-code> <type-id>
1341 # (Function for test scripts)
1342 ics_api_edp_delete_type_2() {
1345 if [ $# -ne 2 ]; then
1346 __print_err "<response-code> <type-id>" $@
1350 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1351 query="/data-producer/v1/info-types/$2"
1353 query="/ei-producer/v1/eitypes/$2"
1355 res="$(__do_curl_to_api ICS DELETE $query)"
1356 status=${res:${#res}-3}
1358 if [ $status -ne $1 ]; then
1359 __log_test_fail_status_code $1 $status
1367 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
1368 # args: (v1_1) <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | [<type-id> <schema-file>]+) ]
1369 # (Function for test scripts)
1370 ics_api_edp_get_producer() {
1373 #Possible arg count: 2, 5 6, 8, 10 etc
1375 if [ $# -eq 2 ]; then
1378 if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then
1381 variablecount=$(($#-4))
1382 if [ $# -gt 5 ] && [ $(($variablecount%2)) -eq 0 ]; then
1386 if [ $paramError -ne 0 ]; then
1387 __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (NOID | [<type-id> <schema-file>]+) ]" $@
1391 query="/ei-producer/v1/eiproducers/$2"
1392 res="$(__do_curl_to_api ICS GET $query)"
1393 status=${res:${#res}-3}
1395 if [ $status -ne $1 ]; then
1396 __log_test_fail_status_code $1 $status
1400 if [ $# -gt 2 ]; then
1401 body=${res:0:${#res}-3}
1403 if [ $# -gt 5 ]; then
1405 for ((i=0; i<$(($#-5)); i=i+2)); do
1406 if [ "$targetJson" != "[" ]; then
1407 targetJson=$targetJson","
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"
1416 targetJson=$targetJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
1419 targetJson=$targetJson"]"
1420 if [ $# -gt 4 ]; then
1421 targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
1423 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1424 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1426 if [ $res -ne 0 ]; then
1427 __log_test_fail_body
1436 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
1437 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}
1438 # args (v1_2): <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]
1439 # (Function for test scripts)
1440 ics_api_edp_get_producer_2() {
1443 #Possible arg count: 2, 5, 6, 7, 8 etc
1445 if [ $# -eq 2 ]; then
1448 if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then
1451 if [ $# -ge 5 ]; then
1455 if [ $paramError -ne 0 ]; then
1456 __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]" $@
1459 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1460 query="/data-producer/v1/info-producers/$2"
1462 query="/ei-producer/v1/eiproducers/$2"
1464 res="$(__do_curl_to_api ICS GET $query)"
1465 status=${res:${#res}-3}
1467 if [ $status -ne $1 ]; then
1468 __log_test_fail_status_code $1 $status
1472 if [ $# -gt 2 ]; then
1473 body=${res:0:${#res}-3}
1475 if [ $# -gt 4 ] && [ "$5" != "EMPTY" ]; then
1477 for ((i=0; i<$(($#-4)); i=i+1)); do
1478 if [ "$targetJson" != "[" ]; then
1479 targetJson=$targetJson","
1481 targetJson=$targetJson"\"${arr[$i]}\""
1484 targetJson=$targetJson"]"
1485 if [ $# -gt 4 ]; then
1486 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1487 targetJson="{\"supported_info_types\":$targetJson,\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\"}"
1489 targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
1492 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1493 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1495 if [ $res -ne 0 ]; then
1496 __log_test_fail_body
1505 # API Test function: DELETE /ei-producer/v1/eiproducers/{eiProducerId}
1506 # API Test function: DELETE /data-producer/v1/info-producers/{infoProducerId}
1507 # args: <response-code> <producer-id>
1508 # (Function for test scripts)
1509 ics_api_edp_delete_producer() {
1512 if [ $# -lt 2 ]; then
1513 __print_err "<response-code> <producer-id>" $@
1516 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1517 query="/data-producer/v1/info-producers/$2"
1519 query="/ei-producer/v1/eiproducers/$2"
1521 res="$(__do_curl_to_api ICS DELETE $query)"
1522 status=${res:${#res}-3}
1524 if [ $status -ne $1 ]; then
1525 __log_test_fail_status_code $1 $status
1533 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
1534 # args: (v1_1) <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+
1535 # (Function for test scripts)
1536 ics_api_edp_put_producer() {
1539 #Valid number of parametrer 5,6,8,10,
1541 if [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then
1543 elif [ $# -gt 5 ] && [ $(($#%2)) -eq 0 ]; then
1546 if [ $paramError -ne 0 ]; then
1547 __print_err "<response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+" $@
1552 if [ $# -gt 5 ]; then
1554 for ((i=0; i<$(($#-5)); i=i+2)); do
1555 if [ "$inputJson" != "[" ]; then
1556 inputJson=$inputJson","
1558 if [ -f ${arr[$i+1]} ]; then
1559 schema=$(cat ${arr[$i+1]})
1561 __log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
1564 inputJson=$inputJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
1567 inputJson="\"supported_ei_types\":"$inputJson"]"
1569 inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
1571 inputJson="{"$inputJson"}"
1573 file="./tmp/.p.json"
1574 echo "$inputJson" > $file
1575 query="/ei-producer/v1/eiproducers/$2"
1576 res="$(__do_curl_to_api ICS PUT $query $file)"
1577 status=${res:${#res}-3}
1579 if [ $status -ne $1 ]; then
1580 __log_test_fail_status_code $1 $status
1588 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
1589 # API Test function: PUT /data-producer/v1/info-producers/{infoProducerId}
1590 # args: (v1_2) <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]
1591 # (Function for test scripts)
1592 ics_api_edp_put_producer_2() {
1595 #Valid number of parametrer 5,6,8,10,
1597 if [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then
1599 elif [ $# -ge 5 ]; then
1602 if [ $paramError -ne 0 ]; then
1603 __print_err "<response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]" $@
1608 if [ $# -gt 4 ] && [ "$5" != "NOTYPE" ]; then
1610 for ((i=0; i<$(($#-4)); i=i+1)); do
1611 if [ "$inputJson" != "[" ]; then
1612 inputJson=$inputJson","
1614 inputJson=$inputJson"\""${arr[$i]}"\""
1617 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1618 inputJson="\"supported_info_types\":"$inputJson"]"
1620 inputJson=$inputJson",\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\""
1622 inputJson="{"$inputJson"}"
1624 file="./tmp/.p.json"
1625 echo "$inputJson" > $file
1626 query="/data-producer/v1/info-producers/$2"
1628 inputJson="\"supported_ei_types\":"$inputJson"]"
1630 inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
1632 inputJson="{"$inputJson"}"
1634 file="./tmp/.p.json"
1635 echo "$inputJson" > $file
1636 query="/ei-producer/v1/eiproducers/$2"
1638 res="$(__do_curl_to_api ICS PUT $query $file)"
1639 status=${res:${#res}-3}
1641 if [ $status -ne $1 ]; then
1642 __log_test_fail_status_code $1 $status
1650 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
1651 # args: (V1-1) <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)
1652 # (Function for test scripts)
1653 ics_api_edp_get_producer_jobs() {
1656 #Valid number of parameter 2,3,7,11
1658 if [ $# -eq 2 ]; then
1661 if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
1664 variablecount=$(($#-2))
1665 if [ $# -gt 3 ] && [ $(($variablecount%5)) -eq 0 ]; then
1668 if [ $paramError -eq 1 ]; then
1669 __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)" $@
1673 query="/ei-producer/v1/eiproducers/$2/eijobs"
1674 res="$(__do_curl_to_api ICS GET $query)"
1675 status=${res:${#res}-3}
1676 if [ $status -ne $1 ]; then
1677 __log_test_fail_status_code $1 $status
1680 if [ $# -gt 2 ]; then
1681 body=${res:0:${#res}-3}
1683 if [ $# -gt 3 ]; then
1685 for ((i=0; i<$(($#-3)); i=i+5)); do
1686 if [ "$targetJson" != "[" ]; then
1687 targetJson=$targetJson","
1689 if [ -f ${arr[$i+4]} ]; then
1690 jobfile=$(cat ${arr[$i+4]})
1691 jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
1693 __log_test_fail_general "Job template file "${arr[$i+4]}", does not exist"
1696 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}"
1699 targetJson=$targetJson"]"
1701 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1702 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1704 if [ $res -ne 0 ]; then
1705 __log_test_fail_body
1714 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
1715 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}/info-jobs
1716 # args: (V1-2) <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)
1717 # (Function for test scripts)
1718 ics_api_edp_get_producer_jobs_2() {
1721 #Valid number of parameter 2,3,7,11
1723 if [ $# -eq 2 ]; then
1726 if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
1729 variablecount=$(($#-2))
1730 if [ $# -gt 3 ] && [ $(($variablecount%5)) -eq 0 ]; then
1733 if [ $paramError -eq 1 ]; then
1734 __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)" $@
1737 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1738 query="/data-producer/v1/info-producers/$2/info-jobs"
1740 query="/ei-producer/v1/eiproducers/$2/eijobs"
1742 res="$(__do_curl_to_api ICS GET $query)"
1743 status=${res:${#res}-3}
1744 if [ $status -ne $1 ]; then
1745 __log_test_fail_status_code $1 $status
1748 if [ $# -gt 2 ]; then
1749 body=${res:0:${#res}-3}
1751 if [ $# -gt 3 ]; then
1753 for ((i=0; i<$(($#-3)); i=i+5)); do
1754 if [ "$targetJson" != "[" ]; then
1755 targetJson=$targetJson","
1757 if [ -f ${arr[$i+4]} ]; then
1758 jobfile=$(cat ${arr[$i+4]})
1759 jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
1761 __log_test_fail_general "Job template file "${arr[$i+4]}", does not exist"
1764 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1765 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\":\"????\"}"
1767 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\":\"????\"}"
1771 targetJson=$targetJson"]"
1773 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1774 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1776 if [ $res -ne 0 ]; then
1777 __log_test_fail_body
1786 ##########################################
1787 #### Service status ####
1788 ##########################################
1789 # Function prefix: ics_api_service
1791 # API Test function: GET ​/status
1792 # args: <response-code>
1793 # (Function for test scripts)
1794 ics_api_service_status() {
1797 if [ $# -lt 1 ]; then
1798 __print_err "<response-code>" $@
1801 res="$(__do_curl_to_api ICS GET /status)"
1802 status=${res:${#res}-3}
1803 if [ $status -ne $1 ]; then
1804 __log_test_fail_status_code $1 $status
1811 ###########################################
1812 ######### Info data consumer API ##########
1813 ###########################################
1814 #Function prefix: ics_api_idc
1817 # API Test function: GET /data-consumer/v1/info-types
1818 # args: <response-code> [ (EMPTY | [<type-id>]+) ]
1819 # (Function for test scripts)
1820 ics_api_idc_get_type_ids() {
1823 if [ $# -lt 1 ]; then
1824 __print_err "<response-code> [ (EMPTY | [<type-id>]+) ]" $@
1828 query="/data-consumer/v1/info-types"
1829 res="$(__do_curl_to_api ICS GET $query)"
1830 status=${res:${#res}-3}
1832 if [ $status -ne $1 ]; then
1833 __log_test_fail_status_code $1 $status
1836 if [ $# -gt 1 ]; then
1837 body=${res:0:${#res}-3}
1839 if [ $2 != "EMPTY" ]; then
1840 for pid in ${@:2} ; do
1841 if [ "$targetJson" != "[" ]; then
1842 targetJson=$targetJson","
1844 targetJson=$targetJson"\"$pid\""
1847 targetJson=$targetJson"]"
1848 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1849 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1851 if [ $res -ne 0 ]; then
1852 __log_test_fail_body
1861 # API Test function: GET /data-consumer/v1/info-jobs
1862 # args: <response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
1863 # (Function for test scripts)
1864 ics_api_idc_get_job_ids() {
1867 # Valid number of parameters 4,5,6 etc
1868 if [ $# -lt 3 ]; then
1869 __print_err "<response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
1873 if [ $3 != "NOWNER" ]; then
1877 if [ $2 != "NOTYPE" ]; then
1878 if [ -z "$search" ]; then
1879 search="?infoTypeId="$2
1881 search=$search"&infoTypeId="$2
1884 query="/data-consumer/v1/info-jobs$search"
1886 res="$(__do_curl_to_api ICS GET $query)"
1887 status=${res:${#res}-3}
1889 if [ $status -ne $1 ]; then
1890 __log_test_fail_status_code $1 $status
1894 if [ $# -gt 3 ]; then
1895 body=${res:0:${#res}-3}
1898 for pid in ${@:4} ; do
1899 if [ "$targetJson" != "[" ]; then
1900 targetJson=$targetJson","
1902 if [ $pid != "EMPTY" ]; then
1903 targetJson=$targetJson"\"$pid\""
1907 targetJson=$targetJson"]"
1908 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1909 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1911 if [ $res -ne 0 ]; then
1912 __log_test_fail_body
1921 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}
1922 # args: <response-code> <job-id> [<type-id> <target-url> <owner-id> <template-job-file>]
1923 # (Function for test scripts)
1924 ics_api_idc_get_job() {
1927 if [ $# -ne 2 ] && [ $# -ne 7 ]; then
1928 __print_err "<response-code> <job-id> [<type-id> <target-url> <owner-id> <notification-url> <template-job-file>]" $@
1931 query="/data-consumer/v1/info-jobs/$2"
1932 res="$(__do_curl_to_api ICS GET $query)"
1933 status=${res:${#res}-3}
1935 if [ $status -ne $1 ]; then
1936 __log_test_fail_status_code $1 $status
1940 if [ $# -eq 7 ]; then
1941 body=${res:0:${#res}-3}
1945 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
1947 __log_test_fail_general "Job template file "$6", does not exist"
1950 targetJson="{\"info_type_id\": \"$3\", \"job_result_uri\": \"$4\",\"job_owner\": \"$5\",\"status_notification_uri\": \"$6\",\"job_definition\": $jobfile}"
1951 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1952 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1954 if [ $res -ne 0 ]; then
1955 __log_test_fail_body
1965 # API Test function: PUT ​/data-consumer/v1/info-jobs/{infoJobId}
1966 # args: <response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file> [ VALIDATE ]
1967 # (Function for test scripts)
1968 ics_api_idc_put_job() {
1971 if [ $# -lt 7 ] || [ $# -gt 8 ]; then
1972 __print_err "<response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file> [ VALIDATE ]" $@
1977 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
1979 __log_test_fail_general "Job template file "$7", does not exist"
1983 inputJson="{\"info_type_id\": \"$3\", \"job_result_uri\": \"$4\",\"job_owner\": \"$5\",\"status_notification_uri\": \"$6\",\"job_definition\": $jobfile}"
1984 file="./tmp/.p.json"
1985 echo "$inputJson" > $file
1987 query="/data-consumer/v1/info-jobs/$2"
1989 if [ $# -eq 8 ]; then
1990 if [ $8 == "VALIDATE" ]; then
1991 query=$query"?typeCheck=true"
1995 res="$(__do_curl_to_api ICS PUT $query $file)"
1996 status=${res:${#res}-3}
1998 if [ $status -ne $1 ]; then
1999 __log_test_fail_status_code $1 $status
2007 # API Test function: DELETE ​/data-consumer/v1/info-jobs/{infoJobId}
2008 # args: <response-code> <job-id>
2009 # (Function for test scripts)
2010 ics_api_idc_delete_job() {
2013 if [ $# -ne 2 ]; then
2014 __print_err "<response-code> <job-id>" $@
2017 query="/data-consumer/v1/info-jobs/$2"
2018 res="$(__do_curl_to_api ICS DELETE $query)"
2019 status=${res:${#res}-3}
2021 if [ $status -ne $1 ]; then
2022 __log_test_fail_status_code $1 $status
2030 # API Test function: GET ​/data-consumer/v1/info-types/{infoTypeId}
2031 # args: <response-code> <type-id> [<schema-file> [<type-status> <producers-count]]
2032 # (Function for test scripts)
2033 ics_api_idc_get_type() {
2036 if [ $# -lt 2 ] || [ $# -gt 5 ]; then
2037 __print_err "<response-code> <type-id> [<schema-file> [<type-status> <producers-count]]" $@
2041 query="/data-consumer/v1/info-types/$2"
2042 res="$(__do_curl_to_api ICS GET $query)"
2043 status=${res:${#res}-3}
2045 if [ $status -ne $1 ]; then
2046 __log_test_fail_status_code $1 $status
2050 if [ $# -gt 2 ]; then
2051 body=${res:0:${#res}-3}
2055 __log_test_fail_general "Schema file "$3", does not exist"
2058 if [ $# -eq 5 ]; then
2059 targetJson="{\"job_data_schema\":$schema, \"type_status\":\"$4\", \"no_of_producers\":$5}"
2061 targetJson="{\"job_data_schema\":$schema}"
2063 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2064 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2066 if [ $res -ne 0 ]; then
2067 __log_test_fail_body
2076 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}/status
2077 # This test only status during an optional timeout. No test of the list of producers
2078 # args: <response-code> <job-id> [<status> [<timeout>]]
2079 # (Function for test scripts)
2080 ics_api_idc_get_job_status() {
2083 if [ $# -lt 2 ] && [ $# -gt 4 ]; then
2084 __print_err "<response-code> <job-id> [<status> [<timeout>]]" $@
2088 query="/data-consumer/v1/info-jobs/$2/status"
2092 res="$(__do_curl_to_api ICS GET $query)"
2093 status=${res:${#res}-3}
2095 if [ $# -eq 4 ]; then
2096 duration=$((SECONDS-start))
2097 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
2098 if [ $duration -gt $4 ]; then
2100 duration=-1 #Last iteration
2103 duration=-1 #single test, no wait
2106 if [ $status -ne $1 ]; then
2107 if [ $duration -eq -1 ]; then
2108 __log_test_fail_status_code $1 $status
2112 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
2113 body=${res:0:${#res}-3}
2114 targetJson="{\"info_job_status\": \"$3\"}"
2115 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2116 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2118 if [ $res -ne 0 ]; then
2119 if [ $duration -eq -1 ]; then
2120 __log_test_fail_body
2124 duration=-1 #Goto pass
2127 if [ $duration -eq -1 ]; then
2128 if [ $# -eq 4 ]; then
2142 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}/status
2143 # This function test status and the list of producers with and optional timeout
2144 # args: <response-code> <job-id> [<status> EMPTYPROD|( <prod-count> <producer-id>+ ) [<timeout>]]
2145 # (Function for test scripts)
2146 ics_api_idc_get_job_status2() {
2150 if [ $# -lt 2 ]; then
2155 if [ $# -gt 2 ]; then
2156 if [ $# -lt 4 ]; then
2159 targetJson="{\"info_job_status\": \"$3\""
2160 if [ "$4" == "EMPTYPROD" ]; then
2161 targetJson=$targetJson",\"producers\": []}"
2162 if [ $# -gt 4 ]; then
2166 targetJson=$targetJson",\"producers\": ["
2167 if [ $# -eq $(($4+5)) ]; then
2169 timeout=${args[$idx]}
2171 for ((ics_i = 0 ; ics_i < $4 ; ics_i++)); do
2173 if [ $ics_i -gt 0 ]; then
2174 targetJson=$targetJson","
2176 targetJson=$targetJson"\""${args[$idx]}"\""
2178 targetJson=$targetJson"]}"
2182 if [ $param_error -ne 0 ]; then
2183 __print_err "<response-code> <job-id> [<status> EMPTYPROD|( <prod-count> <producer-id>+ ) [<timeout>]]" $@
2187 query="/data-consumer/v1/info-jobs/$2/status"
2191 res="$(__do_curl_to_api ICS GET $query)"
2192 status=${res:${#res}-3}
2194 if [ $# -gt 2 ]; then
2195 duration=$((SECONDS-start))
2196 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
2197 if [ $duration -gt $timeout ]; then
2199 duration=-1 #Last iteration
2202 duration=-1 #single test, no wait
2205 if [ $status -ne $1 ]; then
2206 if [ $duration -eq -1 ]; then
2207 __log_test_fail_status_code $1 $status
2211 if [ $# -gt 2 ] && [ $status -eq $1 ]; then
2212 body=${res:0:${#res}-3}
2213 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2214 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2216 if [ $res -ne 0 ]; then
2217 if [ $duration -eq -1 ]; then
2218 __log_test_fail_body
2222 duration=-1 #Goto pass
2225 if [ $duration -eq -1 ]; then
2226 if [ $# -eq 4 ]; then
2240 ##########################################
2241 #### Type subscriptions ####
2242 ##########################################
2244 # API Test function: GET /data-consumer/v1/info-type-subscription
2245 # args: <response-code> <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]
2246 # (Function for test scripts)
2247 ics_api_idc_get_subscription_ids() {
2250 if [ $# -lt 3 ]; then
2251 __print_err "<response-code> <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]" $@
2255 query="/data-consumer/v1/info-type-subscription"
2257 if [ $2 != "NOOWNER" ]; then
2261 res="$(__do_curl_to_api ICS GET $query$search)"
2262 status=${res:${#res}-3}
2264 if [ $status -ne $1 ]; then
2265 __log_test_fail_status_code $1 $status
2269 if [ $# -gt 2 ]; then
2270 body=${res:0:${#res}-3}
2272 if [ $3 != "EMPTY" ]; then
2273 for pid in ${@:3} ; do
2274 if [ "$targetJson" != "[" ]; then
2275 targetJson=$targetJson","
2277 targetJson=$targetJson"\"$pid\""
2280 targetJson=$targetJson"]"
2281 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2282 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2284 if [ $res -ne 0 ]; then
2285 __log_test_fail_body
2294 # API Test function: GET /data-consumer/v1/info-type-subscription/{subscriptionId}
2295 # args: <response-code> <subscription-id> [ <owner-id> <status-uri> ]
2296 # (Function for test scripts)
2297 ics_api_idc_get_subscription() {
2300 if [ $# -ne 2 ] && [ $# -ne 4 ]; then
2301 __print_err "<response-code> <subscription-id> [ <owner-id> <status-uri> ]" $@
2305 query="/data-consumer/v1/info-type-subscription/$2"
2306 res="$(__do_curl_to_api ICS GET $query)"
2307 status=${res:${#res}-3}
2309 if [ $status -ne $1 ]; then
2310 __log_test_fail_status_code $1 $status
2314 if [ $# -gt 2 ]; then
2315 body=${res:0:${#res}-3}
2316 targetJson="{\"owner\":\"$3\",\"status_result_uri\":\"$4\"}"
2317 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2318 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2320 if [ $res -ne 0 ]; then
2321 __log_test_fail_body
2330 # API Test function: PUT /data-consumer/v1/info-type-subscription/{subscriptionId}
2331 # args: <response-code> <subscription-id> <owner-id> <status-uri>
2332 # (Function for test scripts)
2333 ics_api_idc_put_subscription() {
2336 if [ $# -ne 4 ]; then
2337 __print_err "<response-code> <subscription-id> <owner-id> <status-uri>" $@
2341 inputJson="{\"owner\": \"$3\",\"status_result_uri\": \"$4\"}"
2342 file="./tmp/.p.json"
2343 echo "$inputJson" > $file
2345 query="/data-consumer/v1/info-type-subscription/$2"
2346 res="$(__do_curl_to_api ICS PUT $query $file)"
2347 status=${res:${#res}-3}
2349 if [ $status -ne $1 ]; then
2350 __log_test_fail_status_code $1 $status
2358 # API Test function: DELETE /data-consumer/v1/info-type-subscription/{subscriptionId}
2359 # args: <response-code> <subscription-id>
2360 # (Function for test scripts)
2361 ics_api_idc_delete_subscription() {
2364 if [ $# -ne 2 ]; then
2365 __print_err "<response-code> <subscription-id> " $@
2369 query="/data-consumer/v1/info-type-subscription/$2"
2370 res="$(__do_curl_to_api ICS DELETE $query)"
2371 status=${res:${#res}-3}
2373 if [ $status -ne $1 ]; then
2374 __log_test_fail_status_code $1 $status
2382 ##########################################
2383 #### Reset jobs ####
2384 ##########################################
2385 # Function prefix: ics_api_admin
2387 # Admin to remove all jobs
2388 # args: <response-code> [ <type> ]
2389 # (Function for test scripts)
2391 ics_api_admin_reset() {
2394 if [ -z "$FLAT_A1_EI" ]; then
2395 query="/A1-EI/v1/eitypes/$2/eijobs"
2397 query="/A1-EI/v1/eijobs"
2399 res="$(__do_curl_to_api ICS GET $query)"
2400 status=${res:${#res}-3}
2402 if [ $status -ne 200 ]; then
2403 __log_test_fail_status_code $1 $status
2407 #Remove brackets and response code
2408 body=${res:1:${#res}-4}
2409 list=$(echo ${body//,/ })
2410 list=$(echo ${list//[/})
2411 list=$(echo ${list//]/})
2412 list=$(echo ${list//\"/})
2414 for job in $list; do
2415 if [ -z "$FLAT_A1_EI" ]; then
2416 echo "Not supported for non-flat EI api"
2418 query="/A1-EI/v1/eijobs/$job"
2419 res="$(__do_curl_to_api ICS DELETE $query)"
2420 status=${res:${#res}-3}
2421 if [ $status -ne 204 ]; then
2422 __log_test_fail_status_code $1 $status
2425 echo " Deleted job: "$job
2433 ##########################################
2434 #### Reset jobs and producers ####
2435 ##########################################
2438 # Admin reset to remove all data in ics; jobs, producers etc
2439 # NOTE - only works in kubernetes and the pod should not be running
2441 # (Function for test scripts)
2443 ics_kube_pvc_reset() {
2446 pvc_name=$(kubectl get pvc -n $KUBE_NONRTRIC_NAMESPACE --no-headers -o custom-columns=":metadata.name" | grep information)
2447 if [ -z "$pvc_name" ]; then
2448 pvc_name=informationservice-pvc
2450 echo " Trying to reset pvc: "$pvc_name
2452 __kube_clean_pvc $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE $pvc_name $ICS_CONTAINER_MNT_DIR