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 # Check application requirements, e.g. helm, the the test needs. Exit 1 if req not satisfied
108 __ICS_test_requirements() {
112 #######################################################
115 # Make curl retries towards ICS for http response codes set in this env var, space separated list of codes
118 #Save first worker node the pod is started on
121 ###########################
123 ###########################
125 # All calls to ICS will be directed to the ICS REST interface from now on
127 # (Function for test scripts)
128 use_ics_rest_http() {
129 __ics_set_protocoll "http" $ICS_INTERNAL_PORT $ICS_EXTERNAL_PORT
132 # All calls to ICS will be directed to the ICS REST interface from now on
134 # (Function for test scripts)
135 use_ics_rest_https() {
136 __ics_set_protocoll "https" $ICS_INTERNAL_SECURE_PORT $ICS_EXTERNAL_SECURE_PORT
139 # All calls to ICS will be directed to the ICS dmaap interface over http from now on
141 # (Function for test scripts)
142 use_ics_dmaap_http() {
143 echo -e $BOLD"ICS dmaap protocol setting"$EBOLD
144 echo -e $RED" - NOT SUPPORTED - "$ERED
145 echo -e " Using $BOLD http $EBOLD and $BOLD DMAAP $EBOLD towards ICS"
146 ICS_ADAPTER_TYPE="MR-HTTP"
150 # Setup paths to svc/container for internal and external access
151 # args: <protocol> <internal-port> <external-port>
152 __ics_set_protocoll() {
153 echo -e $BOLD"$ICS_DISPLAY_NAME protocol setting"$EBOLD
154 echo -e " Using $BOLD $1 $EBOLD towards $ICS_DISPLAY_NAME"
158 ICS_SERVICE_PATH=$1"://"$ICS_APP_NAME":"$2 # docker access, container->container and script->container via proxy
159 if [ $RUNMODE == "KUBE" ]; then
160 ICS_SERVICE_PATH=$1"://"$ICS_APP_NAME.$KUBE_NONRTRIC_NAMESPACE":"$3 # kube access, pod->svc and script->svc via proxy
163 # ICS_ADAPTER used for switching between REST and DMAAP (only REST supported currently)
164 ICS_ADAPTER_TYPE="REST"
165 ICS_ADAPTER=$ICS_SERVICE_PATH
170 # Export env vars for config files, docker compose and kube resources
171 # args: PROXY|NOPROXY
172 __ics_export_vars() {
174 export ICS_APP_NAME_ALIAS
175 export KUBE_NONRTRIC_NAMESPACE
177 export ICS_INTERNAL_PORT
178 export ICS_INTERNAL_SECURE_PORT
179 export ICS_EXTERNAL_PORT
180 export ICS_EXTERNAL_SECURE_PORT
181 export ICS_CONFIG_MOUNT_PATH
182 export ICS_CONFIG_CONFIGMAP_NAME=$ICS_APP_NAME"-config"
183 export ICS_DATA_CONFIGMAP_NAME=$ICS_APP_NAME"-data"
184 export ICS_CONTAINER_MNT_DIR
185 export ICS_HOST_MNT_DIR
186 export ICS_CONFIG_FILE
187 export DOCKER_SIM_NWNAME
188 export ICS_DISPLAY_NAME
191 export ICS_DATA_PV_NAME=$ICS_APP_NAME"-pv"
192 export ICS_DATA_PVC_NAME=$ICS_APP_NAME"-pvc"
193 #Create a unique path for the pv each time to prevent a previous volume to be reused
194 export ICS_PV_PATH="icsdata-"$(date +%s)
196 if [ $1 == "PROXY" ]; then
197 export ICS_HTTP_PROXY_CONFIG_PORT=$HTTP_PROXY_CONFIG_PORT #Set if proxy is started
198 export ICS_HTTP_PROXY_CONFIG_HOST_NAME=$HTTP_PROXY_CONFIG_HOST_NAME #Set if proxy is started
199 if [ $ICS_HTTP_PROXY_CONFIG_PORT -eq 0 ] || [ -z "$ICS_HTTP_PROXY_CONFIG_HOST_NAME" ]; then
200 echo -e $YELLOW" Warning: HTTP PROXY will not be configured, proxy app not started"$EYELLOW
202 echo " Configured with http proxy"
205 export ICS_HTTP_PROXY_CONFIG_PORT=0
206 export ICS_HTTP_PROXY_CONFIG_HOST_NAME=""
207 echo " Configured without http proxy"
213 # args: PROXY|NOPROXY <config-file>
214 # (Function for test scripts)
217 echo -e $BOLD"Starting $ICS_DISPLAY_NAME"$EBOLD
219 if [ $RUNMODE == "KUBE" ]; then
221 # Check if app shall be fully managed by the test script
222 __check_included_image "ICS"
225 # Check if app shall only be used by the testscipt
226 __check_prestarted_image "ICS"
229 if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then
230 echo -e $RED"The $ICS_APP_NAME app is not included as managed nor prestarted in this test script"$ERED
231 echo -e $RED"The $ICS_APP_NAME will not be started"$ERED
234 if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then
235 echo -e $RED"The $ICS_APP_NAME app is included both as managed and prestarted in this test script"$ERED
236 echo -e $RED"The $ICS_APP_NAME will not be started"$ERED
240 if [ $retcode_p -eq 0 ]; then
241 echo -e " Using existing $ICS_APP_NAME deployment and service"
242 echo " Setting ICS replicas=1"
243 res_type=$(__kube_get_resource_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
244 __kube_scale $res_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
247 # Check if app shall be fully managed by the test script
248 if [ $retcode_i -eq 0 ]; then
249 echo -e " Creating $ICS_APP_NAME app and expose service"
251 #Check if nonrtric namespace exists, if not create it
252 __kube_create_namespace $KUBE_NONRTRIC_NAMESPACE
256 # Create config map for config
257 datafile=$PWD/tmp/$ICS_CONFIG_FILE
259 output_yaml=$PWD/tmp/ics_cfc.yaml
260 __kube_create_configmap $ICS_CONFIG_CONFIGMAP_NAME $KUBE_NONRTRIC_NAMESPACE autotest ICS $datafile $output_yaml
263 input_yaml=$SIM_GROUP"/"$ICS_COMPOSE_DIR"/"pv.yaml
264 output_yaml=$PWD/tmp/ics_pv.yaml
265 __kube_create_instance pv $ICS_APP_NAME $input_yaml $output_yaml
268 input_yaml=$SIM_GROUP"/"$ICS_COMPOSE_DIR"/"pvc.yaml
269 output_yaml=$PWD/tmp/ics_pvc.yaml
270 __kube_create_instance pvc $ICS_APP_NAME $input_yaml $output_yaml
273 input_yaml=$SIM_GROUP"/"$ICS_COMPOSE_DIR"/"svc.yaml
274 output_yaml=$PWD/tmp/ics_svc.yaml
275 __kube_create_instance service $ICS_APP_NAME $input_yaml $output_yaml
278 input_yaml=$SIM_GROUP"/"$ICS_COMPOSE_DIR"/"app.yaml
279 output_yaml=$PWD/tmp/ics_app.yaml
280 __kube_create_instance app $ICS_APP_NAME $input_yaml $output_yaml
283 # 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
284 # 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
286 # 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
287 if [ $retcode_i -eq 0 ]; then
288 __ICS_WORKER_NODE=$(kubectl get pod -l "autotest=ICS" -n $KUBE_NONRTRIC_NAMESPACE -o jsonpath='{.items[*].spec.nodeName}')
289 if [ -z "$__ICS_WORKER_NODE" ]; then
290 echo -e $YELLOW" Cannot find worker node for pod for $ICS_APP_NAME, persistency may not work"$EYELLOW
293 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
297 __check_service_start $ICS_APP_NAME $ICS_SERVICE_PATH$ICS_ALIVE_URL
300 __check_included_image 'ICS'
301 if [ $? -eq 1 ]; then
302 echo -e $RED"The ICS app is not included in this test script"$ERED
303 echo -e $RED"ICS will not be started"$ERED
313 if [ "$(ls -A $DIR)" ]; then
314 echo -e $BOLD" Cleaning files in mounted dir: $PWD/db"$EBOLD
315 rm -rf db/* &> /dev/null
316 if [ $? -ne 0 ]; then
317 echo -e $RED" Cannot remove database files in: $PWD"$ERED
322 echo " No files in mounted dir or dir does not exists"
329 dest_file=$SIM_GROUP/$ICS_COMPOSE_DIR/$ICS_HOST_MNT_DIR/$ICS_CONFIG_FILE
331 envsubst < $2 > $dest_file
333 __start_container $ICS_COMPOSE_DIR "" NODOCKERARGS 1 $ICS_APP_NAME
335 __check_service_start $ICS_APP_NAME $ICS_SERVICE_PATH$ICS_ALIVE_URL
344 # (Function for test scripts)
346 echo -e $BOLD"Stopping $ICS_DISPLAY_NAME"$EBOLD
348 if [ $RUNMODE == "KUBE" ]; then
350 __check_prestarted_image "ICS"
351 if [ $? -eq 0 ]; then
352 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
353 res_type=$(__kube_get_resource_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
354 __kube_scale $res_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 0
358 __kube_scale_all_resources $KUBE_NONRTRIC_NAMESPACE autotest ICS
359 echo " Deleting the replica set - a new will be started when the app is started"
360 tmp=$(kubectl delete rs -n $KUBE_NONRTRIC_NAMESPACE -l "autotest=ICS")
361 if [ $? -ne 0 ]; then
362 echo -e $RED" Could not delete replica set "$RED
367 docker stop $ICS_APP_NAME &> ./tmp/.dockererr
368 if [ $? -ne 0 ]; then
369 __print_err "Could not stop $ICS_APP_NAME" $@
375 echo -e $BOLD$GREEN"Stopped"$EGREEN$EBOLD
380 # Start a previously stopped ics
382 # (Function for test scripts)
383 start_stopped_ics() {
384 echo -e $BOLD"Starting (the previously stopped) $ICS_DISPLAY_NAME"$EBOLD
386 if [ $RUNMODE == "KUBE" ]; then
388 __check_prestarted_image "ICS"
389 if [ $? -eq 0 ]; then
390 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
391 res_type=$(__kube_get_resource_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
392 __kube_scale $res_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
393 __check_service_start $ICS_APP_NAME $ICS_SERVICE_PATH$ICS_ALIVE_URL
397 # Tie the PMS to the same worker node it was initially started on
398 # 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
399 if [ -z "$__ICS_WORKER_NODE" ]; then
400 echo -e $RED" No initial worker node found for pod "$RED
404 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
405 echo -e $BOLD" The mounted volume is mounted as hostPath and only available on that worker node."$BOLD
406 tmp=$(kubectl patch deployment $ICS_APP_NAME -n $KUBE_NONRTRIC_NAMESPACE --patch '{"spec": {"template": {"spec": {"nodeSelector": {"kubernetes.io/hostname": "'$__ICS_WORKER_NODE'"}}}}}')
407 if [ $? -ne 0 ]; then
408 echo -e $YELLOW" Cannot set nodeSelector to deployment for $ICS_APP_NAME, persistency may not work"$EYELLOW
410 __kube_scale deployment $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
413 docker start $ICS_APP_NAME &> ./tmp/.dockererr
414 if [ $? -ne 0 ]; then
415 __print_err "Could not start (the stopped) $ICS_APP_NAME" $@
421 __check_service_start $ICS_APP_NAME $ICS_SERVICE_PATH$ICS_ALIVE_URL
422 if [ $? -ne 0 ]; then
429 # Turn on debug level tracing in ICS
431 # (Function for test scripts)
433 echo -e $BOLD"Setting ics debug logging"$EBOLD
434 curlString="$ICS_SERVICE_PATH$ICS_ACTUATOR -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"debug\"}"
435 result=$(__do_curl "$curlString")
436 if [ $? -ne 0 ]; then
437 __print_err "Could not set debug mode" $@
445 # Turn on trace level tracing in ICS
447 # (Function for test scripts)
449 echo -e $BOLD"Setting ics trace logging"$EBOLD
450 curlString="$ICS_SERVICE_PATH/actuator/loggers/org.oransc.information -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}"
451 result=$(__do_curl "$curlString")
452 if [ $? -ne 0 ]; then
453 __print_err "Could not set trace mode" $@
461 # Perform curl retries when making direct call to ICS for the specified http response codes
462 # Speace separated list of http response codes
463 # args: [<response-code>]*
465 echo -e $BOLD"Do curl retries to the ICS REST inteface for these response codes:$@"$EBOLD
471 # Check the ics logs for WARNINGs and ERRORs
473 # (Function for test scripts)
475 __check_container_logs "ICS" $ICS_APP_NAME $ICS_LOGPATH WARN ERR
479 # Tests if a variable value in the ICS is equal to a target value and and optional timeout.
480 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
481 # equal to the target or not.
482 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
483 # before setting pass or fail depending on if the variable value becomes equal to the target
485 # (Function for test scripts)
487 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
488 __var_test ICS "$ICS_SERVICE_PATH/" $1 "=" $2 $3
490 __print_err "Wrong args to ics_equal, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
495 ##########################################
496 ######### A1-E information API ##########
497 ##########################################
498 #Function prefix: ics_api_a1
500 # API Test function: GET /A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs
501 # args: <response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
502 # args (flat uri structure): <response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
503 # (Function for test scripts)
504 ics_api_a1_get_job_ids() {
507 if [ -z "$FLAT_A1_EI" ]; then
508 # Valid number of parameters 4,5,6 etc
509 if [ $# -lt 3 ]; then
510 __print_err "<response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
514 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
515 # Valid number of parameters 4,5,6 etc
516 if [ $# -lt 3 ]; then
517 __print_err "<response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
522 if [ $3 != "NOWNER" ]; then
526 if [ -z "$FLAT_A1_EI" ]; then
527 query="/A1-EI/v1/eitypes/$2/eijobs$search"
529 if [ $2 != "NOTYPE" ]; then
530 if [ -z "$search" ]; then
531 search="?eiTypeId="$2
533 search=$search"&eiTypeId="$2
536 query="/A1-EI/v1/eijobs$search"
538 res="$(__do_curl_to_api ICS GET $query)"
539 status=${res:${#res}-3}
541 if [ $status -ne $1 ]; then
542 __log_test_fail_status_code $1 $status
546 if [ $# -gt 3 ]; then
547 body=${res:0:${#res}-3}
550 for pid in ${@:4} ; do
551 if [ "$targetJson" != "[" ]; then
552 targetJson=$targetJson","
554 if [ $pid != "EMPTY" ]; then
555 targetJson=$targetJson"\"$pid\""
559 targetJson=$targetJson"]"
560 echo " TARGET JSON: $targetJson" >> $HTTPLOG
561 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
563 if [ $res -ne 0 ]; then
573 # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}
574 # args: <response-code> <type-id> [<schema-file>]
575 # (Function for test scripts)
576 ics_api_a1_get_type() {
579 if [ $# -lt 2 ] || [ $# -gt 3 ]; then
580 __print_err "<response-code> <type-id> [<schema-file>]" $@
584 query="/A1-EI/v1/eitypes/$2"
585 res="$(__do_curl_to_api ICS GET $query)"
586 status=${res:${#res}-3}
588 if [ $status -ne $1 ]; then
589 __log_test_fail_status_code $1 $status
593 if [ $# -eq 3 ]; then
594 body=${res:0:${#res}-3}
598 __log_test_fail_general "Schema file "$3", does not exist"
601 if [ -z "$FLAT_A1_EI" ]; then
602 targetJson="{\"eiJobParametersSchema\":$schema}"
606 echo " TARGET JSON: $targetJson" >> $HTTPLOG
607 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
609 if [ $res -ne 0 ]; then
619 # API Test function: GET /A1-EI/v1/eitypes
620 # args: <response-code> [ (EMPTY | [<type-id>]+) ]
621 # (Function for test scripts)
622 ics_api_a1_get_type_ids() {
625 if [ $# -lt 1 ]; then
626 __print_err "<response-code> [ (EMPTY | [<type-id>]+) ]" $@
630 query="/A1-EI/v1/eitypes"
631 res="$(__do_curl_to_api ICS GET $query)"
632 status=${res:${#res}-3}
634 if [ $status -ne $1 ]; then
635 __log_test_fail_status_code $1 $status
638 if [ $# -gt 1 ]; then
639 body=${res:0:${#res}-3}
641 if [ $2 != "EMPTY" ]; then
642 for pid in ${@:2} ; do
643 if [ "$targetJson" != "[" ]; then
644 targetJson=$targetJson","
646 targetJson=$targetJson"\"$pid\""
649 targetJson=$targetJson"]"
650 echo " TARGET JSON: $targetJson" >> $HTTPLOG
651 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
653 if [ $res -ne 0 ]; then
663 # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}​/status
664 # args: <response-code> <type-id> <job-id> [<status>]
665 # args (flat uri structure): <response-code> <job-id> [<status> [<timeout>]]
666 # (Function for test scripts)
667 ics_api_a1_get_job_status() {
670 if [ -z "$FLAT_A1_EI" ]; then
671 if [ $# -ne 3 ] && [ $# -ne 4 ]; then
672 __print_err "<response-code> <type-id> <job-id> [<status>]" $@
676 query="/A1-EI/v1/eitypes/$2/eijobs/$3/status"
678 res="$(__do_curl_to_api ICS GET $query)"
679 status=${res:${#res}-3}
681 if [ $status -ne $1 ]; then
682 __log_test_fail_status_code $1 $status
685 if [ $# -eq 4 ]; then
686 body=${res:0:${#res}-3}
687 targetJson="{\"operationalState\": \"$4\"}"
688 echo " TARGET JSON: $targetJson" >> $HTTPLOG
689 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
691 if [ $res -ne 0 ]; then
697 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
698 if [ $# -lt 2 ] && [ $# -gt 4 ]; then
699 __print_err "<response-code> <job-id> [<status> [<timeout>]]" $@
703 query="/A1-EI/v1/eijobs/$2/status"
707 res="$(__do_curl_to_api ICS GET $query)"
708 status=${res:${#res}-3}
710 if [ $# -eq 4 ]; then
711 duration=$((SECONDS-start))
712 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
713 if [ $duration -gt $4 ]; then
715 duration=-1 #Last iteration
718 duration=-1 #single test, no wait
721 if [ $status -ne $1 ]; then
722 if [ $duration -eq -1 ]; then
723 __log_test_fail_status_code $1 $status
727 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
728 body=${res:0:${#res}-3}
729 targetJson="{\"eiJobStatus\": \"$3\"}"
730 echo " TARGET JSON: $targetJson" >> $HTTPLOG
731 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
733 if [ $res -ne 0 ]; then
734 if [ $duration -eq -1 ]; then
739 duration=-1 #Goto pass
742 if [ $duration -eq -1 ]; then
743 if [ $# -eq 4 ]; then
758 # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
759 # args: <response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]
760 # args (flat uri structure): <response-code> <job-id> [<type-id> <target-url> <owner-id> <template-job-file>]
761 # (Function for test scripts)
762 ics_api_a1_get_job() {
765 if [ -z "$FLAT_A1_EI" ]; then
766 if [ $# -ne 3 ] && [ $# -ne 6 ]; then
767 __print_err "<response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]" $@
770 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
772 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
773 if [ $# -ne 2 ] && [ $# -ne 7 ]; then
774 __print_err "<response-code> <job-id> [<type-id> <target-url> <owner-id> <notification-url> <template-job-file>]" $@
777 query="/A1-EI/v1/eijobs/$2"
779 res="$(__do_curl_to_api ICS GET $query)"
780 status=${res:${#res}-3}
782 if [ $status -ne $1 ]; then
783 __log_test_fail_status_code $1 $status
787 if [ -z "$FLAT_A1_EI" ]; then
788 if [ $# -eq 6 ]; then
789 body=${res:0:${#res}-3}
793 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
795 __log_test_fail_general "Job template file "$6", does not exist"
798 targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
799 echo " TARGET JSON: $targetJson" >> $HTTPLOG
800 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
802 if [ $res -ne 0 ]; then
808 if [ $# -eq 7 ]; then
809 body=${res:0:${#res}-3}
813 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
815 __log_test_fail_general "Job template file "$6", does not exist"
818 targetJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
819 echo " TARGET JSON: $targetJson" >> $HTTPLOG
820 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
822 if [ $res -ne 0 ]; then
833 # API Test function: DELETE ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
834 # args: <response-code> <type-id> <job-id>
835 # args (flat uri structure): <response-code> <job-id>
836 # (Function for test scripts)
837 ics_api_a1_delete_job() {
840 if [ -z "$FLAT_A1_EI" ]; then
841 if [ $# -ne 3 ]; then
842 __print_err "<response-code> <type-id> <job-id>" $@
846 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
848 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
849 if [ $# -ne 2 ]; then
850 __print_err "<response-code> <job-id>" $@
853 query="/A1-EI/v1/eijobs/$2"
855 res="$(__do_curl_to_api ICS DELETE $query)"
856 status=${res:${#res}-3}
858 if [ $status -ne $1 ]; then
859 __log_test_fail_status_code $1 $status
867 # API Test function: PUT ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
868 # args: <response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>
869 # args (flat uri structure): <response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file>
870 # (Function for test scripts)
871 ics_api_a1_put_job() {
874 if [ -z "$FLAT_A1_EI" ]; then
875 if [ $# -lt 6 ]; then
876 __print_err "<response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>" $@
881 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
883 __log_test_fail_general "Job template file "$6", does not exist"
887 inputJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
889 echo "$inputJson" > $file
891 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
893 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
894 if [ $# -lt 7 ]; then
895 __print_err "<response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file>" $@
900 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
902 __log_test_fail_general "Job template file "$7", does not exist"
906 inputJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
908 echo "$inputJson" > $file
910 query="/A1-EI/v1/eijobs/$2"
913 res="$(__do_curl_to_api ICS PUT $query $file)"
914 status=${res:${#res}-3}
916 if [ $status -ne $1 ]; then
917 __log_test_fail_status_code $1 $status
926 ##########################################
927 #### information Data Producer API ####
928 ##########################################
929 # Function prefix: ics_api_edp
931 # API Test function: GET /ei-producer/v1/eitypes
932 # API Test function: GET /data-producer/v1/info-types
933 # args: <response-code> [ EMPTY | <type-id>+]
934 # (Function for test scripts)
935 ics_api_edp_get_type_ids() {
938 if [ $# -lt 1 ]; then
939 __print_err "<response-code> [ EMPTY | <type-id>+]" $@
942 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
943 query="/data-producer/v1/info-types"
945 query="/ei-producer/v1/eitypes"
947 res="$(__do_curl_to_api ICS GET $query)"
948 status=${res:${#res}-3}
950 if [ $status -ne $1 ]; then
951 __log_test_fail_status_code $1 $status
955 if [ $# -gt 1 ]; then
956 body=${res:0:${#res}-3}
958 if [ $2 != "EMPTY" ]; then
959 for pid in ${@:2} ; do
960 if [ "$targetJson" != "[" ]; then
961 targetJson=$targetJson","
963 targetJson=$targetJson"\"$pid\""
966 targetJson=$targetJson"]"
967 echo " TARGET JSON: $targetJson" >> $HTTPLOG
968 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
970 if [ $res -ne 0 ]; then
980 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/status
981 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}/status
982 # args: <response-code> <producer-id> [<status> [<timeout>]]
983 # (Function for test scripts)
984 ics_api_edp_get_producer_status() {
987 if [ $# -lt 2 ] || [ $# -gt 4 ]; then
988 __print_err "<response-code> <producer-id> [<status> [<timeout>]]" $@
991 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
992 query="/data-producer/v1/info-producers/$2/status"
994 query="/ei-producer/v1/eiproducers/$2/status"
998 res="$(__do_curl_to_api ICS GET $query)"
999 status=${res:${#res}-3}
1001 if [ $# -eq 4 ]; then
1002 duration=$((SECONDS-start))
1003 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
1004 if [ $duration -gt $4 ]; then
1006 duration=-1 #Last iteration
1009 duration=-1 #single test, no wait
1012 if [ $status -ne $1 ]; then
1013 if [ $duration -eq -1 ]; then
1014 __log_test_fail_status_code $1 $status
1018 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
1019 body=${res:0:${#res}-3}
1020 targetJson="{\"operational_state\": \"$3\"}"
1021 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1022 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1024 if [ $res -ne 0 ]; then
1025 if [ $duration -eq -1 ]; then
1026 __log_test_fail_body
1030 duration=-1 #Goto pass
1033 if [ $duration -eq -1 ]; then
1034 if [ $# -eq 4 ]; then
1046 # API Test function: GET /ei-producer/v1/eiproducers
1047 # args (v1_1): <response-code> [ EMPTY | <producer-id>+]
1048 # (Function for test scripts)
1049 ics_api_edp_get_producer_ids() {
1052 if [ $# -lt 1 ]; then
1053 __print_err "<response-code> [ EMPTY | <producer-id>+]" $@
1057 query="/ei-producer/v1/eiproducers"
1058 res="$(__do_curl_to_api ICS GET $query)"
1059 status=${res:${#res}-3}
1061 if [ $status -ne $1 ]; then
1062 __log_test_fail_status_code $1 $status
1066 if [ $# -gt 1 ]; then
1067 body=${res:0:${#res}-3}
1070 for pid in ${@:2} ; do
1071 if [ "$targetJson" != "[" ]; then
1072 targetJson=$targetJson","
1074 if [ $pid != "EMPTY" ]; then
1075 targetJson=$targetJson"\"$pid\""
1079 targetJson=$targetJson"]"
1080 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1081 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1083 if [ $res -ne 0 ]; then
1084 __log_test_fail_body
1093 # API Test function: GET /ei-producer/v1/eiproducers
1094 # API Test function: GET /data-producer/v1/info-producers
1095 # args (v1_2): <response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]
1096 # (Function for test scripts)
1097 ics_api_edp_get_producer_ids_2() {
1100 if [ $# -lt 1 ]; then
1101 __print_err "<response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]" $@
1104 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1105 query="/data-producer/v1/info-producers"
1106 if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then
1107 query=$query"?info_type_id=$2"
1110 query="/ei-producer/v1/eiproducers"
1111 if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then
1112 query=$query"?ei_type_id=$2"
1115 res="$(__do_curl_to_api ICS GET $query)"
1116 status=${res:${#res}-3}
1118 if [ $status -ne $1 ]; then
1119 __log_test_fail_status_code $1 $status
1123 if [ $# -gt 2 ]; then
1124 body=${res:0:${#res}-3}
1127 for pid in ${@:3} ; do
1128 if [ "$targetJson" != "[" ]; then
1129 targetJson=$targetJson","
1131 if [ $pid != "EMPTY" ]; then
1132 targetJson=$targetJson"\"$pid\""
1136 targetJson=$targetJson"]"
1137 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1138 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1140 if [ $res -ne 0 ]; then
1141 __log_test_fail_body
1150 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
1151 # args: (v1_1) <response-code> <type-id> [<job-schema-file> (EMPTY | [<producer-id>]+)]
1152 # (Function for test scripts)
1153 ics_api_edp_get_type() {
1157 if [ $# -eq 2 ]; then
1160 if [ $# -gt 3 ]; then
1163 if [ $paramError -ne 0 ]; then
1164 __print_err "<response-code> <type-id> [<job-schema-file> 'EMPTY' | ([<producer-id>]+)]" $@
1168 query="/ei-producer/v1/eitypes/$2"
1169 res="$(__do_curl_to_api ICS GET $query)"
1170 status=${res:${#res}-3}
1172 if [ $status -ne $1 ]; then
1173 __log_test_fail_status_code $1 $status
1176 if [ $# -gt 3 ]; then
1177 body=${res:0:${#res}-3}
1182 __log_test_fail_general "Job template file "$3", does not exist"
1187 if [ $4 != "EMPTY" ]; then
1188 for pid in ${@:4} ; do
1189 if [ "$targetJson" != "" ]; then
1190 targetJson=$targetJson","
1192 targetJson=$targetJson"\"$pid\""
1195 targetJson="{\"ei_job_data_schema\":$schema, \"ei_producer_ids\": [$targetJson]}"
1197 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1198 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1200 if [ $res -ne 0 ]; then
1201 __log_test_fail_body
1209 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
1210 # API Test function: GET /data-producer/v1/info-types/{infoTypeId}
1211 # args: (v1_2) <response-code> <type-id> [<job-schema-file> [ <info-type-info> ]]
1212 # (Function for test scripts)
1213 ics_api_edp_get_type_2() {
1217 if [ $# -eq 2 ]; then
1220 if [ $# -eq 3 ]; then
1223 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then
1224 if [ $# -eq 4 ]; then
1228 if [ $paramError -ne 0 ]; then
1229 __print_err "<response-code> <type-id> [<job-schema-file> [ <info-type-info> ]]" $@
1232 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1233 query="/data-producer/v1/info-types/$2"
1235 query="/ei-producer/v1/eitypes/$2"
1238 res="$(__do_curl_to_api ICS GET $query)"
1239 status=${res:${#res}-3}
1241 if [ $status -ne $1 ]; then
1242 __log_test_fail_status_code $1 $status
1245 if [ $# -ge 3 ]; then
1246 body=${res:0:${#res}-3}
1251 __log_test_fail_general "Job template file "$3", does not exist"
1255 if [ $# -gt 3 ]; then
1259 __log_test_fail_general "Info-data file "$4", does not exist"
1262 info_data=",\"info_type_information\":$info_data"
1264 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1265 targetJson="{\"info_job_data_schema\":$schema $info_data}"
1267 targetJson="{\"ei_job_data_schema\":$schema}"
1270 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1271 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1273 if [ $res -ne 0 ]; then
1274 __log_test_fail_body
1282 # API Test function: PUT /ei-producer/v1/eitypes/{eiTypeId}
1283 # API Test function: PUT /data-producer/v1/info-types/{infoTypeId}
1284 # args: (v1_2) <response-code> <type-id> <job-schema-file> [ <info-type-info> ]
1285 # (Function for test scripts)
1286 ics_api_edp_put_type_2() {
1289 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then
1290 if [ $# -lt 3 ] || [ $# -gt 4 ]; then
1291 __print_err "<response-code> <type-id> <job-schema-file> [ <info-type-info> ]" $@
1295 if [ $# -ne 3 ]; then
1296 __print_err "<response-code> <type-id> <job-schema-file>" $@
1301 if [ ! -f $3 ]; then
1302 __log_test_fail_general "Job schema file "$3", does not exist"
1307 if [ $# -gt 3 ]; then
1311 __log_test_fail_general "Info-data file "$4", does not exist"
1314 info_data=",\"info_type_information\":$info_data"
1317 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1319 input_json="{\"info_job_data_schema\":$schema $info_data}"
1320 file="./tmp/put_type.json"
1321 echo $input_json > $file
1323 query="/data-producer/v1/info-types/$2"
1326 input_json="{\"ei_job_data_schema\":$schema}"
1327 file="./tmp/put_type.json"
1328 echo $input_json > $file
1330 query="/ei-producer/v1/eitypes/$2"
1332 res="$(__do_curl_to_api ICS PUT $query $file)"
1333 status=${res:${#res}-3}
1335 if [ $status -ne $1 ]; then
1336 __log_test_fail_status_code $1 $status
1344 # API Test function: DELETE /ei-producer/v1/eitypes/{eiTypeId}
1345 # API Test function: DELETE /data-producer/v1/info-types/{infoTypeId}
1346 # args: (v1_2) <response-code> <type-id>
1347 # (Function for test scripts)
1348 ics_api_edp_delete_type_2() {
1351 if [ $# -ne 2 ]; then
1352 __print_err "<response-code> <type-id>" $@
1356 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1357 query="/data-producer/v1/info-types/$2"
1359 query="/ei-producer/v1/eitypes/$2"
1361 res="$(__do_curl_to_api ICS DELETE $query)"
1362 status=${res:${#res}-3}
1364 if [ $status -ne $1 ]; then
1365 __log_test_fail_status_code $1 $status
1373 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
1374 # args: (v1_1) <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | [<type-id> <schema-file>]+) ]
1375 # (Function for test scripts)
1376 ics_api_edp_get_producer() {
1379 #Possible arg count: 2, 5 6, 8, 10 etc
1381 if [ $# -eq 2 ]; then
1384 if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then
1387 variablecount=$(($#-4))
1388 if [ $# -gt 5 ] && [ $(($variablecount%2)) -eq 0 ]; then
1392 if [ $paramError -ne 0 ]; then
1393 __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (NOID | [<type-id> <schema-file>]+) ]" $@
1397 query="/ei-producer/v1/eiproducers/$2"
1398 res="$(__do_curl_to_api ICS GET $query)"
1399 status=${res:${#res}-3}
1401 if [ $status -ne $1 ]; then
1402 __log_test_fail_status_code $1 $status
1406 if [ $# -gt 2 ]; then
1407 body=${res:0:${#res}-3}
1409 if [ $# -gt 5 ]; then
1411 for ((i=0; i<$(($#-5)); i=i+2)); do
1412 if [ "$targetJson" != "[" ]; then
1413 targetJson=$targetJson","
1415 if [ -f ${arr[$i+1]} ]; then
1416 schema=$(cat ${arr[$i+1]})
1418 __log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
1422 targetJson=$targetJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
1425 targetJson=$targetJson"]"
1426 if [ $# -gt 4 ]; then
1427 targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
1429 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1430 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1432 if [ $res -ne 0 ]; then
1433 __log_test_fail_body
1442 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
1443 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}
1444 # args (v1_2): <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]
1445 # (Function for test scripts)
1446 ics_api_edp_get_producer_2() {
1449 #Possible arg count: 2, 5, 6, 7, 8 etc
1451 if [ $# -eq 2 ]; then
1454 if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then
1457 if [ $# -ge 5 ]; then
1461 if [ $paramError -ne 0 ]; then
1462 __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]" $@
1465 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1466 query="/data-producer/v1/info-producers/$2"
1468 query="/ei-producer/v1/eiproducers/$2"
1470 res="$(__do_curl_to_api ICS GET $query)"
1471 status=${res:${#res}-3}
1473 if [ $status -ne $1 ]; then
1474 __log_test_fail_status_code $1 $status
1478 if [ $# -gt 2 ]; then
1479 body=${res:0:${#res}-3}
1481 if [ $# -gt 4 ] && [ "$5" != "EMPTY" ]; then
1483 for ((i=0; i<$(($#-4)); i=i+1)); do
1484 if [ "$targetJson" != "[" ]; then
1485 targetJson=$targetJson","
1487 targetJson=$targetJson"\"${arr[$i]}\""
1490 targetJson=$targetJson"]"
1491 if [ $# -gt 4 ]; then
1492 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1493 targetJson="{\"supported_info_types\":$targetJson,\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\"}"
1495 targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
1498 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1499 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1501 if [ $res -ne 0 ]; then
1502 __log_test_fail_body
1511 # API Test function: DELETE /ei-producer/v1/eiproducers/{eiProducerId}
1512 # API Test function: DELETE /data-producer/v1/info-producers/{infoProducerId}
1513 # args: <response-code> <producer-id>
1514 # (Function for test scripts)
1515 ics_api_edp_delete_producer() {
1518 if [ $# -lt 2 ]; then
1519 __print_err "<response-code> <producer-id>" $@
1522 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1523 query="/data-producer/v1/info-producers/$2"
1525 query="/ei-producer/v1/eiproducers/$2"
1527 res="$(__do_curl_to_api ICS DELETE $query)"
1528 status=${res:${#res}-3}
1530 if [ $status -ne $1 ]; then
1531 __log_test_fail_status_code $1 $status
1539 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
1540 # args: (v1_1) <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+
1541 # (Function for test scripts)
1542 ics_api_edp_put_producer() {
1545 #Valid number of parametrer 5,6,8,10,
1547 if [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then
1549 elif [ $# -gt 5 ] && [ $(($#%2)) -eq 0 ]; then
1552 if [ $paramError -ne 0 ]; then
1553 __print_err "<response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+" $@
1558 if [ $# -gt 5 ]; then
1560 for ((i=0; i<$(($#-5)); i=i+2)); do
1561 if [ "$inputJson" != "[" ]; then
1562 inputJson=$inputJson","
1564 if [ -f ${arr[$i+1]} ]; then
1565 schema=$(cat ${arr[$i+1]})
1567 __log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
1570 inputJson=$inputJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
1573 inputJson="\"supported_ei_types\":"$inputJson"]"
1575 inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
1577 inputJson="{"$inputJson"}"
1579 file="./tmp/.p.json"
1580 echo "$inputJson" > $file
1581 query="/ei-producer/v1/eiproducers/$2"
1582 res="$(__do_curl_to_api ICS PUT $query $file)"
1583 status=${res:${#res}-3}
1585 if [ $status -ne $1 ]; then
1586 __log_test_fail_status_code $1 $status
1594 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
1595 # API Test function: PUT /data-producer/v1/info-producers/{infoProducerId}
1596 # args: (v1_2) <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]
1597 # (Function for test scripts)
1598 ics_api_edp_put_producer_2() {
1601 #Valid number of parametrer 5,6,8,10,
1603 if [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then
1605 elif [ $# -ge 5 ]; then
1608 if [ $paramError -ne 0 ]; then
1609 __print_err "<response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]" $@
1614 if [ $# -gt 4 ] && [ "$5" != "NOTYPE" ]; then
1616 for ((i=0; i<$(($#-4)); i=i+1)); do
1617 if [ "$inputJson" != "[" ]; then
1618 inputJson=$inputJson","
1620 inputJson=$inputJson"\""${arr[$i]}"\""
1623 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1624 inputJson="\"supported_info_types\":"$inputJson"]"
1626 inputJson=$inputJson",\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\""
1628 inputJson="{"$inputJson"}"
1630 file="./tmp/.p.json"
1631 echo "$inputJson" > $file
1632 query="/data-producer/v1/info-producers/$2"
1634 inputJson="\"supported_ei_types\":"$inputJson"]"
1636 inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
1638 inputJson="{"$inputJson"}"
1640 file="./tmp/.p.json"
1641 echo "$inputJson" > $file
1642 query="/ei-producer/v1/eiproducers/$2"
1644 res="$(__do_curl_to_api ICS PUT $query $file)"
1645 status=${res:${#res}-3}
1647 if [ $status -ne $1 ]; then
1648 __log_test_fail_status_code $1 $status
1656 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
1657 # args: (V1-1) <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)
1658 # (Function for test scripts)
1659 ics_api_edp_get_producer_jobs() {
1662 #Valid number of parameter 2,3,7,11
1664 if [ $# -eq 2 ]; then
1667 if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
1670 variablecount=$(($#-2))
1671 if [ $# -gt 3 ] && [ $(($variablecount%5)) -eq 0 ]; then
1674 if [ $paramError -eq 1 ]; then
1675 __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)" $@
1679 query="/ei-producer/v1/eiproducers/$2/eijobs"
1680 res="$(__do_curl_to_api ICS GET $query)"
1681 status=${res:${#res}-3}
1682 if [ $status -ne $1 ]; then
1683 __log_test_fail_status_code $1 $status
1686 if [ $# -gt 2 ]; then
1687 body=${res:0:${#res}-3}
1689 if [ $# -gt 3 ]; then
1691 for ((i=0; i<$(($#-3)); i=i+5)); do
1692 if [ "$targetJson" != "[" ]; then
1693 targetJson=$targetJson","
1695 if [ -f ${arr[$i+4]} ]; then
1696 jobfile=$(cat ${arr[$i+4]})
1697 jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
1699 __log_test_fail_general "Job template file "${arr[$i+4]}", does not exist"
1702 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}"
1705 targetJson=$targetJson"]"
1707 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1708 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1710 if [ $res -ne 0 ]; then
1711 __log_test_fail_body
1720 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
1721 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}/info-jobs
1722 # args: (V1-2) <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)
1723 # (Function for test scripts)
1724 ics_api_edp_get_producer_jobs_2() {
1727 #Valid number of parameter 2,3,7,11
1729 if [ $# -eq 2 ]; then
1732 if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
1735 variablecount=$(($#-2))
1736 if [ $# -gt 3 ] && [ $(($variablecount%5)) -eq 0 ]; then
1739 if [ $paramError -eq 1 ]; then
1740 __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)" $@
1743 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1744 query="/data-producer/v1/info-producers/$2/info-jobs"
1746 query="/ei-producer/v1/eiproducers/$2/eijobs"
1748 res="$(__do_curl_to_api ICS GET $query)"
1749 status=${res:${#res}-3}
1750 if [ $status -ne $1 ]; then
1751 __log_test_fail_status_code $1 $status
1754 if [ $# -gt 2 ]; then
1755 body=${res:0:${#res}-3}
1757 if [ $# -gt 3 ]; then
1759 for ((i=0; i<$(($#-3)); i=i+5)); do
1760 if [ "$targetJson" != "[" ]; then
1761 targetJson=$targetJson","
1763 if [ -f ${arr[$i+4]} ]; then
1764 jobfile=$(cat ${arr[$i+4]})
1765 jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
1767 __log_test_fail_general "Job template file "${arr[$i+4]}", does not exist"
1770 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1771 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\":\"????\"}"
1773 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\":\"????\"}"
1777 targetJson=$targetJson"]"
1779 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1780 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1782 if [ $res -ne 0 ]; then
1783 __log_test_fail_body
1792 ##########################################
1793 #### Service status ####
1794 ##########################################
1795 # Function prefix: ics_api_service
1797 # API Test function: GET ​/status
1798 # args: <response-code>
1799 # (Function for test scripts)
1800 ics_api_service_status() {
1803 if [ $# -lt 1 ]; then
1804 __print_err "<response-code>" $@
1807 res="$(__do_curl_to_api ICS GET /status)"
1808 status=${res:${#res}-3}
1809 if [ $status -ne $1 ]; then
1810 __log_test_fail_status_code $1 $status
1817 ###########################################
1818 ######### Info data consumer API ##########
1819 ###########################################
1820 #Function prefix: ics_api_idc
1823 # API Test function: GET /data-consumer/v1/info-types
1824 # args: <response-code> [ (EMPTY | [<type-id>]+) ]
1825 # (Function for test scripts)
1826 ics_api_idc_get_type_ids() {
1829 if [ $# -lt 1 ]; then
1830 __print_err "<response-code> [ (EMPTY | [<type-id>]+) ]" $@
1834 query="/data-consumer/v1/info-types"
1835 res="$(__do_curl_to_api ICS GET $query)"
1836 status=${res:${#res}-3}
1838 if [ $status -ne $1 ]; then
1839 __log_test_fail_status_code $1 $status
1842 if [ $# -gt 1 ]; then
1843 body=${res:0:${#res}-3}
1845 if [ $2 != "EMPTY" ]; then
1846 for pid in ${@:2} ; do
1847 if [ "$targetJson" != "[" ]; then
1848 targetJson=$targetJson","
1850 targetJson=$targetJson"\"$pid\""
1853 targetJson=$targetJson"]"
1854 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1855 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1857 if [ $res -ne 0 ]; then
1858 __log_test_fail_body
1867 # API Test function: GET /data-consumer/v1/info-jobs
1868 # args: <response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
1869 # (Function for test scripts)
1870 ics_api_idc_get_job_ids() {
1873 # Valid number of parameters 4,5,6 etc
1874 if [ $# -lt 3 ]; then
1875 __print_err "<response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
1879 if [ $3 != "NOWNER" ]; then
1883 if [ $2 != "NOTYPE" ]; then
1884 if [ -z "$search" ]; then
1885 search="?infoTypeId="$2
1887 search=$search"&infoTypeId="$2
1890 query="/data-consumer/v1/info-jobs$search"
1892 res="$(__do_curl_to_api ICS GET $query)"
1893 status=${res:${#res}-3}
1895 if [ $status -ne $1 ]; then
1896 __log_test_fail_status_code $1 $status
1900 if [ $# -gt 3 ]; then
1901 body=${res:0:${#res}-3}
1904 for pid in ${@:4} ; do
1905 if [ "$targetJson" != "[" ]; then
1906 targetJson=$targetJson","
1908 if [ $pid != "EMPTY" ]; then
1909 targetJson=$targetJson"\"$pid\""
1913 targetJson=$targetJson"]"
1914 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1915 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1917 if [ $res -ne 0 ]; then
1918 __log_test_fail_body
1927 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}
1928 # args: <response-code> <job-id> [<type-id> <target-url> <owner-id> <template-job-file>]
1929 # (Function for test scripts)
1930 ics_api_idc_get_job() {
1933 if [ $# -ne 2 ] && [ $# -ne 7 ]; then
1934 __print_err "<response-code> <job-id> [<type-id> <target-url> <owner-id> <notification-url> <template-job-file>]" $@
1937 query="/data-consumer/v1/info-jobs/$2"
1938 res="$(__do_curl_to_api ICS GET $query)"
1939 status=${res:${#res}-3}
1941 if [ $status -ne $1 ]; then
1942 __log_test_fail_status_code $1 $status
1946 if [ $# -eq 7 ]; then
1947 body=${res:0:${#res}-3}
1951 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
1953 __log_test_fail_general "Job template file "$6", does not exist"
1956 targetJson="{\"info_type_id\": \"$3\", \"job_result_uri\": \"$4\",\"job_owner\": \"$5\",\"status_notification_uri\": \"$6\",\"job_definition\": $jobfile}"
1957 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1958 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1960 if [ $res -ne 0 ]; then
1961 __log_test_fail_body
1971 # API Test function: PUT ​/data-consumer/v1/info-jobs/{infoJobId}
1972 # args: <response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file> [ VALIDATE ]
1973 # (Function for test scripts)
1974 ics_api_idc_put_job() {
1977 if [ $# -lt 7 ] || [ $# -gt 8 ]; then
1978 __print_err "<response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file> [ VALIDATE ]" $@
1983 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
1985 __log_test_fail_general "Job template file "$7", does not exist"
1989 inputJson="{\"info_type_id\": \"$3\", \"job_result_uri\": \"$4\",\"job_owner\": \"$5\",\"status_notification_uri\": \"$6\",\"job_definition\": $jobfile}"
1990 file="./tmp/.p.json"
1991 echo "$inputJson" > $file
1993 query="/data-consumer/v1/info-jobs/$2"
1995 if [ $# -eq 8 ]; then
1996 if [ $8 == "VALIDATE" ]; then
1997 query=$query"?typeCheck=true"
2001 res="$(__do_curl_to_api ICS PUT $query $file)"
2002 status=${res:${#res}-3}
2004 if [ $status -ne $1 ]; then
2005 __log_test_fail_status_code $1 $status
2013 # API Test function: DELETE ​/data-consumer/v1/info-jobs/{infoJobId}
2014 # args: <response-code> <job-id>
2015 # (Function for test scripts)
2016 ics_api_idc_delete_job() {
2019 if [ $# -ne 2 ]; then
2020 __print_err "<response-code> <job-id>" $@
2023 query="/data-consumer/v1/info-jobs/$2"
2024 res="$(__do_curl_to_api ICS DELETE $query)"
2025 status=${res:${#res}-3}
2027 if [ $status -ne $1 ]; then
2028 __log_test_fail_status_code $1 $status
2036 # API Test function: GET ​/data-consumer/v1/info-types/{infoTypeId}
2037 # args: <response-code> <type-id> [<schema-file> [<type-status> <producers-count]]
2038 # (Function for test scripts)
2039 ics_api_idc_get_type() {
2042 if [ $# -lt 2 ] || [ $# -gt 5 ]; then
2043 __print_err "<response-code> <type-id> [<schema-file> [<type-status> <producers-count]]" $@
2047 query="/data-consumer/v1/info-types/$2"
2048 res="$(__do_curl_to_api ICS GET $query)"
2049 status=${res:${#res}-3}
2051 if [ $status -ne $1 ]; then
2052 __log_test_fail_status_code $1 $status
2056 if [ $# -gt 2 ]; then
2057 body=${res:0:${#res}-3}
2061 __log_test_fail_general "Schema file "$3", does not exist"
2064 if [ $# -eq 5 ]; then
2065 targetJson="{\"job_data_schema\":$schema, \"type_status\":\"$4\", \"no_of_producers\":$5}"
2067 targetJson="{\"job_data_schema\":$schema}"
2069 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2070 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2072 if [ $res -ne 0 ]; then
2073 __log_test_fail_body
2082 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}/status
2083 # This test only status during an optional timeout. No test of the list of producers
2084 # args: <response-code> <job-id> [<status> [<timeout>]]
2085 # (Function for test scripts)
2086 ics_api_idc_get_job_status() {
2089 if [ $# -lt 2 ] && [ $# -gt 4 ]; then
2090 __print_err "<response-code> <job-id> [<status> [<timeout>]]" $@
2094 query="/data-consumer/v1/info-jobs/$2/status"
2098 res="$(__do_curl_to_api ICS GET $query)"
2099 status=${res:${#res}-3}
2101 if [ $# -eq 4 ]; then
2102 duration=$((SECONDS-start))
2103 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
2104 if [ $duration -gt $4 ]; then
2106 duration=-1 #Last iteration
2109 duration=-1 #single test, no wait
2112 if [ $status -ne $1 ]; then
2113 if [ $duration -eq -1 ]; then
2114 __log_test_fail_status_code $1 $status
2118 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
2119 body=${res:0:${#res}-3}
2120 targetJson="{\"info_job_status\": \"$3\"}"
2121 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2122 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2124 if [ $res -ne 0 ]; then
2125 if [ $duration -eq -1 ]; then
2126 __log_test_fail_body
2130 duration=-1 #Goto pass
2133 if [ $duration -eq -1 ]; then
2134 if [ $# -eq 4 ]; then
2148 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}/status
2149 # This function test status and the list of producers with and optional timeout
2150 # args: <response-code> <job-id> [<status> EMPTYPROD|( <prod-count> <producer-id>+ ) [<timeout>]]
2151 # (Function for test scripts)
2152 ics_api_idc_get_job_status2() {
2156 if [ $# -lt 2 ]; then
2161 if [ $# -gt 2 ]; then
2162 if [ $# -lt 4 ]; then
2165 targetJson="{\"info_job_status\": \"$3\""
2166 if [ "$4" == "EMPTYPROD" ]; then
2167 targetJson=$targetJson",\"producers\": []}"
2168 if [ $# -gt 4 ]; then
2172 targetJson=$targetJson",\"producers\": ["
2173 if [ $# -eq $(($4+5)) ]; then
2175 timeout=${args[$idx]}
2177 for ((ics_i = 0 ; ics_i < $4 ; ics_i++)); do
2179 if [ $ics_i -gt 0 ]; then
2180 targetJson=$targetJson","
2182 targetJson=$targetJson"\""${args[$idx]}"\""
2184 targetJson=$targetJson"]}"
2188 if [ $param_error -ne 0 ]; then
2189 __print_err "<response-code> <job-id> [<status> EMPTYPROD|( <prod-count> <producer-id>+ ) [<timeout>]]" $@
2193 query="/data-consumer/v1/info-jobs/$2/status"
2197 res="$(__do_curl_to_api ICS GET $query)"
2198 status=${res:${#res}-3}
2200 if [ $# -gt 2 ]; then
2201 duration=$((SECONDS-start))
2202 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
2203 if [ $duration -gt $timeout ]; then
2205 duration=-1 #Last iteration
2208 duration=-1 #single test, no wait
2211 if [ $status -ne $1 ]; then
2212 if [ $duration -eq -1 ]; then
2213 __log_test_fail_status_code $1 $status
2217 if [ $# -gt 2 ] && [ $status -eq $1 ]; then
2218 body=${res:0:${#res}-3}
2219 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2220 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2222 if [ $res -ne 0 ]; then
2223 if [ $duration -eq -1 ]; then
2224 __log_test_fail_body
2228 duration=-1 #Goto pass
2231 if [ $duration -eq -1 ]; then
2232 if [ $# -eq 4 ]; then
2246 ##########################################
2247 #### Type subscriptions ####
2248 ##########################################
2250 # API Test function: GET /data-consumer/v1/info-type-subscription
2251 # args: <response-code> <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]
2252 # (Function for test scripts)
2253 ics_api_idc_get_subscription_ids() {
2256 if [ $# -lt 3 ]; then
2257 __print_err "<response-code> <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]" $@
2261 query="/data-consumer/v1/info-type-subscription"
2263 if [ $2 != "NOOWNER" ]; then
2267 res="$(__do_curl_to_api ICS GET $query$search)"
2268 status=${res:${#res}-3}
2270 if [ $status -ne $1 ]; then
2271 __log_test_fail_status_code $1 $status
2275 if [ $# -gt 2 ]; then
2276 body=${res:0:${#res}-3}
2278 if [ $3 != "EMPTY" ]; then
2279 for pid in ${@:3} ; do
2280 if [ "$targetJson" != "[" ]; then
2281 targetJson=$targetJson","
2283 targetJson=$targetJson"\"$pid\""
2286 targetJson=$targetJson"]"
2287 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2288 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2290 if [ $res -ne 0 ]; then
2291 __log_test_fail_body
2300 # API Test function: GET /data-consumer/v1/info-type-subscription/{subscriptionId}
2301 # args: <response-code> <subscription-id> [ <owner-id> <status-uri> ]
2302 # (Function for test scripts)
2303 ics_api_idc_get_subscription() {
2306 if [ $# -ne 2 ] && [ $# -ne 4 ]; then
2307 __print_err "<response-code> <subscription-id> [ <owner-id> <status-uri> ]" $@
2311 query="/data-consumer/v1/info-type-subscription/$2"
2312 res="$(__do_curl_to_api ICS GET $query)"
2313 status=${res:${#res}-3}
2315 if [ $status -ne $1 ]; then
2316 __log_test_fail_status_code $1 $status
2320 if [ $# -gt 2 ]; then
2321 body=${res:0:${#res}-3}
2322 targetJson="{\"owner\":\"$3\",\"status_result_uri\":\"$4\"}"
2323 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2324 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2326 if [ $res -ne 0 ]; then
2327 __log_test_fail_body
2336 # API Test function: PUT /data-consumer/v1/info-type-subscription/{subscriptionId}
2337 # args: <response-code> <subscription-id> <owner-id> <status-uri>
2338 # (Function for test scripts)
2339 ics_api_idc_put_subscription() {
2342 if [ $# -ne 4 ]; then
2343 __print_err "<response-code> <subscription-id> <owner-id> <status-uri>" $@
2347 inputJson="{\"owner\": \"$3\",\"status_result_uri\": \"$4\"}"
2348 file="./tmp/.p.json"
2349 echo "$inputJson" > $file
2351 query="/data-consumer/v1/info-type-subscription/$2"
2352 res="$(__do_curl_to_api ICS PUT $query $file)"
2353 status=${res:${#res}-3}
2355 if [ $status -ne $1 ]; then
2356 __log_test_fail_status_code $1 $status
2364 # API Test function: DELETE /data-consumer/v1/info-type-subscription/{subscriptionId}
2365 # args: <response-code> <subscription-id>
2366 # (Function for test scripts)
2367 ics_api_idc_delete_subscription() {
2370 if [ $# -ne 2 ]; then
2371 __print_err "<response-code> <subscription-id> " $@
2375 query="/data-consumer/v1/info-type-subscription/$2"
2376 res="$(__do_curl_to_api ICS DELETE $query)"
2377 status=${res:${#res}-3}
2379 if [ $status -ne $1 ]; then
2380 __log_test_fail_status_code $1 $status
2388 ##########################################
2389 #### Reset jobs ####
2390 ##########################################
2391 # Function prefix: ics_api_admin
2393 # Admin to remove all jobs
2394 # args: <response-code> [ <type> ]
2395 # (Function for test scripts)
2397 ics_api_admin_reset() {
2400 if [ -z "$FLAT_A1_EI" ]; then
2401 query="/A1-EI/v1/eitypes/$2/eijobs"
2403 query="/A1-EI/v1/eijobs"
2405 res="$(__do_curl_to_api ICS GET $query)"
2406 status=${res:${#res}-3}
2408 if [ $status -ne 200 ]; then
2409 __log_test_fail_status_code $1 $status
2413 #Remove brackets and response code
2414 body=${res:1:${#res}-4}
2415 list=$(echo ${body//,/ })
2416 list=$(echo ${list//[/})
2417 list=$(echo ${list//]/})
2418 list=$(echo ${list//\"/})
2420 for job in $list; do
2421 if [ -z "$FLAT_A1_EI" ]; then
2422 echo "Not supported for non-flat EI api"
2424 query="/A1-EI/v1/eijobs/$job"
2425 res="$(__do_curl_to_api ICS DELETE $query)"
2426 status=${res:${#res}-3}
2427 if [ $status -ne 204 ]; then
2428 __log_test_fail_status_code $1 $status
2431 echo " Deleted job: "$job
2439 ##########################################
2440 #### Reset jobs and producers ####
2441 ##########################################
2444 # Admin reset to remove all data in ics; jobs, producers etc
2445 # NOTE - only works in kubernetes and the pod should not be running
2447 # (Function for test scripts)
2449 ics_kube_pvc_reset() {
2452 pvc_name=$(kubectl get pvc -n $KUBE_NONRTRIC_NAMESPACE --no-headers -o custom-columns=":metadata.name" | grep information)
2453 if [ -z "$pvc_name" ]; then
2454 pvc_name=informationservice-pvc
2456 echo " Trying to reset pvc: "$pvc_name
2458 __kube_clean_pvc $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE $pvc_name $ICS_CONTAINER_MNT_DIR