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 $KUBECONF 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)
195 export HOST_PATH_BASE_DIR
197 if [ $1 == "PROXY" ]; then
198 export ICS_HTTP_PROXY_CONFIG_PORT=$HTTP_PROXY_CONFIG_PORT #Set if proxy is started
199 export ICS_HTTP_PROXY_CONFIG_HOST_NAME=$HTTP_PROXY_CONFIG_HOST_NAME #Set if proxy is started
200 if [ $ICS_HTTP_PROXY_CONFIG_PORT -eq 0 ] || [ -z "$ICS_HTTP_PROXY_CONFIG_HOST_NAME" ]; then
201 echo -e $YELLOW" Warning: HTTP PROXY will not be configured, proxy app not started"$EYELLOW
203 echo " Configured with http proxy"
206 export ICS_HTTP_PROXY_CONFIG_PORT=0
207 export ICS_HTTP_PROXY_CONFIG_HOST_NAME=""
208 echo " Configured without http proxy"
214 # args: PROXY|NOPROXY <config-file>
215 # (Function for test scripts)
218 echo -e $BOLD"Starting $ICS_DISPLAY_NAME"$EBOLD
220 if [ $RUNMODE == "KUBE" ]; then
222 # Check if app shall be fully managed by the test script
223 __check_included_image "ICS"
226 # Check if app shall only be used by the testscipt
227 __check_prestarted_image "ICS"
230 if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then
231 echo -e $RED"The $ICS_APP_NAME app is not included as managed nor prestarted in this test script"$ERED
232 echo -e $RED"The $ICS_APP_NAME will not be started"$ERED
235 if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then
236 echo -e $RED"The $ICS_APP_NAME app is included both as managed and prestarted in this test script"$ERED
237 echo -e $RED"The $ICS_APP_NAME will not be started"$ERED
241 if [ $retcode_p -eq 0 ]; then
242 echo -e " Using existing $ICS_APP_NAME deployment and service"
243 echo " Setting ICS replicas=1"
244 res_type=$(__kube_get_resource_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
245 __kube_scale $res_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
248 # Check if app shall be fully managed by the test script
249 if [ $retcode_i -eq 0 ]; then
250 echo -e " Creating $ICS_APP_NAME app and expose service"
252 #Check if nonrtric namespace exists, if not create it
253 __kube_create_namespace $KUBE_NONRTRIC_NAMESPACE
257 # Create config map for config
258 datafile=$PWD/tmp/$ICS_CONFIG_FILE
260 output_yaml=$PWD/tmp/ics_cfc.yaml
261 __kube_create_configmap $ICS_CONFIG_CONFIGMAP_NAME $KUBE_NONRTRIC_NAMESPACE autotest ICS $datafile $output_yaml
264 input_yaml=$SIM_GROUP"/"$ICS_COMPOSE_DIR"/"pv.yaml
265 output_yaml=$PWD/tmp/ics_pv.yaml
266 __kube_create_instance pv $ICS_APP_NAME $input_yaml $output_yaml
269 input_yaml=$SIM_GROUP"/"$ICS_COMPOSE_DIR"/"pvc.yaml
270 output_yaml=$PWD/tmp/ics_pvc.yaml
271 __kube_create_instance pvc $ICS_APP_NAME $input_yaml $output_yaml
274 input_yaml=$SIM_GROUP"/"$ICS_COMPOSE_DIR"/"svc.yaml
275 output_yaml=$PWD/tmp/ics_svc.yaml
276 __kube_create_instance service $ICS_APP_NAME $input_yaml $output_yaml
279 input_yaml=$SIM_GROUP"/"$ICS_COMPOSE_DIR"/"app.yaml
280 output_yaml=$PWD/tmp/ics_app.yaml
281 __kube_create_instance app $ICS_APP_NAME $input_yaml $output_yaml
284 # 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
285 # 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
287 # 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
288 if [ $retcode_i -eq 0 ]; then
289 __ICS_WORKER_NODE=$(kubectl $KUBECONF get pod -l "autotest=ICS" -n $KUBE_NONRTRIC_NAMESPACE -o jsonpath='{.items[*].spec.nodeName}')
290 if [ -z "$__ICS_WORKER_NODE" ]; then
291 echo -e $YELLOW" Cannot find worker node for pod for $ICS_APP_NAME, persistency may not work"$EYELLOW
294 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
298 __check_service_start $ICS_APP_NAME $ICS_SERVICE_PATH$ICS_ALIVE_URL
301 __check_included_image 'ICS'
302 if [ $? -eq 1 ]; then
303 echo -e $RED"The ICS app is not included in this test script"$ERED
304 echo -e $RED"ICS will not be started"$ERED
314 if [ "$(ls -A $DIR)" ]; then
315 echo -e $BOLD" Cleaning files in mounted dir: $PWD/db"$EBOLD
316 rm -rf db/* &> /dev/null
317 if [ $? -ne 0 ]; then
318 echo -e $RED" Cannot remove database files in: $PWD"$ERED
323 echo " No files in mounted dir or dir does not exists"
330 dest_file=$SIM_GROUP/$ICS_COMPOSE_DIR/$ICS_HOST_MNT_DIR/$ICS_CONFIG_FILE
332 envsubst < $2 > $dest_file
334 __start_container $ICS_COMPOSE_DIR "" NODOCKERARGS 1 $ICS_APP_NAME
336 __check_service_start $ICS_APP_NAME $ICS_SERVICE_PATH$ICS_ALIVE_URL
345 # (Function for test scripts)
347 echo -e $BOLD"Stopping $ICS_DISPLAY_NAME"$EBOLD
349 if [ $RUNMODE == "KUBE" ]; then
351 __check_prestarted_image "ICS"
352 if [ $? -eq 0 ]; then
353 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
354 res_type=$(__kube_get_resource_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
355 __kube_scale $res_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 0
359 __kube_scale_all_resources $KUBE_NONRTRIC_NAMESPACE autotest ICS
360 echo " Deleting the replica set - a new will be started when the app is started"
361 tmp=$(kubectl $KUBECONF delete rs -n $KUBE_NONRTRIC_NAMESPACE -l "autotest=ICS")
362 if [ $? -ne 0 ]; then
363 echo -e $RED" Could not delete replica set "$RED
368 docker stop $ICS_APP_NAME &> ./tmp/.dockererr
369 if [ $? -ne 0 ]; then
370 __print_err "Could not stop $ICS_APP_NAME" $@
376 echo -e $BOLD$GREEN"Stopped"$EGREEN$EBOLD
381 # Start a previously stopped ics
383 # (Function for test scripts)
384 start_stopped_ics() {
385 echo -e $BOLD"Starting (the previously stopped) $ICS_DISPLAY_NAME"$EBOLD
387 if [ $RUNMODE == "KUBE" ]; then
389 __check_prestarted_image "ICS"
390 if [ $? -eq 0 ]; then
391 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
392 res_type=$(__kube_get_resource_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
393 __kube_scale $res_type $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
394 __check_service_start $ICS_APP_NAME $ICS_SERVICE_PATH$ICS_ALIVE_URL
398 # Tie the ICS to the same worker node it was initially started on
399 # A PVC of type hostPath is mounted to A1PMS, for persistent storage, so the A1PMS must always be on the node which mounted the volume
400 if [ -z "$__ICS_WORKER_NODE" ]; then
401 echo -e $RED" No initial worker node found for pod "$RED
405 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: $__ICS_WORKER_NODE"$BOLD
406 echo -e $BOLD" The mounted volume is mounted as hostPath and only available on that worker node."$BOLD
407 tmp=$(kubectl $KUBECONF patch deployment $ICS_APP_NAME -n $KUBE_NONRTRIC_NAMESPACE --patch '{"spec": {"template": {"spec": {"nodeSelector": {"kubernetes.io/hostname": "'$__ICS_WORKER_NODE'"}}}}}')
408 if [ $? -ne 0 ]; then
409 echo -e $YELLOW" Cannot set nodeSelector to deployment for $ICS_APP_NAME, persistency may not work"$EYELLOW
411 __kube_scale deployment $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
414 docker start $ICS_APP_NAME &> ./tmp/.dockererr
415 if [ $? -ne 0 ]; then
416 __print_err "Could not start (the stopped) $ICS_APP_NAME" $@
422 __check_service_start $ICS_APP_NAME $ICS_SERVICE_PATH$ICS_ALIVE_URL
423 if [ $? -ne 0 ]; then
430 # Turn on debug level tracing in ICS
432 # (Function for test scripts)
434 echo -e $BOLD"Setting ics debug logging"$EBOLD
435 curlString="$ICS_SERVICE_PATH$ICS_ACTUATOR -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"debug\"}"
436 result=$(__do_curl "$curlString")
437 if [ $? -ne 0 ]; then
438 __print_err "Could not set debug mode" $@
446 # Turn on trace level tracing in ICS
448 # (Function for test scripts)
450 echo -e $BOLD"Setting ics trace logging"$EBOLD
451 curlString="$ICS_SERVICE_PATH/actuator/loggers/org.oransc.information -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}"
452 result=$(__do_curl "$curlString")
453 if [ $? -ne 0 ]; then
454 __print_err "Could not set trace mode" $@
462 # Perform curl retries when making direct call to ICS for the specified http response codes
463 # Speace separated list of http response codes
464 # args: [<response-code>]*
466 echo -e $BOLD"Do curl retries to the ICS REST inteface for these response codes:$@"$EBOLD
472 # Check the ics logs for WARNINGs and ERRORs
474 # (Function for test scripts)
476 __check_container_logs "ICS" $ICS_APP_NAME $ICS_LOGPATH WARN ERR
480 # Tests if a variable value in the ICS is equal to a target value and and optional timeout.
481 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
482 # equal to the target or not.
483 # Arg: <variable-name> <target-value> <timeout-in-sec> - This test waits up to the timeout seconds
484 # before setting pass or fail depending on if the variable value becomes equal to the target
486 # (Function for test scripts)
488 if [ $# -eq 2 ] || [ $# -eq 3 ]; then
489 __var_test ICS "$ICS_SERVICE_PATH/" $1 "=" $2 $3
491 __print_err "Wrong args to ics_equal, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
496 ##########################################
497 ######### A1-E information API ##########
498 ##########################################
499 #Function prefix: ics_api_a1
501 # API Test function: GET /A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs
502 # args: <response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
503 # args (flat uri structure): <response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
504 # (Function for test scripts)
505 ics_api_a1_get_job_ids() {
508 if [ -z "$FLAT_A1_EI" ]; then
509 # Valid number of parameters 4,5,6 etc
510 if [ $# -lt 3 ]; then
511 __print_err "<response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
515 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
516 # Valid number of parameters 4,5,6 etc
517 if [ $# -lt 3 ]; then
518 __print_err "<response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
523 if [ $3 != "NOWNER" ]; then
527 if [ -z "$FLAT_A1_EI" ]; then
528 query="/A1-EI/v1/eitypes/$2/eijobs$search"
530 if [ $2 != "NOTYPE" ]; then
531 if [ -z "$search" ]; then
532 search="?eiTypeId="$2
534 search=$search"&eiTypeId="$2
537 query="/A1-EI/v1/eijobs$search"
539 res="$(__do_curl_to_api ICS GET $query)"
540 status=${res:${#res}-3}
542 if [ $status -ne $1 ]; then
543 __log_test_fail_status_code $1 $status
547 if [ $# -gt 3 ]; then
548 body=${res:0:${#res}-3}
551 for pid in ${@:4} ; do
552 if [ "$targetJson" != "[" ]; then
553 targetJson=$targetJson","
555 if [ $pid != "EMPTY" ]; then
556 targetJson=$targetJson"\"$pid\""
560 targetJson=$targetJson"]"
561 echo " TARGET JSON: $targetJson" >> $HTTPLOG
562 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
564 if [ $res -ne 0 ]; then
574 # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}
575 # args: <response-code> <type-id> [<schema-file>]
576 # (Function for test scripts)
577 ics_api_a1_get_type() {
580 if [ $# -lt 2 ] || [ $# -gt 3 ]; then
581 __print_err "<response-code> <type-id> [<schema-file>]" $@
585 query="/A1-EI/v1/eitypes/$2"
586 res="$(__do_curl_to_api ICS GET $query)"
587 status=${res:${#res}-3}
589 if [ $status -ne $1 ]; then
590 __log_test_fail_status_code $1 $status
594 if [ $# -eq 3 ]; then
595 body=${res:0:${#res}-3}
599 __log_test_fail_general "Schema file "$3", does not exist"
602 if [ -z "$FLAT_A1_EI" ]; then
603 targetJson="{\"eiJobParametersSchema\":$schema}"
607 echo " TARGET JSON: $targetJson" >> $HTTPLOG
608 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
610 if [ $res -ne 0 ]; then
620 # API Test function: GET /A1-EI/v1/eitypes
621 # args: <response-code> [ (EMPTY | [<type-id>]+) ]
622 # (Function for test scripts)
623 ics_api_a1_get_type_ids() {
626 if [ $# -lt 1 ]; then
627 __print_err "<response-code> [ (EMPTY | [<type-id>]+) ]" $@
631 query="/A1-EI/v1/eitypes"
632 res="$(__do_curl_to_api ICS GET $query)"
633 status=${res:${#res}-3}
635 if [ $status -ne $1 ]; then
636 __log_test_fail_status_code $1 $status
639 if [ $# -gt 1 ]; then
640 body=${res:0:${#res}-3}
642 if [ $2 != "EMPTY" ]; then
643 for pid in ${@:2} ; do
644 if [ "$targetJson" != "[" ]; then
645 targetJson=$targetJson","
647 targetJson=$targetJson"\"$pid\""
650 targetJson=$targetJson"]"
651 echo " TARGET JSON: $targetJson" >> $HTTPLOG
652 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
654 if [ $res -ne 0 ]; then
664 # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}​/status
665 # args: <response-code> <type-id> <job-id> [<status>]
666 # args (flat uri structure): <response-code> <job-id> [<status> [<timeout>]]
667 # (Function for test scripts)
668 ics_api_a1_get_job_status() {
671 if [ -z "$FLAT_A1_EI" ]; then
672 if [ $# -ne 3 ] && [ $# -ne 4 ]; then
673 __print_err "<response-code> <type-id> <job-id> [<status>]" $@
677 query="/A1-EI/v1/eitypes/$2/eijobs/$3/status"
679 res="$(__do_curl_to_api ICS GET $query)"
680 status=${res:${#res}-3}
682 if [ $status -ne $1 ]; then
683 __log_test_fail_status_code $1 $status
686 if [ $# -eq 4 ]; then
687 body=${res:0:${#res}-3}
688 targetJson="{\"operationalState\": \"$4\"}"
689 echo " TARGET JSON: $targetJson" >> $HTTPLOG
690 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
692 if [ $res -ne 0 ]; then
698 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
699 if [ $# -lt 2 ] && [ $# -gt 4 ]; then
700 __print_err "<response-code> <job-id> [<status> [<timeout>]]" $@
704 query="/A1-EI/v1/eijobs/$2/status"
708 res="$(__do_curl_to_api ICS GET $query)"
709 status=${res:${#res}-3}
711 if [ $# -eq 4 ]; then
712 duration=$((SECONDS-start))
713 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
714 if [ $duration -gt $4 ]; then
716 duration=-1 #Last iteration
719 duration=-1 #single test, no wait
722 if [ $status -ne $1 ]; then
723 if [ $duration -eq -1 ]; then
724 __log_test_fail_status_code $1 $status
728 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
729 body=${res:0:${#res}-3}
730 targetJson="{\"eiJobStatus\": \"$3\"}"
731 echo " TARGET JSON: $targetJson" >> $HTTPLOG
732 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
734 if [ $res -ne 0 ]; then
735 if [ $duration -eq -1 ]; then
740 duration=-1 #Goto pass
743 if [ $duration -eq -1 ]; then
744 if [ $# -eq 4 ]; then
759 # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
760 # args: <response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]
761 # args (flat uri structure): <response-code> <job-id> [<type-id> <target-url> <owner-id> <template-job-file>]
762 # (Function for test scripts)
763 ics_api_a1_get_job() {
766 if [ -z "$FLAT_A1_EI" ]; then
767 if [ $# -ne 3 ] && [ $# -ne 6 ]; then
768 __print_err "<response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]" $@
771 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
773 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
774 if [ $# -ne 2 ] && [ $# -ne 7 ]; then
775 __print_err "<response-code> <job-id> [<type-id> <target-url> <owner-id> <notification-url> <template-job-file>]" $@
778 query="/A1-EI/v1/eijobs/$2"
780 res="$(__do_curl_to_api ICS GET $query)"
781 status=${res:${#res}-3}
783 if [ $status -ne $1 ]; then
784 __log_test_fail_status_code $1 $status
788 if [ -z "$FLAT_A1_EI" ]; then
789 if [ $# -eq 6 ]; then
790 body=${res:0:${#res}-3}
794 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
796 __log_test_fail_general "Job template file "$6", does not exist"
799 targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
800 echo " TARGET JSON: $targetJson" >> $HTTPLOG
801 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
803 if [ $res -ne 0 ]; then
809 if [ $# -eq 7 ]; then
810 body=${res:0:${#res}-3}
814 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
816 __log_test_fail_general "Job template file "$6", does not exist"
819 targetJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
820 echo " TARGET JSON: $targetJson" >> $HTTPLOG
821 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
823 if [ $res -ne 0 ]; then
834 # API Test function: DELETE ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
835 # args: <response-code> <type-id> <job-id>
836 # args (flat uri structure): <response-code> <job-id>
837 # (Function for test scripts)
838 ics_api_a1_delete_job() {
841 if [ -z "$FLAT_A1_EI" ]; then
842 if [ $# -ne 3 ]; then
843 __print_err "<response-code> <type-id> <job-id>" $@
847 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
849 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
850 if [ $# -ne 2 ]; then
851 __print_err "<response-code> <job-id>" $@
854 query="/A1-EI/v1/eijobs/$2"
856 res="$(__do_curl_to_api ICS DELETE $query)"
857 status=${res:${#res}-3}
859 if [ $status -ne $1 ]; then
860 __log_test_fail_status_code $1 $status
868 # API Test function: PUT ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
869 # args: <response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>
870 # args (flat uri structure): <response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file>
871 # (Function for test scripts)
872 ics_api_a1_put_job() {
875 if [ -z "$FLAT_A1_EI" ]; then
876 if [ $# -lt 6 ]; then
877 __print_err "<response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>" $@
882 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
884 __log_test_fail_general "Job template file "$6", does not exist"
888 inputJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
890 echo "$inputJson" > $file
892 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
894 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
895 if [ $# -lt 7 ]; then
896 __print_err "<response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file>" $@
901 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
903 __log_test_fail_general "Job template file "$7", does not exist"
907 inputJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
909 echo "$inputJson" > $file
911 query="/A1-EI/v1/eijobs/$2"
914 res="$(__do_curl_to_api ICS PUT $query $file)"
915 status=${res:${#res}-3}
917 if [ $status -ne $1 ]; then
918 __log_test_fail_status_code $1 $status
927 ##########################################
928 #### information Data Producer API ####
929 ##########################################
930 # Function prefix: ics_api_edp
932 # API Test function: GET /ei-producer/v1/eitypes
933 # API Test function: GET /data-producer/v1/info-types
934 # args: <response-code> [ EMPTY | <type-id>+]
935 # (Function for test scripts)
936 ics_api_edp_get_type_ids() {
939 if [ $# -lt 1 ]; then
940 __print_err "<response-code> [ EMPTY | <type-id>+]" $@
943 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
944 query="/data-producer/v1/info-types"
946 query="/ei-producer/v1/eitypes"
948 res="$(__do_curl_to_api ICS GET $query)"
949 status=${res:${#res}-3}
951 if [ $status -ne $1 ]; then
952 __log_test_fail_status_code $1 $status
956 if [ $# -gt 1 ]; then
957 body=${res:0:${#res}-3}
959 if [ $2 != "EMPTY" ]; then
960 for pid in ${@:2} ; do
961 if [ "$targetJson" != "[" ]; then
962 targetJson=$targetJson","
964 targetJson=$targetJson"\"$pid\""
967 targetJson=$targetJson"]"
968 echo " TARGET JSON: $targetJson" >> $HTTPLOG
969 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
971 if [ $res -ne 0 ]; then
981 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/status
982 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}/status
983 # args: <response-code> <producer-id> [<status> [<timeout>]]
984 # (Function for test scripts)
985 ics_api_edp_get_producer_status() {
988 if [ $# -lt 2 ] || [ $# -gt 4 ]; then
989 __print_err "<response-code> <producer-id> [<status> [<timeout>]]" $@
992 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
993 query="/data-producer/v1/info-producers/$2/status"
995 query="/ei-producer/v1/eiproducers/$2/status"
999 res="$(__do_curl_to_api ICS GET $query)"
1000 status=${res:${#res}-3}
1002 if [ $# -eq 4 ]; then
1003 duration=$((SECONDS-start))
1004 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
1005 if [ $duration -gt $4 ]; then
1007 duration=-1 #Last iteration
1010 duration=-1 #single test, no wait
1013 if [ $status -ne $1 ]; then
1014 if [ $duration -eq -1 ]; then
1015 __log_test_fail_status_code $1 $status
1019 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
1020 body=${res:0:${#res}-3}
1021 targetJson="{\"operational_state\": \"$3\"}"
1022 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1023 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1025 if [ $res -ne 0 ]; then
1026 if [ $duration -eq -1 ]; then
1027 __log_test_fail_body
1031 duration=-1 #Goto pass
1034 if [ $duration -eq -1 ]; then
1035 if [ $# -eq 4 ]; then
1047 # API Test function: GET /ei-producer/v1/eiproducers
1048 # args (v1_1): <response-code> [ EMPTY | <producer-id>+]
1049 # (Function for test scripts)
1050 ics_api_edp_get_producer_ids() {
1053 if [ $# -lt 1 ]; then
1054 __print_err "<response-code> [ EMPTY | <producer-id>+]" $@
1058 query="/ei-producer/v1/eiproducers"
1059 res="$(__do_curl_to_api ICS GET $query)"
1060 status=${res:${#res}-3}
1062 if [ $status -ne $1 ]; then
1063 __log_test_fail_status_code $1 $status
1067 if [ $# -gt 1 ]; then
1068 body=${res:0:${#res}-3}
1071 for pid in ${@:2} ; do
1072 if [ "$targetJson" != "[" ]; then
1073 targetJson=$targetJson","
1075 if [ $pid != "EMPTY" ]; then
1076 targetJson=$targetJson"\"$pid\""
1080 targetJson=$targetJson"]"
1081 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1082 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1084 if [ $res -ne 0 ]; then
1085 __log_test_fail_body
1094 # API Test function: GET /ei-producer/v1/eiproducers
1095 # API Test function: GET /data-producer/v1/info-producers
1096 # args (v1_2): <response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]
1097 # (Function for test scripts)
1098 ics_api_edp_get_producer_ids_2() {
1101 if [ $# -lt 1 ]; then
1102 __print_err "<response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]" $@
1105 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1106 query="/data-producer/v1/info-producers"
1107 if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then
1108 query=$query"?info_type_id=$2&infoTypeId=$2" #info_type_id changed to infoTypeId in F-release.
1109 #Remove info_type_id when F-release is no longer supported
1112 query="/ei-producer/v1/eiproducers"
1113 if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then
1114 query=$query"?ei_type_id=$2"
1117 res="$(__do_curl_to_api ICS GET $query)"
1118 status=${res:${#res}-3}
1120 if [ $status -ne $1 ]; then
1121 __log_test_fail_status_code $1 $status
1125 if [ $# -gt 2 ]; then
1126 body=${res:0:${#res}-3}
1129 for pid in ${@:3} ; do
1130 if [ "$targetJson" != "[" ]; then
1131 targetJson=$targetJson","
1133 if [ $pid != "EMPTY" ]; then
1134 targetJson=$targetJson"\"$pid\""
1138 targetJson=$targetJson"]"
1139 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1140 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1142 if [ $res -ne 0 ]; then
1143 __log_test_fail_body
1152 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
1153 # args: (v1_1) <response-code> <type-id> [<job-schema-file> (EMPTY | [<producer-id>]+)]
1154 # (Function for test scripts)
1155 ics_api_edp_get_type() {
1159 if [ $# -eq 2 ]; then
1162 if [ $# -gt 3 ]; then
1165 if [ $paramError -ne 0 ]; then
1166 __print_err "<response-code> <type-id> [<job-schema-file> 'EMPTY' | ([<producer-id>]+)]" $@
1170 query="/ei-producer/v1/eitypes/$2"
1171 res="$(__do_curl_to_api ICS GET $query)"
1172 status=${res:${#res}-3}
1174 if [ $status -ne $1 ]; then
1175 __log_test_fail_status_code $1 $status
1178 if [ $# -gt 3 ]; then
1179 body=${res:0:${#res}-3}
1184 __log_test_fail_general "Job template file "$3", does not exist"
1189 if [ $4 != "EMPTY" ]; then
1190 for pid in ${@:4} ; do
1191 if [ "$targetJson" != "" ]; then
1192 targetJson=$targetJson","
1194 targetJson=$targetJson"\"$pid\""
1197 targetJson="{\"ei_job_data_schema\":$schema, \"ei_producer_ids\": [$targetJson]}"
1199 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1200 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1202 if [ $res -ne 0 ]; then
1203 __log_test_fail_body
1211 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
1212 # API Test function: GET /data-producer/v1/info-types/{infoTypeId}
1213 # args: (v1_2) <response-code> <type-id> [<job-schema-file> [ <info-type-info> ]]
1214 # (Function for test scripts)
1215 ics_api_edp_get_type_2() {
1219 if [ $# -eq 2 ]; then
1222 if [ $# -eq 3 ]; then
1225 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then
1226 if [ $# -eq 4 ]; then
1230 if [ $paramError -ne 0 ]; then
1231 __print_err "<response-code> <type-id> [<job-schema-file> [ <info-type-info> ]]" $@
1234 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1235 query="/data-producer/v1/info-types/$2"
1237 query="/ei-producer/v1/eitypes/$2"
1240 res="$(__do_curl_to_api ICS GET $query)"
1241 status=${res:${#res}-3}
1243 if [ $status -ne $1 ]; then
1244 __log_test_fail_status_code $1 $status
1247 if [ $# -ge 3 ]; then
1248 body=${res:0:${#res}-3}
1253 __log_test_fail_general "Job template file "$3", does not exist"
1257 if [ $# -gt 3 ]; then
1261 __log_test_fail_general "Info-data file "$4", does not exist"
1264 info_data=",\"info_type_information\":$info_data"
1266 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1267 targetJson="{\"info_job_data_schema\":$schema $info_data}"
1269 targetJson="{\"ei_job_data_schema\":$schema}"
1272 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1273 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1275 if [ $res -ne 0 ]; then
1276 __log_test_fail_body
1284 # API Test function: PUT /ei-producer/v1/eitypes/{eiTypeId}
1285 # API Test function: PUT /data-producer/v1/info-types/{infoTypeId}
1286 # args: (v1_2) <response-code> <type-id> <job-schema-file> [ <info-type-info> ]
1287 # (Function for test scripts)
1288 ics_api_edp_put_type_2() {
1291 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then
1292 if [ $# -lt 3 ] || [ $# -gt 4 ]; then
1293 __print_err "<response-code> <type-id> <job-schema-file> [ <info-type-info> ]" $@
1297 if [ $# -ne 3 ]; then
1298 __print_err "<response-code> <type-id> <job-schema-file>" $@
1303 if [ ! -f $3 ]; then
1304 __log_test_fail_general "Job schema file "$3", does not exist"
1309 if [ $# -gt 3 ]; then
1313 __log_test_fail_general "Info-data file "$4", does not exist"
1316 info_data=",\"info_type_information\":$info_data"
1319 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1321 input_json="{\"info_job_data_schema\":$schema $info_data}"
1322 file="./tmp/put_type.json"
1323 echo $input_json > $file
1325 query="/data-producer/v1/info-types/$2"
1328 input_json="{\"ei_job_data_schema\":$schema}"
1329 file="./tmp/put_type.json"
1330 echo $input_json > $file
1332 query="/ei-producer/v1/eitypes/$2"
1334 res="$(__do_curl_to_api ICS PUT $query $file)"
1335 status=${res:${#res}-3}
1337 if [ $status -ne $1 ]; then
1338 __log_test_fail_status_code $1 $status
1346 # API Test function: DELETE /ei-producer/v1/eitypes/{eiTypeId}
1347 # API Test function: DELETE /data-producer/v1/info-types/{infoTypeId}
1348 # args: (v1_2) <response-code> <type-id>
1349 # (Function for test scripts)
1350 ics_api_edp_delete_type_2() {
1353 if [ $# -ne 2 ]; then
1354 __print_err "<response-code> <type-id>" $@
1358 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1359 query="/data-producer/v1/info-types/$2"
1361 query="/ei-producer/v1/eitypes/$2"
1363 res="$(__do_curl_to_api ICS DELETE $query)"
1364 status=${res:${#res}-3}
1366 if [ $status -ne $1 ]; then
1367 __log_test_fail_status_code $1 $status
1375 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
1376 # args: (v1_1) <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | [<type-id> <schema-file>]+) ]
1377 # (Function for test scripts)
1378 ics_api_edp_get_producer() {
1381 #Possible arg count: 2, 5 6, 8, 10 etc
1383 if [ $# -eq 2 ]; then
1386 if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then
1389 variablecount=$(($#-4))
1390 if [ $# -gt 5 ] && [ $(($variablecount%2)) -eq 0 ]; then
1394 if [ $paramError -ne 0 ]; then
1395 __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (NOID | [<type-id> <schema-file>]+) ]" $@
1399 query="/ei-producer/v1/eiproducers/$2"
1400 res="$(__do_curl_to_api ICS GET $query)"
1401 status=${res:${#res}-3}
1403 if [ $status -ne $1 ]; then
1404 __log_test_fail_status_code $1 $status
1408 if [ $# -gt 2 ]; then
1409 body=${res:0:${#res}-3}
1411 if [ $# -gt 5 ]; then
1413 for ((i=0; i<$(($#-5)); i=i+2)); do
1414 if [ "$targetJson" != "[" ]; then
1415 targetJson=$targetJson","
1417 if [ -f ${arr[$i+1]} ]; then
1418 schema=$(cat ${arr[$i+1]})
1420 __log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
1424 targetJson=$targetJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
1427 targetJson=$targetJson"]"
1428 if [ $# -gt 4 ]; then
1429 targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
1431 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1432 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1434 if [ $res -ne 0 ]; then
1435 __log_test_fail_body
1444 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
1445 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}
1446 # args (v1_2): <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]
1447 # (Function for test scripts)
1448 ics_api_edp_get_producer_2() {
1451 #Possible arg count: 2, 5, 6, 7, 8 etc
1453 if [ $# -eq 2 ]; then
1456 if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then
1459 if [ $# -ge 5 ]; then
1463 if [ $paramError -ne 0 ]; then
1464 __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]" $@
1467 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1468 query="/data-producer/v1/info-producers/$2"
1470 query="/ei-producer/v1/eiproducers/$2"
1472 res="$(__do_curl_to_api ICS GET $query)"
1473 status=${res:${#res}-3}
1475 if [ $status -ne $1 ]; then
1476 __log_test_fail_status_code $1 $status
1480 if [ $# -gt 2 ]; then
1481 body=${res:0:${#res}-3}
1483 if [ $# -gt 4 ] && [ "$5" != "EMPTY" ]; then
1485 for ((i=0; i<$(($#-4)); i=i+1)); do
1486 if [ "$targetJson" != "[" ]; then
1487 targetJson=$targetJson","
1489 targetJson=$targetJson"\"${arr[$i]}\""
1492 targetJson=$targetJson"]"
1493 if [ $# -gt 4 ]; then
1494 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1495 targetJson="{\"supported_info_types\":$targetJson,\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\"}"
1497 targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
1500 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1501 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1503 if [ $res -ne 0 ]; then
1504 __log_test_fail_body
1513 # API Test function: DELETE /ei-producer/v1/eiproducers/{eiProducerId}
1514 # API Test function: DELETE /data-producer/v1/info-producers/{infoProducerId}
1515 # args: <response-code> <producer-id>
1516 # (Function for test scripts)
1517 ics_api_edp_delete_producer() {
1520 if [ $# -lt 2 ]; then
1521 __print_err "<response-code> <producer-id>" $@
1524 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1525 query="/data-producer/v1/info-producers/$2"
1527 query="/ei-producer/v1/eiproducers/$2"
1529 res="$(__do_curl_to_api ICS DELETE $query)"
1530 status=${res:${#res}-3}
1532 if [ $status -ne $1 ]; then
1533 __log_test_fail_status_code $1 $status
1541 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
1542 # args: (v1_1) <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+
1543 # (Function for test scripts)
1544 ics_api_edp_put_producer() {
1547 #Valid number of parametrer 5,6,8,10,
1549 if [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then
1551 elif [ $# -gt 5 ] && [ $(($#%2)) -eq 0 ]; then
1554 if [ $paramError -ne 0 ]; then
1555 __print_err "<response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+" $@
1560 if [ $# -gt 5 ]; then
1562 for ((i=0; i<$(($#-5)); i=i+2)); do
1563 if [ "$inputJson" != "[" ]; then
1564 inputJson=$inputJson","
1566 if [ -f ${arr[$i+1]} ]; then
1567 schema=$(cat ${arr[$i+1]})
1569 __log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
1572 inputJson=$inputJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
1575 inputJson="\"supported_ei_types\":"$inputJson"]"
1577 inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
1579 inputJson="{"$inputJson"}"
1581 file="./tmp/.p.json"
1582 echo "$inputJson" > $file
1583 query="/ei-producer/v1/eiproducers/$2"
1584 res="$(__do_curl_to_api ICS PUT $query $file)"
1585 status=${res:${#res}-3}
1587 if [ $status -ne $1 ]; then
1588 __log_test_fail_status_code $1 $status
1596 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
1597 # API Test function: PUT /data-producer/v1/info-producers/{infoProducerId}
1598 # args: (v1_2) <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]
1599 # (Function for test scripts)
1600 ics_api_edp_put_producer_2() {
1603 #Valid number of parametrer 5,6,8,10,
1605 if [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then
1607 elif [ $# -ge 5 ]; then
1610 if [ $paramError -ne 0 ]; then
1611 __print_err "<response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]" $@
1616 if [ $# -gt 4 ] && [ "$5" != "NOTYPE" ]; then
1618 for ((i=0; i<$(($#-4)); i=i+1)); do
1619 if [ "$inputJson" != "[" ]; then
1620 inputJson=$inputJson","
1622 inputJson=$inputJson"\""${arr[$i]}"\""
1625 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1626 inputJson="\"supported_info_types\":"$inputJson"]"
1628 inputJson=$inputJson",\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\""
1630 inputJson="{"$inputJson"}"
1632 file="./tmp/.p.json"
1633 echo "$inputJson" > $file
1634 query="/data-producer/v1/info-producers/$2"
1636 inputJson="\"supported_ei_types\":"$inputJson"]"
1638 inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
1640 inputJson="{"$inputJson"}"
1642 file="./tmp/.p.json"
1643 echo "$inputJson" > $file
1644 query="/ei-producer/v1/eiproducers/$2"
1646 res="$(__do_curl_to_api ICS PUT $query $file)"
1647 status=${res:${#res}-3}
1649 if [ $status -ne $1 ]; then
1650 __log_test_fail_status_code $1 $status
1658 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
1659 # args: (V1-1) <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)
1660 # (Function for test scripts)
1661 ics_api_edp_get_producer_jobs() {
1664 #Valid number of parameter 2,3,7,11
1666 if [ $# -eq 2 ]; then
1669 if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
1672 variablecount=$(($#-2))
1673 if [ $# -gt 3 ] && [ $(($variablecount%5)) -eq 0 ]; then
1676 if [ $paramError -eq 1 ]; then
1677 __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)" $@
1681 query="/ei-producer/v1/eiproducers/$2/eijobs"
1682 res="$(__do_curl_to_api ICS GET $query)"
1683 status=${res:${#res}-3}
1684 if [ $status -ne $1 ]; then
1685 __log_test_fail_status_code $1 $status
1688 if [ $# -gt 2 ]; then
1689 body=${res:0:${#res}-3}
1691 if [ $# -gt 3 ]; then
1693 for ((i=0; i<$(($#-3)); i=i+5)); do
1694 if [ "$targetJson" != "[" ]; then
1695 targetJson=$targetJson","
1697 if [ -f ${arr[$i+4]} ]; then
1698 jobfile=$(cat ${arr[$i+4]})
1699 jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
1701 __log_test_fail_general "Job template file "${arr[$i+4]}", does not exist"
1704 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}"
1707 targetJson=$targetJson"]"
1709 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1710 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1712 if [ $res -ne 0 ]; then
1713 __log_test_fail_body
1722 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
1723 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}/info-jobs
1724 # args: (V1-2) <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)
1725 # (Function for test scripts)
1726 ics_api_edp_get_producer_jobs_2() {
1729 #Valid number of parameter 2,3,7,11
1731 if [ $# -eq 2 ]; then
1734 if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
1737 variablecount=$(($#-2))
1738 if [ $# -gt 3 ] && [ $(($variablecount%5)) -eq 0 ]; then
1741 if [ $paramError -eq 1 ]; then
1742 __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)" $@
1745 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1746 query="/data-producer/v1/info-producers/$2/info-jobs"
1748 query="/ei-producer/v1/eiproducers/$2/eijobs"
1750 res="$(__do_curl_to_api ICS GET $query)"
1751 status=${res:${#res}-3}
1752 if [ $status -ne $1 ]; then
1753 __log_test_fail_status_code $1 $status
1756 if [ $# -gt 2 ]; then
1757 body=${res:0:${#res}-3}
1759 if [ $# -gt 3 ]; then
1761 for ((i=0; i<$(($#-3)); i=i+5)); do
1762 if [ "$targetJson" != "[" ]; then
1763 targetJson=$targetJson","
1765 if [ -f ${arr[$i+4]} ]; then
1766 jobfile=$(cat ${arr[$i+4]})
1767 jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
1769 __log_test_fail_general "Job template file "${arr[$i+4]}", does not exist"
1772 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1773 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\":\"????\"}"
1775 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\":\"????\"}"
1779 targetJson=$targetJson"]"
1781 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1782 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1784 if [ $res -ne 0 ]; then
1785 __log_test_fail_body
1794 ##########################################
1795 #### Service status ####
1796 ##########################################
1797 # Function prefix: ics_api_service
1799 # API Test function: GET ​/status
1800 # args: <response-code>
1801 # (Function for test scripts)
1802 ics_api_service_status() {
1805 if [ $# -lt 1 ]; then
1806 __print_err "<response-code>" $@
1809 res="$(__do_curl_to_api ICS GET /status)"
1810 status=${res:${#res}-3}
1811 if [ $status -ne $1 ]; then
1812 __log_test_fail_status_code $1 $status
1819 ###########################################
1820 ######### Info data consumer API ##########
1821 ###########################################
1822 #Function prefix: ics_api_idc
1825 # API Test function: GET /data-consumer/v1/info-types
1826 # args: <response-code> [ (EMPTY | [<type-id>]+) ]
1827 # (Function for test scripts)
1828 ics_api_idc_get_type_ids() {
1831 if [ $# -lt 1 ]; then
1832 __print_err "<response-code> [ (EMPTY | [<type-id>]+) ]" $@
1836 query="/data-consumer/v1/info-types"
1837 res="$(__do_curl_to_api ICS GET $query)"
1838 status=${res:${#res}-3}
1840 if [ $status -ne $1 ]; then
1841 __log_test_fail_status_code $1 $status
1844 if [ $# -gt 1 ]; then
1845 body=${res:0:${#res}-3}
1847 if [ $2 != "EMPTY" ]; then
1848 for pid in ${@:2} ; do
1849 if [ "$targetJson" != "[" ]; then
1850 targetJson=$targetJson","
1852 targetJson=$targetJson"\"$pid\""
1855 targetJson=$targetJson"]"
1856 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1857 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1859 if [ $res -ne 0 ]; then
1860 __log_test_fail_body
1869 # API Test function: GET /data-consumer/v1/info-jobs
1870 # args: <response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
1871 # (Function for test scripts)
1872 ics_api_idc_get_job_ids() {
1875 # Valid number of parameters 4,5,6 etc
1876 if [ $# -lt 3 ]; then
1877 __print_err "<response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
1881 if [ $3 != "NOWNER" ]; then
1885 if [ $2 != "NOTYPE" ]; then
1886 if [ -z "$search" ]; then
1887 search="?infoTypeId="$2
1889 search=$search"&infoTypeId="$2
1892 query="/data-consumer/v1/info-jobs$search"
1894 res="$(__do_curl_to_api ICS GET $query)"
1895 status=${res:${#res}-3}
1897 if [ $status -ne $1 ]; then
1898 __log_test_fail_status_code $1 $status
1902 if [ $# -gt 3 ]; then
1903 body=${res:0:${#res}-3}
1906 for pid in ${@:4} ; do
1907 if [ "$targetJson" != "[" ]; then
1908 targetJson=$targetJson","
1910 if [ $pid != "EMPTY" ]; then
1911 targetJson=$targetJson"\"$pid\""
1915 targetJson=$targetJson"]"
1916 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1917 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1919 if [ $res -ne 0 ]; then
1920 __log_test_fail_body
1929 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}
1930 # args: <response-code> <job-id> [<type-id> <target-url> <owner-id> <template-job-file>]
1931 # (Function for test scripts)
1932 ics_api_idc_get_job() {
1935 if [ $# -ne 2 ] && [ $# -ne 7 ]; then
1936 __print_err "<response-code> <job-id> [<type-id> <target-url> <owner-id> <notification-url> <template-job-file>]" $@
1939 query="/data-consumer/v1/info-jobs/$2"
1940 res="$(__do_curl_to_api ICS GET $query)"
1941 status=${res:${#res}-3}
1943 if [ $status -ne $1 ]; then
1944 __log_test_fail_status_code $1 $status
1948 if [ $# -eq 7 ]; then
1949 body=${res:0:${#res}-3}
1953 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
1955 __log_test_fail_general "Job template file "$6", does not exist"
1958 targetJson="{\"info_type_id\": \"$3\", \"job_result_uri\": \"$4\",\"job_owner\": \"$5\",\"status_notification_uri\": \"$6\",\"job_definition\": $jobfile}"
1959 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1960 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1962 if [ $res -ne 0 ]; then
1963 __log_test_fail_body
1973 # API Test function: PUT ​/data-consumer/v1/info-jobs/{infoJobId}
1974 # args: <response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file> [ VALIDATE ]
1975 # (Function for test scripts)
1976 ics_api_idc_put_job() {
1979 if [ $# -lt 7 ] || [ $# -gt 8 ]; then
1980 __print_err "<response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file> [ VALIDATE ]" $@
1985 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
1987 __log_test_fail_general "Job template file "$7", does not exist"
1991 inputJson="{\"info_type_id\": \"$3\", \"job_result_uri\": \"$4\",\"job_owner\": \"$5\",\"status_notification_uri\": \"$6\",\"job_definition\": $jobfile}"
1992 file="./tmp/.p.json"
1993 echo "$inputJson" > $file
1995 query="/data-consumer/v1/info-jobs/$2"
1997 if [ $# -eq 8 ]; then
1998 if [ $8 == "VALIDATE" ]; then
1999 query=$query"?typeCheck=true"
2003 res="$(__do_curl_to_api ICS PUT $query $file)"
2004 status=${res:${#res}-3}
2006 if [ $status -ne $1 ]; then
2007 __log_test_fail_status_code $1 $status
2015 # API Test function: DELETE ​/data-consumer/v1/info-jobs/{infoJobId}
2016 # args: <response-code> <job-id>
2017 # (Function for test scripts)
2018 ics_api_idc_delete_job() {
2021 if [ $# -ne 2 ]; then
2022 __print_err "<response-code> <job-id>" $@
2025 query="/data-consumer/v1/info-jobs/$2"
2026 res="$(__do_curl_to_api ICS DELETE $query)"
2027 status=${res:${#res}-3}
2029 if [ $status -ne $1 ]; then
2030 __log_test_fail_status_code $1 $status
2038 # API Test function: GET ​/data-consumer/v1/info-types/{infoTypeId}
2039 # args: <response-code> <type-id> [<schema-file> [<type-status> <producers-count]]
2040 # (Function for test scripts)
2041 ics_api_idc_get_type() {
2044 if [ $# -lt 2 ] || [ $# -gt 5 ]; then
2045 __print_err "<response-code> <type-id> [<schema-file> [<type-status> <producers-count]]" $@
2049 query="/data-consumer/v1/info-types/$2"
2050 res="$(__do_curl_to_api ICS GET $query)"
2051 status=${res:${#res}-3}
2053 if [ $status -ne $1 ]; then
2054 __log_test_fail_status_code $1 $status
2058 if [ $# -gt 2 ]; then
2059 body=${res:0:${#res}-3}
2063 __log_test_fail_general "Schema file "$3", does not exist"
2066 if [ $# -eq 5 ]; then
2067 targetJson="{\"job_data_schema\":$schema, \"type_status\":\"$4\", \"no_of_producers\":$5}"
2069 targetJson="{\"job_data_schema\":$schema}"
2071 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2072 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2074 if [ $res -ne 0 ]; then
2075 __log_test_fail_body
2084 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}/status
2085 # This test only status during an optional timeout. No test of the list of producers
2086 # args: <response-code> <job-id> [<status> [<timeout>]]
2087 # (Function for test scripts)
2088 ics_api_idc_get_job_status() {
2091 if [ $# -lt 2 ] && [ $# -gt 4 ]; then
2092 __print_err "<response-code> <job-id> [<status> [<timeout>]]" $@
2096 query="/data-consumer/v1/info-jobs/$2/status"
2100 res="$(__do_curl_to_api ICS GET $query)"
2101 status=${res:${#res}-3}
2103 if [ $# -eq 4 ]; then
2104 duration=$((SECONDS-start))
2105 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
2106 if [ $duration -gt $4 ]; then
2108 duration=-1 #Last iteration
2111 duration=-1 #single test, no wait
2114 if [ $status -ne $1 ]; then
2115 if [ $duration -eq -1 ]; then
2116 __log_test_fail_status_code $1 $status
2120 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
2121 body=${res:0:${#res}-3}
2122 targetJson="{\"info_job_status\": \"$3\"}"
2123 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2124 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2126 if [ $res -ne 0 ]; then
2127 if [ $duration -eq -1 ]; then
2128 __log_test_fail_body
2132 duration=-1 #Goto pass
2135 if [ $duration -eq -1 ]; then
2136 if [ $# -eq 4 ]; then
2150 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}/status
2151 # This function test status and the list of producers with and optional timeout
2152 # args: <response-code> <job-id> [<status> EMPTYPROD|( <prod-count> <producer-id>+ ) [<timeout>]]
2153 # (Function for test scripts)
2154 ics_api_idc_get_job_status2() {
2158 if [ $# -lt 2 ]; then
2163 if [ $# -gt 2 ]; then
2164 if [ $# -lt 4 ]; then
2167 targetJson="{\"info_job_status\": \"$3\""
2168 if [ "$4" == "EMPTYPROD" ]; then
2169 targetJson=$targetJson",\"producers\": []}"
2170 if [ $# -gt 4 ]; then
2174 targetJson=$targetJson",\"producers\": ["
2175 if [ $# -eq $(($4+5)) ]; then
2177 timeout=${args[$idx]}
2179 for ((ics_i = 0 ; ics_i < $4 ; ics_i++)); do
2181 if [ $ics_i -gt 0 ]; then
2182 targetJson=$targetJson","
2184 targetJson=$targetJson"\""${args[$idx]}"\""
2186 targetJson=$targetJson"]}"
2190 if [ $param_error -ne 0 ]; then
2191 __print_err "<response-code> <job-id> [<status> EMPTYPROD|( <prod-count> <producer-id>+ ) [<timeout>]]" $@
2195 query="/data-consumer/v1/info-jobs/$2/status"
2199 res="$(__do_curl_to_api ICS GET $query)"
2200 status=${res:${#res}-3}
2202 if [ $# -gt 2 ]; then
2203 duration=$((SECONDS-start))
2204 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
2205 if [ $duration -gt $timeout ]; then
2207 duration=-1 #Last iteration
2210 duration=-1 #single test, no wait
2213 if [ $status -ne $1 ]; then
2214 if [ $duration -eq -1 ]; then
2215 __log_test_fail_status_code $1 $status
2219 if [ $# -gt 2 ] && [ $status -eq $1 ]; then
2220 body=${res:0:${#res}-3}
2221 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2222 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2224 if [ $res -ne 0 ]; then
2225 if [ $duration -eq -1 ]; then
2226 __log_test_fail_body
2230 duration=-1 #Goto pass
2233 if [ $duration -eq -1 ]; then
2234 if [ $# -eq 4 ]; then
2248 ##########################################
2249 #### Type subscriptions ####
2250 ##########################################
2252 # API Test function: GET /data-consumer/v1/info-type-subscription
2253 # args: <response-code> <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]
2254 # (Function for test scripts)
2255 ics_api_idc_get_subscription_ids() {
2258 if [ $# -lt 3 ]; then
2259 __print_err "<response-code> <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]" $@
2263 query="/data-consumer/v1/info-type-subscription"
2265 if [ $2 != "NOOWNER" ]; then
2269 res="$(__do_curl_to_api ICS GET $query$search)"
2270 status=${res:${#res}-3}
2272 if [ $status -ne $1 ]; then
2273 __log_test_fail_status_code $1 $status
2277 if [ $# -gt 2 ]; then
2278 body=${res:0:${#res}-3}
2280 if [ $3 != "EMPTY" ]; then
2281 for pid in ${@:3} ; do
2282 if [ "$targetJson" != "[" ]; then
2283 targetJson=$targetJson","
2285 targetJson=$targetJson"\"$pid\""
2288 targetJson=$targetJson"]"
2289 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2290 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2292 if [ $res -ne 0 ]; then
2293 __log_test_fail_body
2302 # API Test function: GET /data-consumer/v1/info-type-subscription/{subscriptionId}
2303 # args: <response-code> <subscription-id> [ <owner-id> <status-uri> ]
2304 # (Function for test scripts)
2305 ics_api_idc_get_subscription() {
2308 if [ $# -ne 2 ] && [ $# -ne 4 ]; then
2309 __print_err "<response-code> <subscription-id> [ <owner-id> <status-uri> ]" $@
2313 query="/data-consumer/v1/info-type-subscription/$2"
2314 res="$(__do_curl_to_api ICS GET $query)"
2315 status=${res:${#res}-3}
2317 if [ $status -ne $1 ]; then
2318 __log_test_fail_status_code $1 $status
2322 if [ $# -gt 2 ]; then
2323 body=${res:0:${#res}-3}
2324 targetJson="{\"owner\":\"$3\",\"status_result_uri\":\"$4\"}"
2325 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2326 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2328 if [ $res -ne 0 ]; then
2329 __log_test_fail_body
2338 # API Test function: PUT /data-consumer/v1/info-type-subscription/{subscriptionId}
2339 # args: <response-code> <subscription-id> <owner-id> <status-uri>
2340 # (Function for test scripts)
2341 ics_api_idc_put_subscription() {
2344 if [ $# -ne 4 ]; then
2345 __print_err "<response-code> <subscription-id> <owner-id> <status-uri>" $@
2349 inputJson="{\"owner\": \"$3\",\"status_result_uri\": \"$4\"}"
2350 file="./tmp/.p.json"
2351 echo "$inputJson" > $file
2353 query="/data-consumer/v1/info-type-subscription/$2"
2354 res="$(__do_curl_to_api ICS PUT $query $file)"
2355 status=${res:${#res}-3}
2357 if [ $status -ne $1 ]; then
2358 __log_test_fail_status_code $1 $status
2366 # API Test function: DELETE /data-consumer/v1/info-type-subscription/{subscriptionId}
2367 # args: <response-code> <subscription-id>
2368 # (Function for test scripts)
2369 ics_api_idc_delete_subscription() {
2372 if [ $# -ne 2 ]; then
2373 __print_err "<response-code> <subscription-id> " $@
2377 query="/data-consumer/v1/info-type-subscription/$2"
2378 res="$(__do_curl_to_api ICS DELETE $query)"
2379 status=${res:${#res}-3}
2381 if [ $status -ne $1 ]; then
2382 __log_test_fail_status_code $1 $status
2390 ##########################################
2391 #### Reset jobs ####
2392 ##########################################
2393 # Function prefix: ics_api_admin
2395 # Admin to remove all jobs
2396 # args: <response-code> [ <type> ]
2397 # (Function for test scripts)
2399 ics_api_admin_reset() {
2402 if [ -z "$FLAT_A1_EI" ]; then
2403 query="/A1-EI/v1/eitypes/$2/eijobs"
2405 query="/A1-EI/v1/eijobs"
2407 res="$(__do_curl_to_api ICS GET $query)"
2408 status=${res:${#res}-3}
2410 if [ $status -ne 200 ]; then
2411 __log_test_fail_status_code $1 $status
2415 #Remove brackets and response code
2416 body=${res:1:${#res}-4}
2417 list=$(echo ${body//,/ })
2418 list=$(echo ${list//[/})
2419 list=$(echo ${list//]/})
2420 list=$(echo ${list//\"/})
2422 for job in $list; do
2423 if [ -z "$FLAT_A1_EI" ]; then
2424 echo "Not supported for non-flat EI api"
2426 query="/A1-EI/v1/eijobs/$job"
2427 res="$(__do_curl_to_api ICS DELETE $query)"
2428 status=${res:${#res}-3}
2429 if [ $status -ne 204 ]; then
2430 __log_test_fail_status_code $1 $status
2433 echo " Deleted job: "$job
2441 ##########################################
2442 #### Reset jobs and producers ####
2443 ##########################################
2446 # Admin reset to remove all data in ics; jobs, producers etc
2447 # NOTE - only works in kubernetes and the pod should not be running
2449 # (Function for test scripts)
2451 ics_kube_pvc_reset() {
2454 pvc_name=$(kubectl $KUBECONF get pvc -n $KUBE_NONRTRIC_NAMESPACE --no-headers -o custom-columns=":metadata.name" | grep information)
2455 if [ -z "$pvc_name" ]; then
2456 pvc_name=informationservice-pvc
2458 echo " Trying to reset pvc: "$pvc_name
2460 __kube_clean_pvc $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE $pvc_name $ICS_CONTAINER_MNT_DIR