a18bf7294540fe76a8105a636b889de24db43581
[nonrtric.git] / test / common / ics_api_functions.sh
1 #!/bin/bash
2
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
9 #
10 #       http://www.apache.org/licenses/LICENSE-2.0
11 #
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=================================================
18 #
19
20 # This is a script that contains container/service management functions and test functions for ICS
21
22 ################ Test engine functions ################
23
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
27 __ICS_imagesetup() {
28         __check_and_create_image_var ICS "ICS_IMAGE" "ICS_IMAGE_BASE" "ICS_IMAGE_TAG" $1 "$ICS_DISPLAY_NAME"
29 }
30
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'
36 __ICS_imagepull() {
37         __check_and_pull_image $1 "$ICS_DISPLAY_NAME" $ICS_APP_NAME ICS_IMAGE
38 }
39
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
43 __ICS_imagebuild() {
44         echo -e $RED" Image for app ICS shall never be built"$ERED
45 }
46
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>
50 __ICS_image_data() {
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
54         fi
55 }
56
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
62 }
63
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
68 }
69
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
74 }
75
76 # Store docker logs
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
82         else
83                 docker logs $ICS_APP_NAME > $1$2_ics.log 2>&1
84         fi
85 }
86
87 # Initial setup of protocol, host and ports
88 # This function is called for apps managed by the test script.
89 # args: -
90 __ICS_initial_setup() {
91         use_ics_rest_http
92 }
93
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.
97 # args: -
98 __ICS_statisics_setup() {
99         if [ $RUNMODE == "KUBE" ]; then
100                 echo "ICS $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE"
101         else
102                 echo "ICS $ICS_APP_NAME"
103         fi
104 }
105
106 # Check application requirements, e.g. helm, the the test needs. Exit 1 if req not satisfied
107 # args: -
108 __ICS_test_requirements() {
109         :
110 }
111
112 #######################################################
113
114
115 # Make curl retries towards ICS for http response codes set in this env var, space separated list of codes
116 ICS_RETRY_CODES=""
117
118 #Save first worker node the pod is started on
119 __ICS_WORKER_NODE=""
120
121 ###########################
122 ### ICS functions
123 ###########################
124
125 # All calls to ICS will be directed to the ICS REST interface from now on
126 # args: -
127 # (Function for test scripts)
128 use_ics_rest_http() {
129         __ics_set_protocoll "http" $ICS_INTERNAL_PORT $ICS_EXTERNAL_PORT
130 }
131
132 # All calls to ICS will be directed to the ICS REST interface from now on
133 # args: -
134 # (Function for test scripts)
135 use_ics_rest_https() {
136         __ics_set_protocoll "https" $ICS_INTERNAL_SECURE_PORT $ICS_EXTERNAL_SECURE_PORT
137 }
138
139 # All calls to ICS will be directed to the ICS dmaap interface over http from now on
140 # args: -
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"
147         echo ""
148 }
149
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"
155
156         ## Access to ICS
157
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
161         fi
162
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
166
167         echo ""
168 }
169
170 # Export env vars for config files, docker compose and kube resources
171 # args: PROXY|NOPROXY
172 __ics_export_vars() {
173                 export ICS_APP_NAME
174                 export ICS_APP_NAME_ALIAS
175                 export KUBE_NONRTRIC_NAMESPACE
176                 export ICS_IMAGE
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
189                 export ICS_LOGPATH
190
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
196
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
202                         else
203                                 echo " Configured with http proxy"
204                         fi
205                 else
206                         export ICS_HTTP_PROXY_CONFIG_PORT=0
207                         export ICS_HTTP_PROXY_CONFIG_HOST_NAME=""
208                         echo " Configured without http proxy"
209                 fi
210 }
211
212
213 # Start the ICS
214 # args: PROXY|NOPROXY <config-file>
215 # (Function for test scripts)
216 start_ics() {
217
218         echo -e $BOLD"Starting $ICS_DISPLAY_NAME"$EBOLD
219
220         if [ $RUNMODE == "KUBE" ]; then
221
222                 # Check if app shall be fully managed by the test script
223                 __check_included_image "ICS"
224                 retcode_i=$?
225
226                 # Check if app shall only be used by the testscipt
227                 __check_prestarted_image "ICS"
228                 retcode_p=$?
229
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
233                         exit
234                 fi
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
238                         exit
239                 fi
240
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
246                 fi
247
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"
251
252                         #Check if nonrtric namespace exists, if not create it
253                         __kube_create_namespace $KUBE_NONRTRIC_NAMESPACE
254
255                         __ics_export_vars $1
256
257                         # Create config map for config
258                         datafile=$PWD/tmp/$ICS_CONFIG_FILE
259                         cp $2 $datafile
260                         output_yaml=$PWD/tmp/ics_cfc.yaml
261                         __kube_create_configmap $ICS_CONFIG_CONFIGMAP_NAME $KUBE_NONRTRIC_NAMESPACE autotest ICS $datafile $output_yaml
262
263                         # Create pv
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
267
268                         # Create pvc
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
272
273                         # Create service
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
277
278                         # Create app
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
282                 fi
283
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
286
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
292                         fi
293                 else
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
295                 fi
296
297
298                 __check_service_start $ICS_APP_NAME $ICS_SERVICE_PATH$ICS_ALIVE_URL
299
300         else
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
305                         exit 1
306                 fi
307
308                 curdir=$PWD
309                 cd $SIM_GROUP
310                 cd ics
311                 cd $ICS_HOST_MNT_DIR
312                 #cd ..
313                 if [ -d db ]; then
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
319                                         exit 1
320                                 fi
321                         fi
322                 else
323                         echo " No files in mounted dir or dir does not exists"
324                 fi
325
326                 cd $curdir
327
328                 __ics_export_vars $1
329
330                 dest_file=$SIM_GROUP/$ICS_COMPOSE_DIR/$ICS_HOST_MNT_DIR/$ICS_CONFIG_FILE
331
332                 envsubst < $2 > $dest_file
333
334                 __start_container $ICS_COMPOSE_DIR "" NODOCKERARGS 1 $ICS_APP_NAME
335
336                 __check_service_start $ICS_APP_NAME $ICS_SERVICE_PATH$ICS_ALIVE_URL
337         fi
338         echo ""
339         return 0
340 }
341
342 # Stop the ics
343 # args: -
344 # args: -
345 # (Function for test scripts)
346 stop_ics() {
347         echo -e $BOLD"Stopping $ICS_DISPLAY_NAME"$EBOLD
348
349         if [ $RUNMODE == "KUBE" ]; then
350
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
356                         return 0
357                 fi
358
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
364                         ((RES_CONF_FAIL++))
365                         return 1
366                 fi
367         else
368                 docker stop $ICS_APP_NAME &> ./tmp/.dockererr
369                 if [ $? -ne 0 ]; then
370                         __print_err "Could not stop $ICS_APP_NAME" $@
371                         cat ./tmp/.dockererr
372                         ((RES_CONF_FAIL++))
373                         return 1
374                 fi
375         fi
376         echo -e $BOLD$GREEN"Stopped"$EGREEN$EBOLD
377         echo ""
378         return 0
379 }
380
381 # Start a previously stopped ics
382 # args: -
383 # (Function for test scripts)
384 start_stopped_ics() {
385         echo -e $BOLD"Starting (the previously stopped) $ICS_DISPLAY_NAME"$EBOLD
386
387         if [ $RUNMODE == "KUBE" ]; then
388
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
395                         return 0
396                 fi
397
398                 # Tie the ICS to the same worker node it was initially started on
399                 # 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
400                 if [ -z "$__ICS_WORKER_NODE" ]; then
401                         echo -e $RED" No initial worker node found for pod "$RED
402                         ((RES_CONF_FAIL++))
403                         return 1
404                 else
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: $__PA_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
410                         fi
411                         __kube_scale deployment $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
412                 fi
413         else
414                 docker start $ICS_APP_NAME &> ./tmp/.dockererr
415                 if [ $? -ne 0 ]; then
416                         __print_err "Could not start (the stopped) $ICS_APP_NAME" $@
417                         cat ./tmp/.dockererr
418                         ((RES_CONF_FAIL++))
419                         return 1
420                 fi
421         fi
422         __check_service_start $ICS_APP_NAME $ICS_SERVICE_PATH$ICS_ALIVE_URL
423         if [ $? -ne 0 ]; then
424                 return 1
425         fi
426         echo ""
427         return 0
428 }
429
430 # Turn on debug level tracing in ICS
431 # args: -
432 # (Function for test scripts)
433 set_ics_debug() {
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" $@
439                 ((RES_CONF_FAIL++))
440                 return 1
441         fi
442         echo ""
443         return 0
444 }
445
446 # Turn on trace level tracing in ICS
447 # args: -
448 # (Function for test scripts)
449 set_ics_trace() {
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" $@
455                 ((RES_CONF_FAIL++))
456                 return 1
457         fi
458         echo ""
459         return 0
460 }
461
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>]*
465 use_ics_retries() {
466         echo -e $BOLD"Do curl retries to the ICS REST inteface for these response codes:$@"$EBOLD
467         ICS_RETRY_CODES=$@
468         echo ""
469         return 0
470 }
471
472 # Check the ics logs for WARNINGs and ERRORs
473 # args: -
474 # (Function for test scripts)
475 check_ics_logs() {
476         __check_container_logs "ICS" $ICS_APP_NAME $ICS_LOGPATH WARN ERR
477 }
478
479
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
485 # value or not.
486 # (Function for test scripts)
487 ics_equal() {
488         if [ $# -eq 2 ] || [ $# -eq 3 ]; then
489                 __var_test ICS "$ICS_SERVICE_PATH/" $1 "=" $2 $3
490         else
491                 __print_err "Wrong args to ics_equal, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
492         fi
493 }
494
495
496 ##########################################
497 ######### A1-E information  API ##########
498 ##########################################
499 #Function prefix: ics_api_a1
500
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() {
506         __log_test_start $@
507
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>+ ]" $@
512                         return 1
513                 fi
514         else
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>+ ]" $@
519                         return 1
520                 fi
521         fi
522         search=""
523         if [ $3 != "NOWNER" ]; then
524                 search="?owner="$3
525         fi
526
527         if [  -z "$FLAT_A1_EI" ]; then
528                 query="/A1-EI/v1/eitypes/$2/eijobs$search"
529         else
530                 if [ $2 != "NOTYPE" ]; then
531                         if [ -z "$search" ]; then
532                                 search="?eiTypeId="$2
533                         else
534                                 search=$search"&eiTypeId="$2
535                         fi
536                 fi
537                 query="/A1-EI/v1/eijobs$search"
538         fi
539     res="$(__do_curl_to_api ICS GET $query)"
540     status=${res:${#res}-3}
541
542         if [ $status -ne $1 ]; then
543                 __log_test_fail_status_code $1 $status
544                 return 1
545         fi
546
547         if [ $# -gt 3 ]; then
548                 body=${res:0:${#res}-3}
549                 targetJson="["
550
551                 for pid in ${@:4} ; do
552                         if [ "$targetJson" != "[" ]; then
553                                 targetJson=$targetJson","
554                         fi
555                         if [ $pid != "EMPTY" ]; then
556                                 targetJson=$targetJson"\"$pid\""
557                         fi
558                 done
559
560                 targetJson=$targetJson"]"
561                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
562                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
563
564                 if [ $res -ne 0 ]; then
565                         __log_test_fail_body
566                         return 1
567                 fi
568         fi
569
570         __log_test_pass
571         return 0
572 }
573
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() {
578         __log_test_start $@
579
580     if [ $# -lt 2 ] || [ $# -gt 3 ]; then
581                 __print_err "<response-code> <type-id> [<schema-file>]" $@
582                 return 1
583         fi
584
585         query="/A1-EI/v1/eitypes/$2"
586     res="$(__do_curl_to_api ICS GET $query)"
587     status=${res:${#res}-3}
588
589         if [ $status -ne $1 ]; then
590                 __log_test_fail_status_code $1 $status
591                 return 1
592         fi
593
594         if [ $# -eq 3 ]; then
595                 body=${res:0:${#res}-3}
596                 if [ -f $3 ]; then
597                         schema=$(cat $3)
598                 else
599                         __log_test_fail_general "Schema file "$3", does not exist"
600                         return 1
601                 fi
602                 if [ -z "$FLAT_A1_EI" ]; then
603                         targetJson="{\"eiJobParametersSchema\":$schema}"
604                 else
605                         targetJson=$schema
606                 fi
607                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
608                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
609
610                 if [ $res -ne 0 ]; then
611                         __log_test_fail_body
612                         return 1
613                 fi
614         fi
615
616         __log_test_pass
617         return 0
618 }
619
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() {
624         __log_test_start $@
625
626     if [ $# -lt 1 ]; then
627                 __print_err "<response-code> [ (EMPTY | [<type-id>]+) ]" $@
628                 return 1
629         fi
630
631         query="/A1-EI/v1/eitypes"
632     res="$(__do_curl_to_api ICS GET $query)"
633     status=${res:${#res}-3}
634
635         if [ $status -ne $1 ]; then
636                 __log_test_fail_status_code $1 $status
637                 return 1
638         fi
639         if [ $# -gt 1 ]; then
640                 body=${res:0:${#res}-3}
641                 targetJson="["
642                 if [ $2 != "EMPTY" ]; then
643                         for pid in ${@:2} ; do
644                                 if [ "$targetJson" != "[" ]; then
645                                         targetJson=$targetJson","
646                                 fi
647                                 targetJson=$targetJson"\"$pid\""
648                         done
649                 fi
650                 targetJson=$targetJson"]"
651                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
652                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
653
654                 if [ $res -ne 0 ]; then
655                         __log_test_fail_body
656                         return 1
657                 fi
658         fi
659
660         __log_test_pass
661         return 0
662 }
663
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() {
669         __log_test_start $@
670
671         if [ -z "$FLAT_A1_EI" ]; then
672                 if [ $# -ne 3 ] && [ $# -ne 4 ]; then
673                         __print_err "<response-code> <type-id> <job-id> [<status>]" $@
674                         return 1
675                 fi
676
677                 query="/A1-EI/v1/eitypes/$2/eijobs/$3/status"
678
679                 res="$(__do_curl_to_api ICS GET $query)"
680                 status=${res:${#res}-3}
681
682                 if [ $status -ne $1 ]; then
683                         __log_test_fail_status_code $1 $status
684                         return 1
685                 fi
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")
691
692                         if [ $res -ne 0 ]; then
693                                 __log_test_fail_body
694                                 return 1
695                         fi
696                 fi
697         else
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>]]" $@
701                         return 1
702                 fi
703
704                 query="/A1-EI/v1/eijobs/$2/status"
705
706                 start=$SECONDS
707                 for (( ; ; )); do
708                         res="$(__do_curl_to_api ICS GET $query)"
709                         status=${res:${#res}-3}
710
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
715                                         echo ""
716                                         duration=-1  #Last iteration
717                                 fi
718                         else
719                                 duration=-1 #single test, no wait
720                         fi
721
722                         if [ $status -ne $1 ]; then
723                                 if [ $duration -eq -1 ]; then
724                                         __log_test_fail_status_code $1 $status
725                                         return 1
726                                 fi
727                         fi
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")
733
734                                 if [ $res -ne 0 ]; then
735                                         if [ $duration -eq -1 ]; then
736                                                 __log_test_fail_body
737                                                 return 1
738                                         fi
739                                 else
740                                         duration=-1  #Goto pass
741                                 fi
742                         fi
743                         if [ $duration -eq -1 ]; then
744                                 if [ $# -eq 4 ]; then
745                                         echo ""
746                                 fi
747                                 __log_test_pass
748                                 return 0
749                         else
750                                 sleep 1
751                         fi
752                 done
753         fi
754
755         __log_test_pass
756         return 0
757 }
758
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() {
764         __log_test_start $@
765
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>]" $@
769                         return 1
770                 fi
771                 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
772         else
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>]" $@
776                         return 1
777                 fi
778                 query="/A1-EI/v1/eijobs/$2"
779         fi
780     res="$(__do_curl_to_api ICS GET $query)"
781     status=${res:${#res}-3}
782
783         if [ $status -ne $1 ]; then
784                 __log_test_fail_status_code $1 $status
785                 return 1
786         fi
787
788         if [  -z "$FLAT_A1_EI" ]; then
789                 if [ $# -eq 6 ]; then
790                         body=${res:0:${#res}-3}
791
792                         if [ -f $6 ]; then
793                                 jobfile=$(cat $6)
794                                 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
795                         else
796                                 __log_test_fail_general "Job template file "$6", does not exist"
797                                 return 1
798                         fi
799                         targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
800                         echo " TARGET JSON: $targetJson" >> $HTTPLOG
801                         res=$(python3 ../common/compare_json.py "$targetJson" "$body")
802
803                         if [ $res -ne 0 ]; then
804                                 __log_test_fail_body
805                                 return 1
806                         fi
807                 fi
808         else
809                 if [ $# -eq 7 ]; then
810                         body=${res:0:${#res}-3}
811
812                         if [ -f $7 ]; then
813                                 jobfile=$(cat $7)
814                                 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
815                         else
816                                 __log_test_fail_general "Job template file "$6", does not exist"
817                                 return 1
818                         fi
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")
822
823                         if [ $res -ne 0 ]; then
824                                 __log_test_fail_body
825                                 return 1
826                         fi
827                 fi
828         fi
829
830         __log_test_pass
831         return 0
832 }
833
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() {
839         __log_test_start $@
840
841         if [  -z "$FLAT_A1_EI" ]; then
842                 if [ $# -ne 3 ]; then
843                         __print_err "<response-code> <type-id> <job-id>" $@
844                         return 1
845                 fi
846
847                 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
848         else
849                 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
850                 if [ $# -ne 2 ]; then
851                         __print_err "<response-code> <job-id>" $@
852                         return 1
853                 fi
854                 query="/A1-EI/v1/eijobs/$2"
855         fi
856     res="$(__do_curl_to_api ICS DELETE $query)"
857     status=${res:${#res}-3}
858
859         if [ $status -ne $1 ]; then
860                 __log_test_fail_status_code $1 $status
861                 return 1
862         fi
863
864         __log_test_pass
865         return 0
866 }
867
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() {
873         __log_test_start $@
874
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>" $@
878                         return 1
879                 fi
880                 if [ -f $6 ]; then
881                         jobfile=$(cat $6)
882                         jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
883                 else
884                         __log_test_fail_general "Job template file "$6", does not exist"
885                         return 1
886                 fi
887
888                 inputJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
889                 file="./tmp/.p.json"
890                 echo "$inputJson" > $file
891
892                 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
893         else
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>" $@
897                         return 1
898                 fi
899                 if [ -f $7 ]; then
900                         jobfile=$(cat $7)
901                         jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
902                 else
903                         __log_test_fail_general "Job template file "$7", does not exist"
904                         return 1
905                 fi
906
907                 inputJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
908                 file="./tmp/.p.json"
909                 echo "$inputJson" > $file
910
911                 query="/A1-EI/v1/eijobs/$2"
912         fi
913
914     res="$(__do_curl_to_api ICS PUT $query $file)"
915     status=${res:${#res}-3}
916
917         if [ $status -ne $1 ]; then
918                 __log_test_fail_status_code $1 $status
919                 return 1
920         fi
921
922         __log_test_pass
923         return 0
924 }
925
926
927 ##########################################
928 ####   information Data Producer API   ####
929 ##########################################
930 # Function prefix: ics_api_edp
931
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() {
937         __log_test_start $@
938
939     if [ $# -lt 1 ]; then
940                 __print_err "<response-code> [ EMPTY | <type-id>+]" $@
941                 return 1
942         fi
943         if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
944                 query="/data-producer/v1/info-types"
945         else
946                 query="/ei-producer/v1/eitypes"
947         fi
948     res="$(__do_curl_to_api ICS GET $query)"
949     status=${res:${#res}-3}
950
951         if [ $status -ne $1 ]; then
952                 __log_test_fail_status_code $1 $status
953                 return 1
954         fi
955
956         if [ $# -gt 1 ]; then
957                 body=${res:0:${#res}-3}
958                 targetJson="["
959                 if [ $2 != "EMPTY" ]; then
960                         for pid in ${@:2} ; do
961                                 if [ "$targetJson" != "[" ]; then
962                                         targetJson=$targetJson","
963                                 fi
964                                 targetJson=$targetJson"\"$pid\""
965                         done
966                 fi
967                 targetJson=$targetJson"]"
968                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
969                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
970
971                 if [ $res -ne 0 ]; then
972                         __log_test_fail_body
973                         return 1
974                 fi
975         fi
976
977         __log_test_pass
978         return 0
979 }
980
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() {
986         __log_test_start $@
987
988     if [ $# -lt 2 ] || [ $# -gt 4 ]; then
989                 __print_err "<response-code> <producer-id> [<status> [<timeout>]]" $@
990                 return 1
991         fi
992         if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
993                 query="/data-producer/v1/info-producers/$2/status"
994         else
995                 query="/ei-producer/v1/eiproducers/$2/status"
996         fi
997         start=$SECONDS
998         for (( ; ; )); do
999                 res="$(__do_curl_to_api ICS GET $query)"
1000                 status=${res:${#res}-3}
1001
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
1006                                 echo ""
1007                                 duration=-1  #Last iteration
1008                         fi
1009                 else
1010                         duration=-1 #single test, no wait
1011                 fi
1012
1013                 if [ $status -ne $1 ]; then
1014                         if [ $duration -eq -1 ]; then
1015                                 __log_test_fail_status_code $1 $status
1016                                 return 1
1017                         fi
1018                 fi
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")
1024
1025                         if [ $res -ne 0 ]; then
1026                                 if [ $duration -eq -1 ]; then
1027                                         __log_test_fail_body
1028                                         return 1
1029                                 fi
1030                         else
1031                                 duration=-1  #Goto pass
1032                         fi
1033                 fi
1034                 if [ $duration -eq -1 ]; then
1035                         if [ $# -eq 4 ]; then
1036                                 echo ""
1037                         fi
1038                         __log_test_pass
1039                         return 0
1040                 else
1041                         sleep 1
1042                 fi
1043         done
1044 }
1045
1046
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() {
1051         __log_test_start $@
1052
1053     if [ $# -lt 1 ]; then
1054                 __print_err "<response-code> [ EMPTY | <producer-id>+]" $@
1055                 return 1
1056         fi
1057
1058         query="/ei-producer/v1/eiproducers"
1059     res="$(__do_curl_to_api ICS GET $query)"
1060     status=${res:${#res}-3}
1061
1062         if [ $status -ne $1 ]; then
1063                 __log_test_fail_status_code $1 $status
1064                 return 1
1065         fi
1066
1067         if [ $# -gt 1 ]; then
1068                 body=${res:0:${#res}-3}
1069                 targetJson="["
1070
1071                 for pid in ${@:2} ; do
1072                         if [ "$targetJson" != "[" ]; then
1073                                 targetJson=$targetJson","
1074                         fi
1075                         if [ $pid != "EMPTY" ]; then
1076                                 targetJson=$targetJson"\"$pid\""
1077                         fi
1078                 done
1079
1080                 targetJson=$targetJson"]"
1081                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1082                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1083
1084                 if [ $res -ne 0 ]; then
1085                         __log_test_fail_body
1086                         return 1
1087                 fi
1088         fi
1089
1090         __log_test_pass
1091         return 0
1092 }
1093
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() {
1099         __log_test_start $@
1100
1101     if [ $# -lt 1 ]; then
1102                 __print_err "<response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]" $@
1103                 return 1
1104         fi
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
1110                 fi
1111         else
1112                 query="/ei-producer/v1/eiproducers"
1113                 if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then
1114                         query=$query"?ei_type_id=$2"
1115                 fi
1116         fi
1117     res="$(__do_curl_to_api ICS GET $query)"
1118     status=${res:${#res}-3}
1119
1120         if [ $status -ne $1 ]; then
1121                 __log_test_fail_status_code $1 $status
1122                 return 1
1123         fi
1124
1125         if [ $# -gt 2 ]; then
1126                 body=${res:0:${#res}-3}
1127                 targetJson="["
1128
1129                 for pid in ${@:3} ; do
1130                         if [ "$targetJson" != "[" ]; then
1131                                 targetJson=$targetJson","
1132                         fi
1133                         if [ $pid != "EMPTY" ]; then
1134                                 targetJson=$targetJson"\"$pid\""
1135                         fi
1136                 done
1137
1138                 targetJson=$targetJson"]"
1139                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1140                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1141
1142                 if [ $res -ne 0 ]; then
1143                         __log_test_fail_body
1144                         return 1
1145                 fi
1146         fi
1147
1148         __log_test_pass
1149         return 0
1150 }
1151
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() {
1156         __log_test_start $@
1157
1158         paramError=1
1159         if [ $# -eq 2 ]; then
1160                 paramError=0
1161         fi
1162         if [ $# -gt 3 ]; then
1163                 paramError=0
1164         fi
1165     if [ $paramError -ne 0 ]; then
1166                 __print_err "<response-code> <type-id> [<job-schema-file> 'EMPTY' | ([<producer-id>]+)]" $@
1167                 return 1
1168         fi
1169
1170         query="/ei-producer/v1/eitypes/$2"
1171     res="$(__do_curl_to_api ICS GET $query)"
1172     status=${res:${#res}-3}
1173
1174         if [ $status -ne $1 ]; then
1175                 __log_test_fail_status_code $1 $status
1176                 return 1
1177         fi
1178         if [ $# -gt 3 ]; then
1179                 body=${res:0:${#res}-3}
1180
1181                 if [ -f $3 ]; then
1182                         schema=$(cat $3)
1183                 else
1184                         __log_test_fail_general "Job template file "$3", does not exist"
1185                         return 1
1186                 fi
1187
1188                 targetJson=""
1189                 if [ $4 != "EMPTY" ]; then
1190                         for pid in ${@:4} ; do
1191                                 if [ "$targetJson" != "" ]; then
1192                                         targetJson=$targetJson","
1193                                 fi
1194                                 targetJson=$targetJson"\"$pid\""
1195                         done
1196                 fi
1197                 targetJson="{\"ei_job_data_schema\":$schema, \"ei_producer_ids\": [$targetJson]}"
1198
1199                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1200                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1201
1202                 if [ $res -ne 0 ]; then
1203                         __log_test_fail_body
1204                         return 1
1205                 fi
1206         fi
1207         __log_test_pass
1208         return 0
1209 }
1210
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() {
1216         __log_test_start $@
1217
1218         paramError=1
1219         if [ $# -eq 2 ]; then
1220                 paramError=0
1221         fi
1222         if [ $# -eq 3 ]; then
1223                 paramError=0
1224         fi
1225         if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then
1226                 if [ $# -eq 4 ]; then
1227                         paramError=0
1228                 fi
1229         fi
1230     if [ $paramError -ne 0 ]; then
1231                 __print_err "<response-code> <type-id> [<job-schema-file> [ <info-type-info> ]]" $@
1232                 return 1
1233         fi
1234         if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1235                 query="/data-producer/v1/info-types/$2"
1236         else
1237                 query="/ei-producer/v1/eitypes/$2"
1238         fi
1239
1240     res="$(__do_curl_to_api ICS GET $query)"
1241     status=${res:${#res}-3}
1242
1243         if [ $status -ne $1 ]; then
1244                 __log_test_fail_status_code $1 $status
1245                 return 1
1246         fi
1247         if [ $# -ge 3 ]; then
1248                 body=${res:0:${#res}-3}
1249
1250                 if [ -f $3 ]; then
1251                         schema=$(cat $3)
1252                 else
1253                         __log_test_fail_general "Job template file "$3", does not exist"
1254                         return 1
1255                 fi
1256                 info_data=""
1257                 if [ $# -gt 3 ]; then
1258                         if [ -f $4 ]; then
1259                                 info_data=$(cat $4)
1260                         else
1261                                 __log_test_fail_general "Info-data file "$4", does not exist"
1262                                 return 1
1263                         fi
1264                         info_data=",\"info_type_information\":$info_data"
1265                 fi
1266                 if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1267                         targetJson="{\"info_job_data_schema\":$schema $info_data}"
1268                 else
1269                         targetJson="{\"ei_job_data_schema\":$schema}"
1270                 fi
1271
1272                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1273                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1274
1275                 if [ $res -ne 0 ]; then
1276                         __log_test_fail_body
1277                         return 1
1278                 fi
1279         fi
1280         __log_test_pass
1281         return 0
1282 }
1283
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() {
1289         __log_test_start $@
1290
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> ]" $@
1294                         return 1
1295                 fi
1296         else
1297                 if [ $# -ne 3 ]; then
1298                         __print_err "<response-code> <type-id> <job-schema-file>" $@
1299                         return 1
1300                 fi
1301         fi
1302
1303         if [ ! -f $3 ]; then
1304                 __log_test_fail_general "Job schema file "$3", does not exist"
1305                 return 1
1306         fi
1307
1308         info_data=""
1309         if [ $# -gt 3 ]; then
1310                 if [ -f $4 ]; then
1311                         info_data=$(cat $4)
1312                 else
1313                         __log_test_fail_general "Info-data file "$4", does not exist"
1314                         return 1
1315                 fi
1316                 info_data=",\"info_type_information\":$info_data"
1317         fi
1318
1319         if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1320                 schema=$(cat $3)
1321                 input_json="{\"info_job_data_schema\":$schema $info_data}"
1322                 file="./tmp/put_type.json"
1323                 echo $input_json > $file
1324
1325                 query="/data-producer/v1/info-types/$2"
1326         else
1327                 schema=$(cat $3)
1328                 input_json="{\"ei_job_data_schema\":$schema}"
1329                 file="./tmp/put_type.json"
1330                 echo $input_json > $file
1331
1332                 query="/ei-producer/v1/eitypes/$2"
1333         fi
1334     res="$(__do_curl_to_api ICS PUT $query $file)"
1335     status=${res:${#res}-3}
1336
1337         if [ $status -ne $1 ]; then
1338                 __log_test_fail_status_code $1 $status
1339                 return 1
1340         fi
1341
1342         __log_test_pass
1343         return 0
1344 }
1345
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() {
1351         __log_test_start $@
1352
1353     if [ $# -ne 2 ]; then
1354                 __print_err "<response-code> <type-id>" $@
1355                 return 1
1356         fi
1357
1358         if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1359                 query="/data-producer/v1/info-types/$2"
1360         else
1361                 query="/ei-producer/v1/eitypes/$2"
1362         fi
1363     res="$(__do_curl_to_api ICS DELETE $query)"
1364     status=${res:${#res}-3}
1365
1366         if [ $status -ne $1 ]; then
1367                 __log_test_fail_status_code $1 $status
1368                 return 1
1369         fi
1370
1371         __log_test_pass
1372         return 0
1373 }
1374
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() {
1379         __log_test_start $@
1380
1381         #Possible arg count: 2, 5 6, 8, 10 etc
1382         paramError=1
1383         if [ $# -eq 2 ]; then
1384                 paramError=0
1385         fi
1386         if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then
1387                 paramError=0
1388         fi
1389         variablecount=$(($#-4))
1390         if [ $# -gt 5 ] && [ $(($variablecount%2)) -eq 0 ]; then
1391                 paramError=0
1392         fi
1393
1394     if [ $paramError -ne 0 ]; then
1395                 __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (NOID | [<type-id> <schema-file>]+) ]" $@
1396                 return 1
1397         fi
1398
1399         query="/ei-producer/v1/eiproducers/$2"
1400     res="$(__do_curl_to_api ICS GET $query)"
1401     status=${res:${#res}-3}
1402
1403         if [ $status -ne $1 ]; then
1404                 __log_test_fail_status_code $1 $status
1405                 return 1
1406         fi
1407
1408         if [ $# -gt 2 ]; then
1409                 body=${res:0:${#res}-3}
1410                 targetJson="["
1411                 if [ $# -gt 5 ]; then
1412                         arr=(${@:5})
1413                         for ((i=0; i<$(($#-5)); i=i+2)); do
1414                                 if [ "$targetJson" != "[" ]; then
1415                                         targetJson=$targetJson","
1416                                 fi
1417                                 if [ -f ${arr[$i+1]} ]; then
1418                                         schema=$(cat ${arr[$i+1]})
1419                                 else
1420                                         __log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
1421                                         return 1
1422                                 fi
1423
1424                                 targetJson=$targetJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
1425                         done
1426                 fi
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\"}"
1430                 fi
1431                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1432                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1433
1434                 if [ $res -ne 0 ]; then
1435                         __log_test_fail_body
1436                         return 1
1437                 fi
1438         fi
1439
1440         __log_test_pass
1441         return 0
1442 }
1443
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() {
1449         __log_test_start $@
1450
1451         #Possible arg count: 2, 5, 6, 7, 8 etc
1452         paramError=1
1453         if [ $# -eq 2 ]; then
1454                 paramError=0
1455         fi
1456         if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then
1457                 paramError=0
1458         fi
1459         if [ $# -ge 5 ]; then
1460                 paramError=0
1461         fi
1462
1463     if [ $paramError -ne 0 ]; then
1464                 __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]" $@
1465                 return 1
1466         fi
1467         if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1468                 query="/data-producer/v1/info-producers/$2"
1469         else
1470                 query="/ei-producer/v1/eiproducers/$2"
1471         fi
1472     res="$(__do_curl_to_api ICS GET $query)"
1473     status=${res:${#res}-3}
1474
1475         if [ $status -ne $1 ]; then
1476                 __log_test_fail_status_code $1 $status
1477                 return 1
1478         fi
1479
1480         if [ $# -gt 2 ]; then
1481                 body=${res:0:${#res}-3}
1482                 targetJson="["
1483                 if [ $# -gt 4 ] && [ "$5" != "EMPTY" ]; then
1484                         arr=(${@:5})
1485                         for ((i=0; i<$(($#-4)); i=i+1)); do
1486                                 if [ "$targetJson" != "[" ]; then
1487                                         targetJson=$targetJson","
1488                                 fi
1489                                 targetJson=$targetJson"\"${arr[$i]}\""
1490                         done
1491                 fi
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\"}"
1496                         else
1497                                 targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
1498                         fi
1499                 fi
1500                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1501                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1502
1503                 if [ $res -ne 0 ]; then
1504                         __log_test_fail_body
1505                         return 1
1506                 fi
1507         fi
1508
1509         __log_test_pass
1510         return 0
1511 }
1512
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() {
1518         __log_test_start $@
1519
1520     if [ $# -lt 2 ]; then
1521                 __print_err "<response-code> <producer-id>" $@
1522                 return 1
1523         fi
1524         if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1525                 query="/data-producer/v1/info-producers/$2"
1526         else
1527                 query="/ei-producer/v1/eiproducers/$2"
1528         fi
1529     res="$(__do_curl_to_api ICS DELETE $query)"
1530     status=${res:${#res}-3}
1531
1532         if [ $status -ne $1 ]; then
1533                 __log_test_fail_status_code $1 $status
1534                 return 1
1535         fi
1536
1537         __log_test_pass
1538         return 0
1539 }
1540
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() {
1545         __log_test_start $@
1546
1547         #Valid number of parametrer 5,6,8,10,
1548         paramError=1
1549         if  [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then
1550                 paramError=0
1551         elif [ $# -gt 5 ] && [ $(($#%2)) -eq 0 ]; then
1552                 paramError=0
1553         fi
1554         if [ $paramError -ne 0 ]; then
1555                 __print_err "<response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+" $@
1556                 return 1
1557         fi
1558
1559         inputJson="["
1560         if [ $# -gt 5 ]; then
1561                 arr=(${@:5})
1562                 for ((i=0; i<$(($#-5)); i=i+2)); do
1563                         if [ "$inputJson" != "[" ]; then
1564                                 inputJson=$inputJson","
1565                         fi
1566                         if [ -f ${arr[$i+1]} ]; then
1567                                 schema=$(cat ${arr[$i+1]})
1568                         else
1569                                 __log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
1570                                 return 1
1571                         fi
1572                         inputJson=$inputJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
1573                 done
1574         fi
1575         inputJson="\"supported_ei_types\":"$inputJson"]"
1576
1577         inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
1578
1579         inputJson="{"$inputJson"}"
1580
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}
1586
1587         if [ $status -ne $1 ]; then
1588                 __log_test_fail_status_code $1 $status
1589                 return 1
1590         fi
1591
1592         __log_test_pass
1593         return 0
1594 }
1595
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() {
1601         __log_test_start $@
1602
1603         #Valid number of parametrer 5,6,8,10,
1604         paramError=1
1605         if  [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then
1606                 paramError=0
1607         elif [ $# -ge 5 ]; then
1608                 paramError=0
1609         fi
1610         if [ $paramError -ne 0 ]; then
1611                 __print_err "<response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]" $@
1612                 return 1
1613         fi
1614
1615         inputJson="["
1616         if [ $# -gt 4 ] && [ "$5" != "NOTYPE" ]; then
1617                 arr=(${@:5})
1618                 for ((i=0; i<$(($#-4)); i=i+1)); do
1619                         if [ "$inputJson" != "[" ]; then
1620                                 inputJson=$inputJson","
1621                         fi
1622                         inputJson=$inputJson"\""${arr[$i]}"\""
1623                 done
1624         fi
1625         if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1626                 inputJson="\"supported_info_types\":"$inputJson"]"
1627
1628                 inputJson=$inputJson",\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\""
1629
1630                 inputJson="{"$inputJson"}"
1631
1632                 file="./tmp/.p.json"
1633                 echo "$inputJson" > $file
1634                 query="/data-producer/v1/info-producers/$2"
1635         else
1636                 inputJson="\"supported_ei_types\":"$inputJson"]"
1637
1638                 inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
1639
1640                 inputJson="{"$inputJson"}"
1641
1642                 file="./tmp/.p.json"
1643                 echo "$inputJson" > $file
1644                 query="/ei-producer/v1/eiproducers/$2"
1645         fi
1646     res="$(__do_curl_to_api ICS PUT $query $file)"
1647     status=${res:${#res}-3}
1648
1649         if [ $status -ne $1 ]; then
1650                 __log_test_fail_status_code $1 $status
1651                 return 1
1652         fi
1653
1654         __log_test_pass
1655         return 0
1656 }
1657
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() {
1662         __log_test_start $@
1663
1664         #Valid number of parameter 2,3,7,11
1665         paramError=1
1666         if [ $# -eq 2 ]; then
1667                 paramError=0
1668         fi
1669         if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
1670                 paramError=0
1671         fi
1672         variablecount=$(($#-2))
1673         if [ $# -gt 3 ] && [ $(($variablecount%5)) -eq 0 ]; then
1674                 paramError=0
1675         fi
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>]+)" $@
1678                 return 1
1679         fi
1680
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
1686                 return 1
1687         fi
1688         if [ $# -gt 2 ]; then
1689                 body=${res:0:${#res}-3}
1690                 targetJson="["
1691                 if [ $# -gt 3 ]; then
1692                         arr=(${@:3})
1693                         for ((i=0; i<$(($#-3)); i=i+5)); do
1694                                 if [ "$targetJson" != "[" ]; then
1695                                         targetJson=$targetJson","
1696                                 fi
1697                                 if [ -f ${arr[$i+4]} ]; then
1698                                         jobfile=$(cat ${arr[$i+4]})
1699                                         jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
1700                                 else
1701                                         __log_test_fail_general "Job template file "${arr[$i+4]}", does not exist"
1702                                         return 1
1703                                 fi
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}"
1705                         done
1706                 fi
1707                 targetJson=$targetJson"]"
1708
1709                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1710                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1711
1712                 if [ $res -ne 0 ]; then
1713                         __log_test_fail_body
1714                         return 1
1715                 fi
1716         fi
1717
1718         __log_test_pass
1719         return 0
1720 }
1721
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() {
1727         __log_test_start $@
1728
1729         #Valid number of parameter 2,3,7,11
1730         paramError=1
1731         if [ $# -eq 2 ]; then
1732                 paramError=0
1733         fi
1734         if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
1735                 paramError=0
1736         fi
1737         variablecount=$(($#-2))
1738         if [ $# -gt 3 ] && [ $(($variablecount%5)) -eq 0 ]; then
1739                 paramError=0
1740         fi
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>]+)" $@
1743                 return 1
1744         fi
1745         if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1746                 query="/data-producer/v1/info-producers/$2/info-jobs"
1747         else
1748                 query="/ei-producer/v1/eiproducers/$2/eijobs"
1749         fi
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
1754                 return 1
1755         fi
1756         if [ $# -gt 2 ]; then
1757                 body=${res:0:${#res}-3}
1758                 targetJson="["
1759                 if [ $# -gt 3 ]; then
1760                         arr=(${@:3})
1761                         for ((i=0; i<$(($#-3)); i=i+5)); do
1762                                 if [ "$targetJson" != "[" ]; then
1763                                         targetJson=$targetJson","
1764                                 fi
1765                                 if [ -f ${arr[$i+4]} ]; then
1766                                         jobfile=$(cat ${arr[$i+4]})
1767                                         jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
1768                                 else
1769                                         __log_test_fail_general "Job template file "${arr[$i+4]}", does not exist"
1770                                         return 1
1771                                 fi
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\":\"????\"}"
1774                                 else
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\":\"????\"}"
1776                                 fi
1777                         done
1778                 fi
1779                 targetJson=$targetJson"]"
1780
1781                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1782                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1783
1784                 if [ $res -ne 0 ]; then
1785                         __log_test_fail_body
1786                         return 1
1787                 fi
1788         fi
1789
1790         __log_test_pass
1791         return 0
1792 }
1793
1794 ##########################################
1795 ####          Service status          ####
1796 ##########################################
1797 # Function prefix: ics_api_service
1798
1799 # API Test function: GET â€‹/status
1800 # args: <response-code>
1801 # (Function for test scripts)
1802 ics_api_service_status() {
1803         __log_test_start $@
1804
1805     if [ $# -lt 1 ]; then
1806                 __print_err "<response-code>" $@
1807                 return 1
1808         fi
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
1813                 return 1
1814         fi
1815         __log_test_pass
1816         return 0
1817 }
1818
1819 ###########################################
1820 ######### Info data consumer API ##########
1821 ###########################################
1822 #Function prefix: ics_api_idc
1823
1824
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() {
1829         __log_test_start $@
1830
1831     if [ $# -lt 1 ]; then
1832                 __print_err "<response-code> [ (EMPTY | [<type-id>]+) ]" $@
1833                 return 1
1834         fi
1835
1836         query="/data-consumer/v1/info-types"
1837     res="$(__do_curl_to_api ICS GET $query)"
1838     status=${res:${#res}-3}
1839
1840         if [ $status -ne $1 ]; then
1841                 __log_test_fail_status_code $1 $status
1842                 return 1
1843         fi
1844         if [ $# -gt 1 ]; then
1845                 body=${res:0:${#res}-3}
1846                 targetJson="["
1847                 if [ $2 != "EMPTY" ]; then
1848                         for pid in ${@:2} ; do
1849                                 if [ "$targetJson" != "[" ]; then
1850                                         targetJson=$targetJson","
1851                                 fi
1852                                 targetJson=$targetJson"\"$pid\""
1853                         done
1854                 fi
1855                 targetJson=$targetJson"]"
1856                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1857                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1858
1859                 if [ $res -ne 0 ]; then
1860                         __log_test_fail_body
1861                         return 1
1862                 fi
1863         fi
1864
1865         __log_test_pass
1866         return 0
1867 }
1868
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() {
1873         __log_test_start $@
1874
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>+ ]" $@
1878                 return 1
1879         fi
1880         search=""
1881         if [ $3 != "NOWNER" ]; then
1882                 search="?owner="$3
1883         fi
1884
1885         if [ $2 != "NOTYPE" ]; then
1886                 if [ -z "$search" ]; then
1887                         search="?infoTypeId="$2
1888                 else
1889                         search=$search"&infoTypeId="$2
1890                 fi
1891         fi
1892         query="/data-consumer/v1/info-jobs$search"
1893
1894     res="$(__do_curl_to_api ICS GET $query)"
1895     status=${res:${#res}-3}
1896
1897         if [ $status -ne $1 ]; then
1898                 __log_test_fail_status_code $1 $status
1899                 return 1
1900         fi
1901
1902         if [ $# -gt 3 ]; then
1903                 body=${res:0:${#res}-3}
1904                 targetJson="["
1905
1906                 for pid in ${@:4} ; do
1907                         if [ "$targetJson" != "[" ]; then
1908                                 targetJson=$targetJson","
1909                         fi
1910                         if [ $pid != "EMPTY" ]; then
1911                                 targetJson=$targetJson"\"$pid\""
1912                         fi
1913                 done
1914
1915                 targetJson=$targetJson"]"
1916                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1917                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1918
1919                 if [ $res -ne 0 ]; then
1920                         __log_test_fail_body
1921                         return 1
1922                 fi
1923         fi
1924
1925         __log_test_pass
1926         return 0
1927 }
1928
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() {
1933         __log_test_start $@
1934
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>]" $@
1937                 return 1
1938         fi
1939         query="/data-consumer/v1/info-jobs/$2"
1940     res="$(__do_curl_to_api ICS GET $query)"
1941     status=${res:${#res}-3}
1942
1943         if [ $status -ne $1 ]; then
1944                 __log_test_fail_status_code $1 $status
1945                 return 1
1946         fi
1947
1948         if [ $# -eq 7 ]; then
1949                 body=${res:0:${#res}-3}
1950
1951                 if [ -f $7 ]; then
1952                         jobfile=$(cat $7)
1953                         jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
1954                 else
1955                         __log_test_fail_general "Job template file "$6", does not exist"
1956                         return 1
1957                 fi
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")
1961
1962                 if [ $res -ne 0 ]; then
1963                         __log_test_fail_body
1964                         return 1
1965                 fi
1966         fi
1967
1968         __log_test_pass
1969         return 0
1970 }
1971
1972
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() {
1977         __log_test_start $@
1978
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 ]" $@
1981                 return 1
1982         fi
1983         if [ -f $7 ]; then
1984                 jobfile=$(cat $7)
1985                 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
1986         else
1987                 __log_test_fail_general "Job template file "$7", does not exist"
1988                 return 1
1989         fi
1990
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
1994
1995         query="/data-consumer/v1/info-jobs/$2"
1996
1997         if [ $# -eq 8 ]; then
1998                 if [ $8 == "VALIDATE" ]; then
1999                         query=$query"?typeCheck=true"
2000                 fi
2001         fi
2002
2003     res="$(__do_curl_to_api ICS PUT $query $file)"
2004     status=${res:${#res}-3}
2005
2006         if [ $status -ne $1 ]; then
2007                 __log_test_fail_status_code $1 $status
2008                 return 1
2009         fi
2010
2011         __log_test_pass
2012         return 0
2013 }
2014
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() {
2019         __log_test_start $@
2020
2021         if [ $# -ne 2 ]; then
2022                 __print_err "<response-code> <job-id>" $@
2023                 return 1
2024         fi
2025         query="/data-consumer/v1/info-jobs/$2"
2026     res="$(__do_curl_to_api ICS DELETE $query)"
2027     status=${res:${#res}-3}
2028
2029         if [ $status -ne $1 ]; then
2030                 __log_test_fail_status_code $1 $status
2031                 return 1
2032         fi
2033
2034         __log_test_pass
2035         return 0
2036 }
2037
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() {
2042         __log_test_start $@
2043
2044     if [ $# -lt 2 ] || [ $# -gt 5 ]; then
2045                 __print_err "<response-code> <type-id> [<schema-file> [<type-status> <producers-count]]" $@
2046                 return 1
2047         fi
2048
2049         query="/data-consumer/v1/info-types/$2"
2050     res="$(__do_curl_to_api ICS GET $query)"
2051     status=${res:${#res}-3}
2052
2053         if [ $status -ne $1 ]; then
2054                 __log_test_fail_status_code $1 $status
2055                 return 1
2056         fi
2057
2058         if [ $# -gt 2 ]; then
2059                 body=${res:0:${#res}-3}
2060                 if [ -f $3 ]; then
2061                         schema=$(cat $3)
2062                 else
2063                         __log_test_fail_general "Schema file "$3", does not exist"
2064                         return 1
2065                 fi
2066                 if [ $# -eq 5 ]; then
2067                         targetJson="{\"job_data_schema\":$schema, \"type_status\":\"$4\", \"no_of_producers\":$5}"
2068                 else
2069                         targetJson="{\"job_data_schema\":$schema}"
2070                 fi
2071                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2072                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2073
2074                 if [ $res -ne 0 ]; then
2075                         __log_test_fail_body
2076                         return 1
2077                 fi
2078         fi
2079
2080         __log_test_pass
2081         return 0
2082 }
2083
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() {
2089         __log_test_start $@
2090
2091         if [ $# -lt 2 ] && [ $# -gt 4 ]; then
2092                 __print_err "<response-code> <job-id> [<status> [<timeout>]]" $@
2093                 return 1
2094         fi
2095
2096         query="/data-consumer/v1/info-jobs/$2/status"
2097
2098         start=$SECONDS
2099         for (( ; ; )); do
2100                 res="$(__do_curl_to_api ICS GET $query)"
2101                 status=${res:${#res}-3}
2102
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
2107                                 echo ""
2108                                 duration=-1  #Last iteration
2109                         fi
2110                 else
2111                         duration=-1 #single test, no wait
2112                 fi
2113
2114                 if [ $status -ne $1 ]; then
2115                         if [ $duration -eq -1 ]; then
2116                                 __log_test_fail_status_code $1 $status
2117                                 return 1
2118                         fi
2119                 fi
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")
2125
2126                         if [ $res -ne 0 ]; then
2127                                 if [ $duration -eq -1 ]; then
2128                                         __log_test_fail_body
2129                                         return 1
2130                                 fi
2131                         else
2132                                 duration=-1  #Goto pass
2133                         fi
2134                 fi
2135                 if [ $duration -eq -1 ]; then
2136                         if [ $# -eq 4 ]; then
2137                                 echo ""
2138                         fi
2139                         __log_test_pass
2140                         return 0
2141                 else
2142                         sleep 1
2143                 fi
2144         done
2145
2146         __log_test_pass
2147         return 0
2148 }
2149
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() {
2155
2156         __log_test_start $@
2157         param_error=0
2158         if [ $# -lt 2 ]; then
2159                 param_error=1
2160         fi
2161         args=("$@")
2162         timeout=0
2163         if [ $# -gt 2 ]; then
2164                 if [ $# -lt 4 ]; then
2165                         param_error=1
2166                 fi
2167                 targetJson="{\"info_job_status\": \"$3\""
2168                 if [ "$4" == "EMPTYPROD" ]; then
2169                         targetJson=$targetJson",\"producers\": []}"
2170                         if [ $# -gt 4 ]; then
2171                                 timeout=$5
2172                         fi
2173                 else
2174                         targetJson=$targetJson",\"producers\": ["
2175                         if [ $# -eq $(($4+5)) ]; then
2176                                 idx=$(($4+4))
2177                                 timeout=${args[$idx]}
2178                         fi
2179                         for ((ics_i = 0 ; ics_i < $4 ; ics_i++)); do
2180                                 idx=$(($ics_i+4))
2181                                 if [ $ics_i -gt 0 ]; then
2182                                         targetJson=$targetJson","
2183                                 fi
2184                                 targetJson=$targetJson"\""${args[$idx]}"\""
2185                         done
2186                         targetJson=$targetJson"]}"
2187                 fi
2188         fi
2189
2190         if [ $param_error -ne 0 ]; then
2191                 __print_err "<response-code> <job-id> [<status> EMPTYPROD|( <prod-count> <producer-id>+ ) [<timeout>]]" $@
2192                 return 1
2193         fi
2194
2195         query="/data-consumer/v1/info-jobs/$2/status"
2196
2197         start=$SECONDS
2198         for (( ; ; )); do
2199                 res="$(__do_curl_to_api ICS GET $query)"
2200                 status=${res:${#res}-3}
2201
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
2206                                 echo ""
2207                                 duration=-1  #Last iteration
2208                         fi
2209                 else
2210                         duration=-1 #single test, no wait
2211                 fi
2212
2213                 if [ $status -ne $1 ]; then
2214                         if [ $duration -eq -1 ]; then
2215                                 __log_test_fail_status_code $1 $status
2216                                 return 1
2217                         fi
2218                 fi
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")
2223
2224                         if [ $res -ne 0 ]; then
2225                                 if [ $duration -eq -1 ]; then
2226                                         __log_test_fail_body
2227                                         return 1
2228                                 fi
2229                         else
2230                                 duration=-1  #Goto pass
2231                         fi
2232                 fi
2233                 if [ $duration -eq -1 ]; then
2234                         if [ $# -eq 4 ]; then
2235                                 echo ""
2236                         fi
2237                         __log_test_pass
2238                         return 0
2239                 else
2240                         sleep 1
2241                 fi
2242         done
2243
2244         __log_test_pass
2245         return 0
2246 }
2247
2248 ##########################################
2249 ####     Type subscriptions           ####
2250 ##########################################
2251
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() {
2256         __log_test_start $@
2257
2258     if [ $# -lt 3 ]; then
2259                 __print_err "<response-code> <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]" $@
2260                 return 1
2261         fi
2262
2263         query="/data-consumer/v1/info-type-subscription"
2264         search=""
2265         if [ $2 != "NOOWNER" ]; then
2266                 search="?owner="$2
2267         fi
2268
2269     res="$(__do_curl_to_api ICS GET $query$search)"
2270     status=${res:${#res}-3}
2271
2272         if [ $status -ne $1 ]; then
2273                 __log_test_fail_status_code $1 $status
2274                 return 1
2275         fi
2276
2277         if [ $# -gt 2 ]; then
2278                 body=${res:0:${#res}-3}
2279                 targetJson="["
2280                 if [ $3 != "EMPTY" ]; then
2281                         for pid in ${@:3} ; do
2282                                 if [ "$targetJson" != "[" ]; then
2283                                         targetJson=$targetJson","
2284                                 fi
2285                                 targetJson=$targetJson"\"$pid\""
2286                         done
2287                 fi
2288                 targetJson=$targetJson"]"
2289                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2290                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2291
2292                 if [ $res -ne 0 ]; then
2293                         __log_test_fail_body
2294                         return 1
2295                 fi
2296         fi
2297
2298         __log_test_pass
2299         return 0
2300 }
2301
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() {
2306         __log_test_start $@
2307
2308     if [ $# -ne 2 ] && [ $# -ne 4 ]; then
2309                 __print_err "<response-code>  <subscription-id> [ <owner-id> <status-uri> ]" $@
2310                 return 1
2311         fi
2312
2313         query="/data-consumer/v1/info-type-subscription/$2"
2314     res="$(__do_curl_to_api ICS GET $query)"
2315     status=${res:${#res}-3}
2316
2317         if [ $status -ne $1 ]; then
2318                 __log_test_fail_status_code $1 $status
2319                 return 1
2320         fi
2321
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")
2327
2328                 if [ $res -ne 0 ]; then
2329                         __log_test_fail_body
2330                         return 1
2331                 fi
2332         fi
2333
2334         __log_test_pass
2335         return 0
2336 }
2337
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() {
2342         __log_test_start $@
2343
2344     if [ $# -ne 4 ]; then
2345                 __print_err "<response-code>  <subscription-id> <owner-id> <status-uri>" $@
2346                 return 1
2347         fi
2348
2349         inputJson="{\"owner\": \"$3\",\"status_result_uri\": \"$4\"}"
2350         file="./tmp/.p.json"
2351         echo "$inputJson" > $file
2352
2353         query="/data-consumer/v1/info-type-subscription/$2"
2354     res="$(__do_curl_to_api ICS PUT $query $file)"
2355     status=${res:${#res}-3}
2356
2357         if [ $status -ne $1 ]; then
2358                 __log_test_fail_status_code $1 $status
2359                 return 1
2360         fi
2361
2362         __log_test_pass
2363         return 0
2364 }
2365
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() {
2370         __log_test_start $@
2371
2372         if [ $# -ne 2 ]; then
2373                 __print_err "<response-code>  <subscription-id> " $@
2374                 return 1
2375         fi
2376
2377         query="/data-consumer/v1/info-type-subscription/$2"
2378     res="$(__do_curl_to_api ICS DELETE $query)"
2379     status=${res:${#res}-3}
2380
2381         if [ $status -ne $1 ]; then
2382                 __log_test_fail_status_code $1 $status
2383                 return 1
2384         fi
2385
2386         __log_test_pass
2387         return 0
2388 }
2389
2390 ##########################################
2391 ####          Reset jobs              ####
2392 ##########################################
2393 # Function prefix: ics_api_admin
2394
2395 # Admin to remove all jobs
2396 # args: <response-code> [ <type> ]
2397 # (Function for test scripts)
2398
2399 ics_api_admin_reset() {
2400         __log_test_start $@
2401
2402         if [  -z "$FLAT_A1_EI" ]; then
2403                 query="/A1-EI/v1/eitypes/$2/eijobs"
2404         else
2405                 query="/A1-EI/v1/eijobs"
2406         fi
2407     res="$(__do_curl_to_api ICS GET $query)"
2408     status=${res:${#res}-3}
2409
2410         if [ $status -ne 200 ]; then
2411                 __log_test_fail_status_code $1 $status
2412                 return 1
2413         fi
2414
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//\"/})
2421         list=$list" "
2422         for job in $list; do
2423                 if [  -z "$FLAT_A1_EI" ]; then
2424                         echo "Not supported for non-flat EI api"
2425                 else
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
2431                                 return 1
2432                         fi
2433                         echo " Deleted job: "$job
2434                 fi
2435         done
2436
2437         __log_test_pass
2438         return 0
2439 }
2440
2441 ##########################################
2442 ####     Reset jobs and producers     ####
2443 ##########################################
2444
2445
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
2448 # args: -
2449 # (Function for test scripts)
2450
2451 ics_kube_pvc_reset() {
2452         __log_test_start $@
2453
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
2457         fi
2458         echo " Trying to reset pvc: "$pvc_name
2459
2460         __kube_clean_pvc $ICS_APP_NAME $KUBE_NONRTRIC_NAMESPACE $pvc_name $ICS_CONTAINER_MNT_DIR
2461
2462         __log_test_pass
2463         return 0
2464 }