Merge "Added tests and improvements"
[nonrtric.git] / test / common / ecs_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 ECS
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 __ECS_imagesetup() {
28         __check_and_create_image_var ECS "ECS_IMAGE" "ECS_IMAGE_BASE" "ECS_IMAGE_TAG" $1 "$ECS_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 __ECS_imagepull() {
37         __check_and_pull_image $1 "$ECS_DISPLAY_NAME" $ECS_APP_NAME ECS_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 __ECS_imagebuild() {
44         echo -e $RED" Image for app ECS 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 __ECS_image_data() {
51         echo -e "$ECS_DISPLAY_NAME\t$(docker images --format $1 $ECS_IMAGE)" >>   $2
52         if [ ! -z "$ECS_IMAGE_SOURCE" ]; then
53                 echo -e "-- source image --\t$(docker images --format $1 $ECS_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 __ECS_kube_scale_zero() {
61         __kube_scale_all_resources $KUBE_NONRTRIC_NAMESPACE autotest ECS
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 __ECS_kube_scale_zero_and_wait() {
67         __kube_scale_and_wait_all_resources $KUBE_NONRTRIC_NAMESPACE app "$KUBE_NONRTRIC_NAMESPACE"-enrichmentservice
68 }
69
70 # Delete all kube resouces for the app
71 # This function is called for apps managed by the test script.
72 __ECS_kube_delete_all() {
73         __kube_delete_all_resources $KUBE_NONRTRIC_NAMESPACE autotest ECS
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 __ECS_store_docker_logs() {
80         if [ $RUNMODE == "KUBE" ]; then
81                 kubectl  logs -l "autotest=ECS" -n $KUBE_NONRTRIC_NAMESPACE --tail=-1 > $1$2_ecs.log 2>&1
82         else
83                 docker logs $ECS_APP_NAME > $1$2_ecs.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 __ECS_initial_setup() {
91         use_ecs_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 __ECS_statisics_setup() {
99         if [ $RUNMODE == "KUBE" ]; then
100                 echo "ECS $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE"
101         else
102                 echo "ECS $ECS_APP_NAME"
103         fi
104 }
105
106 #######################################################
107
108
109 # Make curl retries towards ECS for http response codes set in this env var, space separated list of codes
110 ECS_RETRY_CODES=""
111
112 #Save first worker node the pod is started on
113 __ECS_WORKER_NODE=""
114
115 ###########################
116 ### ECS functions
117 ###########################
118
119 # All calls to ECS will be directed to the ECS REST interface from now on
120 # args: -
121 # (Function for test scripts)
122 use_ecs_rest_http() {
123         __ecs_set_protocoll "http" $ECS_INTERNAL_PORT $ECS_EXTERNAL_PORT
124 }
125
126 # All calls to ECS will be directed to the ECS REST interface from now on
127 # args: -
128 # (Function for test scripts)
129 use_ecs_rest_https() {
130         __ecs_set_protocoll "https" $ECS_INTERNAL_SECURE_PORT $ECS_EXTERNAL_SECURE_PORT
131 }
132
133 # All calls to ECS will be directed to the ECS dmaap interface over http from now on
134 # args: -
135 # (Function for test scripts)
136 use_ecs_dmaap_http() {
137         echo -e $BOLD"ECS dmaap protocol setting"$EBOLD
138         echo -e $RED" - NOT SUPPORTED - "$ERED
139         echo -e " Using $BOLD http $EBOLD and $BOLD DMAAP $EBOLD towards ECS"
140         ECS_ADAPTER_TYPE="MR-HTTP"
141         echo ""
142 }
143
144 # Setup paths to svc/container for internal and external access
145 # args: <protocol> <internal-port> <external-port>
146 __ecs_set_protocoll() {
147         echo -e $BOLD"$ECS_DISPLAY_NAME protocol setting"$EBOLD
148         echo -e " Using $BOLD http $EBOLD towards $ECS_DISPLAY_NAME"
149
150         ## Access to ECS
151
152         ECS_SERVICE_PATH=$1"://"$ECS_APP_NAME":"$2  # docker access, container->container and script->container via proxy
153         if [ $RUNMODE == "KUBE" ]; then
154                 ECS_SERVICE_PATH=$1"://"$ECS_APP_NAME.$KUBE_NONRTRIC_NAMESPACE":"$3 # kube access, pod->svc and script->svc via proxy
155         fi
156
157         # ECS_ADAPTER used for switching between REST and DMAAP (only REST supported currently)
158         ECS_ADAPTER_TYPE="REST"
159         ECS_ADAPTER=$ECS_SERVICE_PATH
160
161         echo ""
162 }
163
164 # Export env vars for config files, docker compose and kube resources
165 # args: PROXY|NOPROXY
166 __ecs_export_vars() {
167                 export ECS_APP_NAME
168                 export ECS_APP_NAME_ALIAS
169                 export KUBE_NONRTRIC_NAMESPACE
170                 export ECS_IMAGE
171                 export ECS_INTERNAL_PORT
172                 export ECS_INTERNAL_SECURE_PORT
173                 export ECS_EXTERNAL_PORT
174                 export ECS_EXTERNAL_SECURE_PORT
175                 export ECS_CONFIG_MOUNT_PATH
176                 export ECS_CONFIG_CONFIGMAP_NAME=$ECS_APP_NAME"-config"
177                 export ECS_DATA_CONFIGMAP_NAME=$ECS_APP_NAME"-data"
178                 export ECS_CONTAINER_MNT_DIR
179                 export ECS_HOST_MNT_DIR
180                 export ECS_CONFIG_FILE
181                 export DOCKER_SIM_NWNAME
182                 export ECS_DISPLAY_NAME
183
184
185                 export ECS_DATA_PV_NAME=$ECS_APP_NAME"-pv"
186                 export ECS_DATA_PVC_NAME=$ECS_APP_NAME"-pvc"
187                 #Create a unique path for the pv each time to prevent a previous volume to be reused
188                 export ECS_PV_PATH="ecsdata-"$(date +%s)
189
190                 if [ $1 == "PROXY" ]; then
191                         export ECS_HTTP_PROXY_CONFIG_PORT=$HTTP_PROXY_CONFIG_PORT  #Set if proxy is started
192                         export ECS_HTTP_PROXY_CONFIG_HOST_NAME=$HTTP_PROXY_CONFIG_HOST_NAME #Set if proxy is started
193                         if [ $ECS_HTTP_PROXY_CONFIG_PORT -eq 0 ] || [ -z "$ECS_HTTP_PROXY_CONFIG_HOST_NAME" ]; then
194                                 echo -e $YELLOW" Warning: HTTP PROXY will not be configured, proxy app not started"$EYELLOW
195                         else
196                                 echo " Configured with http proxy"
197                         fi
198                 else
199                         export ECS_HTTP_PROXY_CONFIG_PORT=0
200                         export ECS_HTTP_PROXY_CONFIG_HOST_NAME=""
201                         echo " Configured without http proxy"
202                 fi
203 }
204
205
206 # Start the ECS
207 # args: PROXY|NOPROXY <config-file>
208 # (Function for test scripts)
209 start_ecs() {
210
211         echo -e $BOLD"Starting $ECS_DISPLAY_NAME"$EBOLD
212
213         if [ $RUNMODE == "KUBE" ]; then
214
215                 # Check if app shall be fully managed by the test script
216                 __check_included_image "ECS"
217                 retcode_i=$?
218
219                 # Check if app shall only be used by the testscipt
220                 __check_prestarted_image "ECS"
221                 retcode_p=$?
222
223                 if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then
224                         echo -e $RED"The $ECS_APP_NAME app is not included as managed nor prestarted in this test script"$ERED
225                         echo -e $RED"The $ECS_APP_NAME will not be started"$ERED
226                         exit
227                 fi
228                 if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then
229                         echo -e $RED"The $ECS_APP_NAME app is included both as managed and prestarted in this test script"$ERED
230                         echo -e $RED"The $ECS_APP_NAME will not be started"$ERED
231                         exit
232                 fi
233
234
235                 if [ $retcode_p -eq 0 ]; then
236                         echo -e " Using existing $ECS_APP_NAME deployment and service"
237                         echo " Setting ECS replicas=1"
238                         res_type=$(__kube_get_resource_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
239                         __kube_scale $res_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
240                 fi
241
242                 # Check if app shall be fully managed by the test script
243                 if [ $retcode_i -eq 0 ]; then
244                         echo -e " Creating $ECS_APP_NAME app and expose service"
245
246                         #Check if nonrtric namespace exists, if not create it
247                         __kube_create_namespace $KUBE_NONRTRIC_NAMESPACE
248
249                         __ecs_export_vars $1
250
251                         # Create config map for config
252                         datafile=$PWD/tmp/$ECS_CONFIG_FILE
253                         cp $2 $datafile
254                         output_yaml=$PWD/tmp/ecs_cfc.yaml
255                         __kube_create_configmap $ECS_CONFIG_CONFIGMAP_NAME $KUBE_NONRTRIC_NAMESPACE autotest ECS $datafile $output_yaml
256
257                         # Create pv
258                         input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"pv.yaml
259                         output_yaml=$PWD/tmp/ecs_pv.yaml
260                         __kube_create_instance pv $ECS_APP_NAME $input_yaml $output_yaml
261
262                         # Create pvc
263                         input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"pvc.yaml
264                         output_yaml=$PWD/tmp/ecs_pvc.yaml
265                         __kube_create_instance pvc $ECS_APP_NAME $input_yaml $output_yaml
266
267                         # Create service
268                         input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"svc.yaml
269                         output_yaml=$PWD/tmp/ecs_svc.yaml
270                         __kube_create_instance service $ECS_APP_NAME $input_yaml $output_yaml
271
272                         # Create app
273                         input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"app.yaml
274                         output_yaml=$PWD/tmp/ecs_app.yaml
275                         __kube_create_instance app $ECS_APP_NAME $input_yaml $output_yaml
276                 fi
277
278                 # Tie the ECS to a worker node so that ECS will always be scheduled to the same worker node if the ECS pod is restarted
279                 # A PVC of type hostPath is mounted to ECS, for persistent storage, so the ECS must always be on the node which mounted the volume
280
281                 # 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
282                 if [ $retcode_i -eq 0 ]; then
283                         __ECS_WORKER_NODE=$(kubectl get pod -l "autotest=ECS" -n $KUBE_NONRTRIC_NAMESPACE -o jsonpath='{.items[*].spec.nodeName}')
284                         if [ -z "$__ECS_WORKER_NODE" ]; then
285                                 echo -e $YELLOW" Cannot find worker node for pod for $ECS_APP_NAME, persistency may not work"$EYELLOW
286                         fi
287                 else
288                         echo -e $YELLOW" Persistency may not work for app $ECS_APP_NAME in multi-worker node config when running it as a prestarted app"$EYELLOW
289                 fi
290
291
292                 __check_service_start $ECS_APP_NAME $ECS_SERVICE_PATH$ECS_ALIVE_URL
293
294         else
295                 __check_included_image 'ECS'
296                 if [ $? -eq 1 ]; then
297                         echo -e $RED"The ECS app is not included in this test script"$ERED
298                         echo -e $RED"ECS will not be started"$ERED
299                         exit 1
300                 fi
301
302                 curdir=$PWD
303                 cd $SIM_GROUP
304                 cd ecs
305                 cd $ECS_HOST_MNT_DIR
306                 #cd ..
307                 if [ -d db ]; then
308                         if [ "$(ls -A $DIR)" ]; then
309                                 echo -e $BOLD" Cleaning files in mounted dir: $PWD/db"$EBOLD
310                                 rm -rf db/*  &> /dev/null
311                                 if [ $? -ne 0 ]; then
312                                         echo -e $RED" Cannot remove database files in: $PWD"$ERED
313                                         exit 1
314                                 fi
315                         fi
316                 else
317                         echo " No files in mounted dir or dir does not exists"
318                 fi
319
320                 cd $curdir
321
322                 __ecs_export_vars $1
323
324                 dest_file=$SIM_GROUP/$ECS_COMPOSE_DIR/$ECS_HOST_MNT_DIR/$ECS_CONFIG_FILE
325
326                 envsubst < $2 > $dest_file
327
328                 __start_container $ECS_COMPOSE_DIR "" NODOCKERARGS 1 $ECS_APP_NAME
329
330                 __check_service_start $ECS_APP_NAME $ECS_SERVICE_PATH$ECS_ALIVE_URL
331         fi
332         echo ""
333         return 0
334 }
335
336 # Stop the ecs
337 # args: -
338 # args: -
339 # (Function for test scripts)
340 stop_ecs() {
341         echo -e $BOLD"Stopping $ECS_DISPLAY_NAME"$EBOLD
342
343         if [ $RUNMODE == "KUBE" ]; then
344
345                 __check_prestarted_image "ECS"
346                 if [ $? -eq 0 ]; then
347                         echo -e $YELLOW" Persistency may not work for app $ECS_APP_NAME in multi-worker node config when running it as a prestarted app"$EYELLOW
348                         res_type=$(__kube_get_resource_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
349                         __kube_scale $res_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 0
350                         return 0
351                 fi
352
353                 __kube_scale_all_resources $KUBE_NONRTRIC_NAMESPACE autotest ECS
354                 echo "  Deleting the replica set - a new will be started when the app is started"
355                 tmp=$(kubectl delete rs -n $KUBE_NONRTRIC_NAMESPACE -l "autotest=ECS")
356                 if [ $? -ne 0 ]; then
357                         echo -e $RED" Could not delete replica set "$RED
358                         ((RES_CONF_FAIL++))
359                         return 1
360                 fi
361         else
362                 docker stop $ECS_APP_NAME &> ./tmp/.dockererr
363                 if [ $? -ne 0 ]; then
364                         __print_err "Could not stop $ECS_APP_NAME" $@
365                         cat ./tmp/.dockererr
366                         ((RES_CONF_FAIL++))
367                         return 1
368                 fi
369         fi
370         echo -e $BOLD$GREEN"Stopped"$EGREEN$EBOLD
371         echo ""
372         return 0
373 }
374
375 # Start a previously stopped ecs
376 # args: -
377 # (Function for test scripts)
378 start_stopped_ecs() {
379         echo -e $BOLD"Starting (the previously stopped) $ECS_DISPLAY_NAME"$EBOLD
380
381         if [ $RUNMODE == "KUBE" ]; then
382
383                 __check_prestarted_image "ECS"
384                 if [ $? -eq 0 ]; then
385                         echo -e $YELLOW" Persistency may not work for app $ECS_APP_NAME in multi-worker node config when running it as a prestarted app"$EYELLOW
386                         res_type=$(__kube_get_resource_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE)
387                         __kube_scale $res_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
388                         __check_service_start $ECS_APP_NAME $ECS_SERVICE_PATH$ECS_ALIVE_URL
389                         return 0
390                 fi
391
392                 # Tie the PMS to the same worker node it was initially started on
393                 # 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
394                 if [ -z "$__ECS_WORKER_NODE" ]; then
395                         echo -e $RED" No initial worker node found for pod "$RED
396                         ((RES_CONF_FAIL++))
397                         return 1
398                 else
399                         echo -e $BOLD" Setting nodeSelector kubernetes.io/hostname=$__ECS_WORKER_NODE to deployment for $ECS_APP_NAME. Pod will always run on this worker node: $__PA_WORKER_NODE"$BOLD
400                         echo -e $BOLD" The mounted volume is mounted as hostPath and only available on that worker node."$BOLD
401                         tmp=$(kubectl patch deployment $ECS_APP_NAME -n $KUBE_NONRTRIC_NAMESPACE --patch '{"spec": {"template": {"spec": {"nodeSelector": {"kubernetes.io/hostname": "'$__ECS_WORKER_NODE'"}}}}}')
402                         if [ $? -ne 0 ]; then
403                                 echo -e $YELLOW" Cannot set nodeSelector to deployment for $ECS_APP_NAME, persistency may not work"$EYELLOW
404                         fi
405                         __kube_scale deployment $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1
406                 fi
407         else
408                 docker start $ECS_APP_NAME &> ./tmp/.dockererr
409                 if [ $? -ne 0 ]; then
410                         __print_err "Could not start (the stopped) $ECS_APP_NAME" $@
411                         cat ./tmp/.dockererr
412                         ((RES_CONF_FAIL++))
413                         return 1
414                 fi
415         fi
416         __check_service_start $ECS_APP_NAME $ECS_SERVICE_PATH$ECS_ALIVE_URL
417         if [ $? -ne 0 ]; then
418                 return 1
419         fi
420         echo ""
421         return 0
422 }
423
424 # Turn on debug level tracing in ECS
425 # args: -
426 # (Function for test scripts)
427 set_ecs_debug() {
428         echo -e $BOLD"Setting ecs debug logging"$EBOLD
429         curlString="$ECS_SERVICE_PATH$ECS_ACTUATOR -X POST  -H Content-Type:application/json -d {\"configuredLevel\":\"debug\"}"
430         result=$(__do_curl "$curlString")
431         if [ $? -ne 0 ]; then
432                 __print_err "Could not set debug mode" $@
433                 ((RES_CONF_FAIL++))
434                 return 1
435         fi
436         echo ""
437         return 0
438 }
439
440 # Turn on trace level tracing in ECS
441 # args: -
442 # (Function for test scripts)
443 set_ecs_trace() {
444         echo -e $BOLD"Setting ecs trace logging"$EBOLD
445         curlString="$ECS_SERVICE_PATH/actuator/loggers/org.oransc.enrichment -X POST  -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}"
446         result=$(__do_curl "$curlString")
447         if [ $? -ne 0 ]; then
448                 __print_err "Could not set trace mode" $@
449                 ((RES_CONF_FAIL++))
450                 return 1
451         fi
452         echo ""
453         return 0
454 }
455
456 # Perform curl retries when making direct call to ECS for the specified http response codes
457 # Speace separated list of http response codes
458 # args: [<response-code>]*
459 use_ecs_retries() {
460         echo -e $BOLD"Do curl retries to the ECS REST inteface for these response codes:$@"$EBOLD
461         ECS_RETRY_CODES=$@
462         echo ""
463         return 0
464 }
465
466 # Check the ecs logs for WARNINGs and ERRORs
467 # args: -
468 # (Function for test scripts)
469 check_ecs_logs() {
470         __check_container_logs "ECS" $ECS_APP_NAME $ECS_LOGPATH WARN ERR
471 }
472
473
474 # Tests if a variable value in the ECS is equal to a target value and and optional timeout.
475 # Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
476 # equal to the target or not.
477 # Arg: <variable-name> <target-value> <timeout-in-sec>  - This test waits up to the timeout seconds
478 # before setting pass or fail depending on if the variable value becomes equal to the target
479 # value or not.
480 # (Function for test scripts)
481 ecs_equal() {
482         if [ $# -eq 2 ] || [ $# -eq 3 ]; then
483                 __var_test ECS "$ECS_SERVICE_PATH/" $1 "=" $2 $3
484         else
485                 __print_err "Wrong args to ecs_equal, needs two or three args: <sim-param> <target-value> [ timeout ]" $@
486         fi
487 }
488
489
490 ##########################################
491 ######### A1-E Enrichment  API ##########
492 ##########################################
493 #Function prefix: ecs_api_a1
494
495 # API Test function: GET /A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs
496 # args: <response-code> <type-id>  <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
497 # args (flat uri structure): <response-code> <type-id>|NOTYPE  <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
498 # (Function for test scripts)
499 ecs_api_a1_get_job_ids() {
500         __log_test_start $@
501
502         if [ -z "$FLAT_A1_EI" ]; then
503                 # Valid number of parameters 4,5,6 etc
504         if [ $# -lt 3 ]; then
505                         __print_err "<response-code> <type-id>  <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
506                         return 1
507                 fi
508         else
509                 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
510                 # Valid number of parameters 4,5,6 etc
511         if [ $# -lt 3 ]; then
512                         __print_err "<response-code> <type-id>|NOTYPE  <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
513                         return 1
514                 fi
515         fi
516         search=""
517         if [ $3 != "NOWNER" ]; then
518                 search="?owner="$3
519         fi
520
521         if [  -z "$FLAT_A1_EI" ]; then
522                 query="/A1-EI/v1/eitypes/$2/eijobs$search"
523         else
524                 if [ $2 != "NOTYPE" ]; then
525                         if [ -z "$search" ]; then
526                                 search="?eiTypeId="$2
527                         else
528                                 search=$search"&eiTypeId="$2
529                         fi
530                 fi
531                 query="/A1-EI/v1/eijobs$search"
532         fi
533     res="$(__do_curl_to_api ECS GET $query)"
534     status=${res:${#res}-3}
535
536         if [ $status -ne $1 ]; then
537                 __log_test_fail_status_code $1 $status
538                 return 1
539         fi
540
541         if [ $# -gt 3 ]; then
542                 body=${res:0:${#res}-3}
543                 targetJson="["
544
545                 for pid in ${@:4} ; do
546                         if [ "$targetJson" != "[" ]; then
547                                 targetJson=$targetJson","
548                         fi
549                         if [ $pid != "EMPTY" ]; then
550                                 targetJson=$targetJson"\"$pid\""
551                         fi
552                 done
553
554                 targetJson=$targetJson"]"
555                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
556                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
557
558                 if [ $res -ne 0 ]; then
559                         __log_test_fail_body
560                         return 1
561                 fi
562         fi
563
564         __log_test_pass
565         return 0
566 }
567
568 # API Test function: GET â€‹/A1-EI​/v1​/eitypes​/{eiTypeId}
569 # args: <response-code> <type-id> [<schema-file>]
570 # (Function for test scripts)
571 ecs_api_a1_get_type() {
572         __log_test_start $@
573
574     if [ $# -lt 2 ] || [ $# -gt 3 ]; then
575                 __print_err "<response-code> <type-id> [<schema-file>]" $@
576                 return 1
577         fi
578
579         query="/A1-EI/v1/eitypes/$2"
580     res="$(__do_curl_to_api ECS GET $query)"
581     status=${res:${#res}-3}
582
583         if [ $status -ne $1 ]; then
584                 __log_test_fail_status_code $1 $status
585                 return 1
586         fi
587
588         if [ $# -eq 3 ]; then
589                 body=${res:0:${#res}-3}
590                 if [ -f $3 ]; then
591                         schema=$(cat $3)
592                 else
593                         __log_test_fail_general "Schema file "$3", does not exist"
594                         return 1
595                 fi
596                 if [ -z "$FLAT_A1_EI" ]; then
597                         targetJson="{\"eiJobParametersSchema\":$schema}"
598                 else
599                         targetJson=$schema
600                 fi
601                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
602                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
603
604                 if [ $res -ne 0 ]; then
605                         __log_test_fail_body
606                         return 1
607                 fi
608         fi
609
610         __log_test_pass
611         return 0
612 }
613
614 # API Test function: GET /A1-EI/v1/eitypes
615 # args: <response-code> [ (EMPTY | [<type-id>]+) ]
616 # (Function for test scripts)
617 ecs_api_a1_get_type_ids() {
618         __log_test_start $@
619
620     if [ $# -lt 1 ]; then
621                 __print_err "<response-code> [ (EMPTY | [<type-id>]+) ]" $@
622                 return 1
623         fi
624
625         query="/A1-EI/v1/eitypes"
626     res="$(__do_curl_to_api ECS GET $query)"
627     status=${res:${#res}-3}
628
629         if [ $status -ne $1 ]; then
630                 __log_test_fail_status_code $1 $status
631                 return 1
632         fi
633         if [ $# -gt 1 ]; then
634                 body=${res:0:${#res}-3}
635                 targetJson="["
636                 if [ $2 != "EMPTY" ]; then
637                         for pid in ${@:2} ; do
638                                 if [ "$targetJson" != "[" ]; then
639                                         targetJson=$targetJson","
640                                 fi
641                                 targetJson=$targetJson"\"$pid\""
642                         done
643                 fi
644                 targetJson=$targetJson"]"
645                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
646                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
647
648                 if [ $res -ne 0 ]; then
649                         __log_test_fail_body
650                         return 1
651                 fi
652         fi
653
654         __log_test_pass
655         return 0
656 }
657
658 # API Test function: GET â€‹/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}​/status
659 # args: <response-code> <type-id> <job-id> [<status>]
660 # args (flat uri structure): <response-code> <job-id> [<status> [<timeout>]]
661 # (Function for test scripts)
662 ecs_api_a1_get_job_status() {
663         __log_test_start $@
664
665         if [ -z "$FLAT_A1_EI" ]; then
666                 if [ $# -ne 3 ] && [ $# -ne 4 ]; then
667                         __print_err "<response-code> <type-id> <job-id> [<status>]" $@
668                         return 1
669                 fi
670
671                 query="/A1-EI/v1/eitypes/$2/eijobs/$3/status"
672
673                 res="$(__do_curl_to_api ECS GET $query)"
674                 status=${res:${#res}-3}
675
676                 if [ $status -ne $1 ]; then
677                         __log_test_fail_status_code $1 $status
678                         return 1
679                 fi
680                 if [ $# -eq 4 ]; then
681                         body=${res:0:${#res}-3}
682                         targetJson="{\"operationalState\": \"$4\"}"
683                         echo " TARGET JSON: $targetJson" >> $HTTPLOG
684                         res=$(python3 ../common/compare_json.py "$targetJson" "$body")
685
686                         if [ $res -ne 0 ]; then
687                                 __log_test_fail_body
688                                 return 1
689                         fi
690                 fi
691         else
692                 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
693                 if [ $# -lt 2 ] && [ $# -gt 4 ]; then
694                         __print_err "<response-code> <job-id> [<status> [<timeout>]]" $@
695                         return 1
696                 fi
697
698                 query="/A1-EI/v1/eijobs/$2/status"
699
700                 start=$SECONDS
701                 for (( ; ; )); do
702                         res="$(__do_curl_to_api ECS GET $query)"
703                         status=${res:${#res}-3}
704
705                         if [ $# -eq 4 ]; then
706                                 duration=$((SECONDS-start))
707                                 echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
708                                 if [ $duration -gt $4 ]; then
709                                         echo ""
710                                         duration=-1  #Last iteration
711                                 fi
712                         else
713                                 duration=-1 #single test, no wait
714                         fi
715
716                         if [ $status -ne $1 ]; then
717                                 if [ $duration -eq -1 ]; then
718                                         __log_test_fail_status_code $1 $status
719                                         return 1
720                                 fi
721                         fi
722                         if [ $# -ge 3 ] && [ $status -eq $1 ]; then
723                                 body=${res:0:${#res}-3}
724                                 targetJson="{\"eiJobStatus\": \"$3\"}"
725                                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
726                                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
727
728                                 if [ $res -ne 0 ]; then
729                                         if [ $duration -eq -1 ]; then
730                                                 __log_test_fail_body
731                                                 return 1
732                                         fi
733                                 else
734                                         duration=-1  #Goto pass
735                                 fi
736                         fi
737                         if [ $duration -eq -1 ]; then
738                                 if [ $# -eq 4 ]; then
739                                         echo ""
740                                 fi
741                                 __log_test_pass
742                                 return 0
743                         else
744                                 sleep 1
745                         fi
746                 done
747         fi
748
749         __log_test_pass
750         return 0
751 }
752
753 # API Test function: GET â€‹/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
754 # args: <response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]
755 # args (flat uri structure): <response-code> <job-id> [<type-id> <target-url> <owner-id> <template-job-file>]
756 # (Function for test scripts)
757 ecs_api_a1_get_job() {
758         __log_test_start $@
759
760         if [  -z "$FLAT_A1_EI" ]; then
761                 if [ $# -ne 3 ] && [ $# -ne 6 ]; then
762                         __print_err "<response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]" $@
763                         return 1
764                 fi
765                 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
766         else
767                 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
768                 if [ $# -ne 2 ] && [ $# -ne 7 ]; then
769                         __print_err "<response-code> <job-id> [<type-id> <target-url> <owner-id> <notification-url> <template-job-file>]" $@
770                         return 1
771                 fi
772                 query="/A1-EI/v1/eijobs/$2"
773         fi
774     res="$(__do_curl_to_api ECS GET $query)"
775     status=${res:${#res}-3}
776
777         if [ $status -ne $1 ]; then
778                 __log_test_fail_status_code $1 $status
779                 return 1
780         fi
781
782         if [  -z "$FLAT_A1_EI" ]; then
783                 if [ $# -eq 6 ]; then
784                         body=${res:0:${#res}-3}
785
786                         if [ -f $6 ]; then
787                                 jobfile=$(cat $6)
788                                 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
789                         else
790                                 __log_test_fail_general "Job template file "$6", does not exist"
791                                 return 1
792                         fi
793                         targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
794                         echo " TARGET JSON: $targetJson" >> $HTTPLOG
795                         res=$(python3 ../common/compare_json.py "$targetJson" "$body")
796
797                         if [ $res -ne 0 ]; then
798                                 __log_test_fail_body
799                                 return 1
800                         fi
801                 fi
802         else
803                 if [ $# -eq 7 ]; then
804                         body=${res:0:${#res}-3}
805
806                         if [ -f $7 ]; then
807                                 jobfile=$(cat $7)
808                                 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
809                         else
810                                 __log_test_fail_general "Job template file "$6", does not exist"
811                                 return 1
812                         fi
813                         targetJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
814                         echo " TARGET JSON: $targetJson" >> $HTTPLOG
815                         res=$(python3 ../common/compare_json.py "$targetJson" "$body")
816
817                         if [ $res -ne 0 ]; then
818                                 __log_test_fail_body
819                                 return 1
820                         fi
821                 fi
822         fi
823
824         __log_test_pass
825         return 0
826 }
827
828 # API Test function: DELETE â€‹/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
829 # args: <response-code> <type-id> <job-id>
830 # args (flat uri structure): <response-code> <job-id>
831 # (Function for test scripts)
832 ecs_api_a1_delete_job() {
833         __log_test_start $@
834
835         if [  -z "$FLAT_A1_EI" ]; then
836                 if [ $# -ne 3 ]; then
837                         __print_err "<response-code> <type-id> <job-id>" $@
838                         return 1
839                 fi
840
841                 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
842         else
843                 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
844                 if [ $# -ne 2 ]; then
845                         __print_err "<response-code> <job-id>" $@
846                         return 1
847                 fi
848                 query="/A1-EI/v1/eijobs/$2"
849         fi
850     res="$(__do_curl_to_api ECS DELETE $query)"
851     status=${res:${#res}-3}
852
853         if [ $status -ne $1 ]; then
854                 __log_test_fail_status_code $1 $status
855                 return 1
856         fi
857
858         __log_test_pass
859         return 0
860 }
861
862 # API Test function: PUT â€‹/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}
863 # args: <response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>
864 # args (flat uri structure): <response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file>
865 # (Function for test scripts)
866 ecs_api_a1_put_job() {
867         __log_test_start $@
868
869         if [  -z "$FLAT_A1_EI" ]; then
870                 if [ $# -lt 6 ]; then
871                         __print_err "<response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>" $@
872                         return 1
873                 fi
874                 if [ -f $6 ]; then
875                         jobfile=$(cat $6)
876                         jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
877                 else
878                         __log_test_fail_general "Job template file "$6", does not exist"
879                         return 1
880                 fi
881
882                 inputJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
883                 file="./tmp/.p.json"
884                 echo "$inputJson" > $file
885
886                 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
887         else
888                 echo -e $YELLOW"INTERFACE - FLAT URI STRUCTURE"$EYELLOW
889                 if [ $# -lt 7 ]; then
890                         __print_err "<response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file>" $@
891                         return 1
892                 fi
893                 if [ -f $7 ]; then
894                         jobfile=$(cat $7)
895                         jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
896                 else
897                         __log_test_fail_general "Job template file "$7", does not exist"
898                         return 1
899                 fi
900
901                 inputJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
902                 file="./tmp/.p.json"
903                 echo "$inputJson" > $file
904
905                 query="/A1-EI/v1/eijobs/$2"
906         fi
907
908     res="$(__do_curl_to_api ECS PUT $query $file)"
909     status=${res:${#res}-3}
910
911         if [ $status -ne $1 ]; then
912                 __log_test_fail_status_code $1 $status
913                 return 1
914         fi
915
916         __log_test_pass
917         return 0
918 }
919
920
921 ##########################################
922 ####   Enrichment Data Producer API   ####
923 ##########################################
924 # Function prefix: ecs_api_edp
925
926 # API Test function: GET /ei-producer/v1/eitypes
927 # API Test function: GET /data-producer/v1/info-types
928 # args: <response-code> [ EMPTY | <type-id>+]
929 # (Function for test scripts)
930 ecs_api_edp_get_type_ids() {
931         __log_test_start $@
932
933     if [ $# -lt 1 ]; then
934                 __print_err "<response-code> [ EMPTY | <type-id>+]" $@
935                 return 1
936         fi
937         if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
938                 query="/data-producer/v1/info-types"
939         else
940                 query="/ei-producer/v1/eitypes"
941         fi
942     res="$(__do_curl_to_api ECS GET $query)"
943     status=${res:${#res}-3}
944
945         if [ $status -ne $1 ]; then
946                 __log_test_fail_status_code $1 $status
947                 return 1
948         fi
949
950         if [ $# -gt 1 ]; then
951                 body=${res:0:${#res}-3}
952                 targetJson="["
953                 if [ $2 != "EMPTY" ]; then
954                         for pid in ${@:2} ; do
955                                 if [ "$targetJson" != "[" ]; then
956                                         targetJson=$targetJson","
957                                 fi
958                                 targetJson=$targetJson"\"$pid\""
959                         done
960                 fi
961                 targetJson=$targetJson"]"
962                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
963                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
964
965                 if [ $res -ne 0 ]; then
966                         __log_test_fail_body
967                         return 1
968                 fi
969         fi
970
971         __log_test_pass
972         return 0
973 }
974
975 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/status
976 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}/status
977 # args: <response-code> <producer-id> [<status> [<timeout>]]
978 # (Function for test scripts)
979 ecs_api_edp_get_producer_status() {
980         __log_test_start $@
981
982     if [ $# -lt 2 ] || [ $# -gt 4 ]; then
983                 __print_err "<response-code> <producer-id> [<status> [<timeout>]]" $@
984                 return 1
985         fi
986         if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
987                 query="/data-producer/v1/info-producers/$2/status"
988         else
989                 query="/ei-producer/v1/eiproducers/$2/status"
990         fi
991         start=$SECONDS
992         for (( ; ; )); do
993                 res="$(__do_curl_to_api ECS GET $query)"
994                 status=${res:${#res}-3}
995
996                 if [ $# -eq 4 ]; then
997                         duration=$((SECONDS-start))
998                         echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
999                         if [ $duration -gt $4 ]; then
1000                                 echo ""
1001                                 duration=-1  #Last iteration
1002                         fi
1003                 else
1004                         duration=-1 #single test, no wait
1005                 fi
1006
1007                 if [ $status -ne $1 ]; then
1008                         if [ $duration -eq -1 ]; then
1009                                 __log_test_fail_status_code $1 $status
1010                                 return 1
1011                         fi
1012                 fi
1013                 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
1014                         body=${res:0:${#res}-3}
1015                         targetJson="{\"operational_state\": \"$3\"}"
1016                         echo " TARGET JSON: $targetJson" >> $HTTPLOG
1017                         res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1018
1019                         if [ $res -ne 0 ]; then
1020                                 if [ $duration -eq -1 ]; then
1021                                         __log_test_fail_body
1022                                         return 1
1023                                 fi
1024                         else
1025                                 duration=-1  #Goto pass
1026                         fi
1027                 fi
1028                 if [ $duration -eq -1 ]; then
1029                         if [ $# -eq 4 ]; then
1030                                 echo ""
1031                         fi
1032                         __log_test_pass
1033                         return 0
1034                 else
1035                         sleep 1
1036                 fi
1037         done
1038 }
1039
1040
1041 # API Test function: GET /ei-producer/v1/eiproducers
1042 # args (v1_1): <response-code> [ EMPTY | <producer-id>+]
1043 # (Function for test scripts)
1044 ecs_api_edp_get_producer_ids() {
1045         __log_test_start $@
1046
1047     if [ $# -lt 1 ]; then
1048                 __print_err "<response-code> [ EMPTY | <producer-id>+]" $@
1049                 return 1
1050         fi
1051
1052         query="/ei-producer/v1/eiproducers"
1053     res="$(__do_curl_to_api ECS GET $query)"
1054     status=${res:${#res}-3}
1055
1056         if [ $status -ne $1 ]; then
1057                 __log_test_fail_status_code $1 $status
1058                 return 1
1059         fi
1060
1061         if [ $# -gt 1 ]; then
1062                 body=${res:0:${#res}-3}
1063                 targetJson="["
1064
1065                 for pid in ${@:2} ; do
1066                         if [ "$targetJson" != "[" ]; then
1067                                 targetJson=$targetJson","
1068                         fi
1069                         if [ $pid != "EMPTY" ]; then
1070                                 targetJson=$targetJson"\"$pid\""
1071                         fi
1072                 done
1073
1074                 targetJson=$targetJson"]"
1075                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1076                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1077
1078                 if [ $res -ne 0 ]; then
1079                         __log_test_fail_body
1080                         return 1
1081                 fi
1082         fi
1083
1084         __log_test_pass
1085         return 0
1086 }
1087
1088 # API Test function: GET /ei-producer/v1/eiproducers
1089 # API Test function: GET /data-producer/v1/info-producers
1090 # args (v1_2): <response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]
1091 # (Function for test scripts)
1092 ecs_api_edp_get_producer_ids_2() {
1093         __log_test_start $@
1094
1095     if [ $# -lt 1 ]; then
1096                 __print_err "<response-code> [ ( NOTYPE | <type-id> ) [ EMPTY | <producer-id>+] ]" $@
1097                 return 1
1098         fi
1099     if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1100                 query="/data-producer/v1/info-producers"
1101                 if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then
1102                         query=$query"?info_type_id=$2"
1103                 fi
1104         else
1105                 query="/ei-producer/v1/eiproducers"
1106                 if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then
1107                         query=$query"?ei_type_id=$2"
1108                 fi
1109         fi
1110     res="$(__do_curl_to_api ECS GET $query)"
1111     status=${res:${#res}-3}
1112
1113         if [ $status -ne $1 ]; then
1114                 __log_test_fail_status_code $1 $status
1115                 return 1
1116         fi
1117
1118         if [ $# -gt 2 ]; then
1119                 body=${res:0:${#res}-3}
1120                 targetJson="["
1121
1122                 for pid in ${@:3} ; do
1123                         if [ "$targetJson" != "[" ]; then
1124                                 targetJson=$targetJson","
1125                         fi
1126                         if [ $pid != "EMPTY" ]; then
1127                                 targetJson=$targetJson"\"$pid\""
1128                         fi
1129                 done
1130
1131                 targetJson=$targetJson"]"
1132                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1133                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1134
1135                 if [ $res -ne 0 ]; then
1136                         __log_test_fail_body
1137                         return 1
1138                 fi
1139         fi
1140
1141         __log_test_pass
1142         return 0
1143 }
1144
1145 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
1146 # args: (v1_1) <response-code> <type-id> [<job-schema-file> (EMPTY | [<producer-id>]+)]
1147 # (Function for test scripts)
1148 ecs_api_edp_get_type() {
1149         __log_test_start $@
1150
1151         paramError=1
1152         if [ $# -eq 2 ]; then
1153                 paramError=0
1154         fi
1155         if [ $# -gt 3 ]; then
1156                 paramError=0
1157         fi
1158     if [ $paramError -ne 0 ]; then
1159                 __print_err "<response-code> <type-id> [<job-schema-file> 'EMPTY' | ([<producer-id>]+)]" $@
1160                 return 1
1161         fi
1162
1163         query="/ei-producer/v1/eitypes/$2"
1164     res="$(__do_curl_to_api ECS GET $query)"
1165     status=${res:${#res}-3}
1166
1167         if [ $status -ne $1 ]; then
1168                 __log_test_fail_status_code $1 $status
1169                 return 1
1170         fi
1171         if [ $# -gt 3 ]; then
1172                 body=${res:0:${#res}-3}
1173
1174                 if [ -f $3 ]; then
1175                         schema=$(cat $3)
1176                 else
1177                         __log_test_fail_general "Job template file "$3", does not exist"
1178                         return 1
1179                 fi
1180
1181                 targetJson=""
1182                 if [ $4 != "EMPTY" ]; then
1183                         for pid in ${@:4} ; do
1184                                 if [ "$targetJson" != "" ]; then
1185                                         targetJson=$targetJson","
1186                                 fi
1187                                 targetJson=$targetJson"\"$pid\""
1188                         done
1189                 fi
1190                 targetJson="{\"ei_job_data_schema\":$schema, \"ei_producer_ids\": [$targetJson]}"
1191
1192                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1193                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1194
1195                 if [ $res -ne 0 ]; then
1196                         __log_test_fail_body
1197                         return 1
1198                 fi
1199         fi
1200         __log_test_pass
1201         return 0
1202 }
1203
1204 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
1205 # API Test function: GET /data-producer/v1/info-types/{infoTypeId}
1206 # args: (v1_2) <response-code> <type-id> [<job-schema-file> [ <info-type-info> ]]
1207 # (Function for test scripts)
1208 ecs_api_edp_get_type_2() {
1209         __log_test_start $@
1210
1211         paramError=1
1212         if [ $# -eq 2 ]; then
1213                 paramError=0
1214         fi
1215         if [ $# -eq 3 ]; then
1216                 paramError=0
1217         fi
1218         if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then
1219                 if [ $# -eq 4 ]; then
1220                         paramError=0
1221                 fi
1222         fi
1223     if [ $paramError -ne 0 ]; then
1224                 __print_err "<response-code> <type-id> [<job-schema-file> [ <info-type-info> ]]" $@
1225                 return 1
1226         fi
1227         if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1228                 query="/data-producer/v1/info-types/$2"
1229         else
1230                 query="/ei-producer/v1/eitypes/$2"
1231         fi
1232
1233     res="$(__do_curl_to_api ECS GET $query)"
1234     status=${res:${#res}-3}
1235
1236         if [ $status -ne $1 ]; then
1237                 __log_test_fail_status_code $1 $status
1238                 return 1
1239         fi
1240         if [ $# -ge 3 ]; then
1241                 body=${res:0:${#res}-3}
1242
1243                 if [ -f $3 ]; then
1244                         schema=$(cat $3)
1245                 else
1246                         __log_test_fail_general "Job template file "$3", does not exist"
1247                         return 1
1248                 fi
1249                 info_data=""
1250                 if [ $# -gt 3 ]; then
1251                         if [ -f $4 ]; then
1252                                 info_data=$(cat $4)
1253                         else
1254                                 __log_test_fail_general "Info-data file "$4", does not exist"
1255                                 return 1
1256                         fi
1257                         info_data=",\"info_type_information\":$info_data"
1258                 fi
1259                 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1260                         targetJson="{\"info_job_data_schema\":$schema $info_data}"
1261                 else
1262                         targetJson="{\"ei_job_data_schema\":$schema}"
1263                 fi
1264
1265                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1266                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1267
1268                 if [ $res -ne 0 ]; then
1269                         __log_test_fail_body
1270                         return 1
1271                 fi
1272         fi
1273         __log_test_pass
1274         return 0
1275 }
1276
1277 # API Test function: PUT /ei-producer/v1/eitypes/{eiTypeId}
1278 # API Test function: PUT /data-producer/v1/info-types/{infoTypeId}
1279 # args: (v1_2) <response-code> <type-id> <job-schema-file> [ <info-type-info> ]
1280 # (Function for test scripts)
1281 ecs_api_edp_put_type_2() {
1282         __log_test_start $@
1283
1284         if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then
1285                 if [ $# -lt 3 ] || [ $# -gt 4 ]; then
1286                         __print_err "<response-code> <type-id> <job-schema-file> [ <info-type-info> ]" $@
1287                         return 1
1288                 fi
1289         else
1290                 if [ $# -ne 3 ]; then
1291                         __print_err "<response-code> <type-id> <job-schema-file>" $@
1292                         return 1
1293                 fi
1294         fi
1295
1296         if [ ! -f $3 ]; then
1297                 __log_test_fail_general "Job schema file "$3", does not exist"
1298                 return 1
1299         fi
1300
1301         info_data=""
1302         if [ $# -gt 3 ]; then
1303                 if [ -f $4 ]; then
1304                         info_data=$(cat $4)
1305                 else
1306                         __log_test_fail_general "Info-data file "$4", does not exist"
1307                         return 1
1308                 fi
1309                 info_data=",\"info_type_information\":$info_data"
1310         fi
1311
1312         if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1313                 schema=$(cat $3)
1314                 input_json="{\"info_job_data_schema\":$schema $info_data}"
1315                 file="./tmp/put_type.json"
1316                 echo $input_json > $file
1317
1318                 query="/data-producer/v1/info-types/$2"
1319         else
1320                 schema=$(cat $3)
1321                 input_json="{\"ei_job_data_schema\":$schema}"
1322                 file="./tmp/put_type.json"
1323                 echo $input_json > $file
1324
1325                 query="/ei-producer/v1/eitypes/$2"
1326         fi
1327     res="$(__do_curl_to_api ECS PUT $query $file)"
1328     status=${res:${#res}-3}
1329
1330         if [ $status -ne $1 ]; then
1331                 __log_test_fail_status_code $1 $status
1332                 return 1
1333         fi
1334
1335         __log_test_pass
1336         return 0
1337 }
1338
1339 # API Test function: DELETE /ei-producer/v1/eitypes/{eiTypeId}
1340 # API Test function: DELETE /data-producer/v1/info-types/{infoTypeId}
1341 # args: (v1_2) <response-code> <type-id>
1342 # (Function for test scripts)
1343 ecs_api_edp_delete_type_2() {
1344         __log_test_start $@
1345
1346     if [ $# -ne 2 ]; then
1347                 __print_err "<response-code> <type-id>" $@
1348                 return 1
1349         fi
1350
1351         if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1352                 query="/data-producer/v1/info-types/$2"
1353         else
1354                 query="/ei-producer/v1/eitypes/$2"
1355         fi
1356     res="$(__do_curl_to_api ECS DELETE $query)"
1357     status=${res:${#res}-3}
1358
1359         if [ $status -ne $1 ]; then
1360                 __log_test_fail_status_code $1 $status
1361                 return 1
1362         fi
1363
1364         __log_test_pass
1365         return 0
1366 }
1367
1368 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
1369 # args: (v1_1) <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | [<type-id> <schema-file>]+) ]
1370 # (Function for test scripts)
1371 ecs_api_edp_get_producer() {
1372         __log_test_start $@
1373
1374         #Possible arg count: 2, 5 6, 8, 10 etc
1375         paramError=1
1376         if [ $# -eq 2 ]; then
1377                 paramError=0
1378         fi
1379         if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then
1380                 paramError=0
1381         fi
1382         variablecount=$(($#-4))
1383         if [ $# -gt 5 ] && [ $(($variablecount%2)) -eq 0 ]; then
1384                 paramError=0
1385         fi
1386
1387     if [ $paramError -ne 0 ]; then
1388                 __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (NOID | [<type-id> <schema-file>]+) ]" $@
1389                 return 1
1390         fi
1391
1392         query="/ei-producer/v1/eiproducers/$2"
1393     res="$(__do_curl_to_api ECS GET $query)"
1394     status=${res:${#res}-3}
1395
1396         if [ $status -ne $1 ]; then
1397                 __log_test_fail_status_code $1 $status
1398                 return 1
1399         fi
1400
1401         if [ $# -gt 2 ]; then
1402                 body=${res:0:${#res}-3}
1403                 targetJson="["
1404                 if [ $# -gt 5 ]; then
1405                         arr=(${@:5})
1406                         for ((i=0; i<$(($#-5)); i=i+2)); do
1407                                 if [ "$targetJson" != "[" ]; then
1408                                         targetJson=$targetJson","
1409                                 fi
1410                                 if [ -f ${arr[$i+1]} ]; then
1411                                         schema=$(cat ${arr[$i+1]})
1412                                 else
1413                                         __log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
1414                                         return 1
1415                                 fi
1416
1417                                 targetJson=$targetJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
1418                         done
1419                 fi
1420                 targetJson=$targetJson"]"
1421                 if [ $# -gt 4 ]; then
1422                         targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
1423                 fi
1424                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1425                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1426
1427                 if [ $res -ne 0 ]; then
1428                         __log_test_fail_body
1429                         return 1
1430                 fi
1431         fi
1432
1433         __log_test_pass
1434         return 0
1435 }
1436
1437 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
1438 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}
1439 # args (v1_2): <response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]
1440 # (Function for test scripts)
1441 ecs_api_edp_get_producer_2() {
1442         __log_test_start $@
1443
1444         #Possible arg count: 2, 5, 6, 7, 8 etc
1445         paramError=1
1446         if [ $# -eq 2 ]; then
1447                 paramError=0
1448         fi
1449         if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then
1450                 paramError=0
1451         fi
1452         if [ $# -ge 5 ]; then
1453                 paramError=0
1454         fi
1455
1456     if [ $paramError -ne 0 ]; then
1457                 __print_err "<response-code> <producer-id> [<job-callback> <supervision-callback> (EMPTY | <type-id>+) ]" $@
1458                 return 1
1459         fi
1460         if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1461                 query="/data-producer/v1/info-producers/$2"
1462         else
1463                 query="/ei-producer/v1/eiproducers/$2"
1464         fi
1465     res="$(__do_curl_to_api ECS GET $query)"
1466     status=${res:${#res}-3}
1467
1468         if [ $status -ne $1 ]; then
1469                 __log_test_fail_status_code $1 $status
1470                 return 1
1471         fi
1472
1473         if [ $# -gt 2 ]; then
1474                 body=${res:0:${#res}-3}
1475                 targetJson="["
1476                 if [ $# -gt 4 ] && [ "$5" != "EMPTY" ]; then
1477                         arr=(${@:5})
1478                         for ((i=0; i<$(($#-4)); i=i+1)); do
1479                                 if [ "$targetJson" != "[" ]; then
1480                                         targetJson=$targetJson","
1481                                 fi
1482                                 targetJson=$targetJson"\"${arr[$i]}\""
1483                         done
1484                 fi
1485                 targetJson=$targetJson"]"
1486                 if [ $# -gt 4 ]; then
1487                         if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1488                                 targetJson="{\"supported_info_types\":$targetJson,\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\"}"
1489                         else
1490                                 targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}"
1491                         fi
1492                 fi
1493                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1494                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1495
1496                 if [ $res -ne 0 ]; then
1497                         __log_test_fail_body
1498                         return 1
1499                 fi
1500         fi
1501
1502         __log_test_pass
1503         return 0
1504 }
1505
1506 # API Test function: DELETE /ei-producer/v1/eiproducers/{eiProducerId}
1507 # API Test function: DELETE /data-producer/v1/info-producers/{infoProducerId}
1508 # args: <response-code> <producer-id>
1509 # (Function for test scripts)
1510 ecs_api_edp_delete_producer() {
1511         __log_test_start $@
1512
1513     if [ $# -lt 2 ]; then
1514                 __print_err "<response-code> <producer-id>" $@
1515                 return 1
1516         fi
1517         if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1518                 query="/data-producer/v1/info-producers/$2"
1519         else
1520                 query="/ei-producer/v1/eiproducers/$2"
1521         fi
1522     res="$(__do_curl_to_api ECS DELETE $query)"
1523     status=${res:${#res}-3}
1524
1525         if [ $status -ne $1 ]; then
1526                 __log_test_fail_status_code $1 $status
1527                 return 1
1528         fi
1529
1530         __log_test_pass
1531         return 0
1532 }
1533
1534 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
1535 # args: (v1_1) <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+
1536 # (Function for test scripts)
1537 ecs_api_edp_put_producer() {
1538         __log_test_start $@
1539
1540         #Valid number of parametrer 5,6,8,10,
1541         paramError=1
1542         if  [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then
1543                 paramError=0
1544         elif [ $# -gt 5 ] && [ $(($#%2)) -eq 0 ]; then
1545                 paramError=0
1546         fi
1547         if [ $paramError -ne 0 ]; then
1548                 __print_err "<response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+" $@
1549                 return 1
1550         fi
1551
1552         inputJson="["
1553         if [ $# -gt 5 ]; then
1554                 arr=(${@:5})
1555                 for ((i=0; i<$(($#-5)); i=i+2)); do
1556                         if [ "$inputJson" != "[" ]; then
1557                                 inputJson=$inputJson","
1558                         fi
1559                         if [ -f ${arr[$i+1]} ]; then
1560                                 schema=$(cat ${arr[$i+1]})
1561                         else
1562                                 __log_test_fail_general "Schema file "${arr[$i+1]}", does not exist"
1563                                 return 1
1564                         fi
1565                         inputJson=$inputJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
1566                 done
1567         fi
1568         inputJson="\"supported_ei_types\":"$inputJson"]"
1569
1570         inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
1571
1572         inputJson="{"$inputJson"}"
1573
1574         file="./tmp/.p.json"
1575         echo "$inputJson" > $file
1576         query="/ei-producer/v1/eiproducers/$2"
1577     res="$(__do_curl_to_api ECS PUT $query $file)"
1578     status=${res:${#res}-3}
1579
1580         if [ $status -ne $1 ]; then
1581                 __log_test_fail_status_code $1 $status
1582                 return 1
1583         fi
1584
1585         __log_test_pass
1586         return 0
1587 }
1588
1589 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
1590 # API Test function: PUT /data-producer/v1/info-producers/{infoProducerId}
1591 # args: (v1_2) <response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]
1592 # (Function for test scripts)
1593 ecs_api_edp_put_producer_2() {
1594         __log_test_start $@
1595
1596         #Valid number of parametrer 5,6,8,10,
1597         paramError=1
1598         if  [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then
1599                 paramError=0
1600         elif [ $# -ge 5 ]; then
1601                 paramError=0
1602         fi
1603         if [ $paramError -ne 0 ]; then
1604                 __print_err "<response-code> <producer-id> <job-callback> <supervision-callback> NOTYPE|[<type-id>+]" $@
1605                 return 1
1606         fi
1607
1608         inputJson="["
1609         if [ $# -gt 4 ] && [ "$5" != "NOTYPE" ]; then
1610                 arr=(${@:5})
1611                 for ((i=0; i<$(($#-4)); i=i+1)); do
1612                         if [ "$inputJson" != "[" ]; then
1613                                 inputJson=$inputJson","
1614                         fi
1615                         inputJson=$inputJson"\""${arr[$i]}"\""
1616                 done
1617         fi
1618         if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1619                 inputJson="\"supported_info_types\":"$inputJson"]"
1620
1621                 inputJson=$inputJson",\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\""
1622
1623                 inputJson="{"$inputJson"}"
1624
1625                 file="./tmp/.p.json"
1626                 echo "$inputJson" > $file
1627                 query="/data-producer/v1/info-producers/$2"
1628         else
1629                 inputJson="\"supported_ei_types\":"$inputJson"]"
1630
1631                 inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\""
1632
1633                 inputJson="{"$inputJson"}"
1634
1635                 file="./tmp/.p.json"
1636                 echo "$inputJson" > $file
1637                 query="/ei-producer/v1/eiproducers/$2"
1638         fi
1639     res="$(__do_curl_to_api ECS PUT $query $file)"
1640     status=${res:${#res}-3}
1641
1642         if [ $status -ne $1 ]; then
1643                 __log_test_fail_status_code $1 $status
1644                 return 1
1645         fi
1646
1647         __log_test_pass
1648         return 0
1649 }
1650
1651 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
1652 # args: (V1-1) <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)
1653 # (Function for test scripts)
1654 ecs_api_edp_get_producer_jobs() {
1655         __log_test_start $@
1656
1657         #Valid number of parameter 2,3,7,11
1658         paramError=1
1659         if [ $# -eq 2 ]; then
1660                 paramError=0
1661         fi
1662         if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
1663                 paramError=0
1664         fi
1665         variablecount=$(($#-2))
1666         if [ $# -gt 3 ] && [ $(($variablecount%5)) -eq 0 ]; then
1667                 paramError=0
1668         fi
1669         if [ $paramError -eq 1 ]; then
1670                 __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)" $@
1671                 return 1
1672         fi
1673
1674         query="/ei-producer/v1/eiproducers/$2/eijobs"
1675     res="$(__do_curl_to_api ECS GET $query)"
1676     status=${res:${#res}-3}
1677         if [ $status -ne $1 ]; then
1678                 __log_test_fail_status_code $1 $status
1679                 return 1
1680         fi
1681         if [ $# -gt 2 ]; then
1682                 body=${res:0:${#res}-3}
1683                 targetJson="["
1684                 if [ $# -gt 3 ]; then
1685                         arr=(${@:3})
1686                         for ((i=0; i<$(($#-3)); i=i+5)); do
1687                                 if [ "$targetJson" != "[" ]; then
1688                                         targetJson=$targetJson","
1689                                 fi
1690                                 if [ -f ${arr[$i+4]} ]; then
1691                                         jobfile=$(cat ${arr[$i+4]})
1692                                         jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
1693                                 else
1694                                         __log_test_fail_general "Job template file "${arr[$i+4]}", does not exist"
1695                                         return 1
1696                                 fi
1697                                 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}"
1698                         done
1699                 fi
1700                 targetJson=$targetJson"]"
1701
1702                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1703                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1704
1705                 if [ $res -ne 0 ]; then
1706                         __log_test_fail_body
1707                         return 1
1708                 fi
1709         fi
1710
1711         __log_test_pass
1712         return 0
1713 }
1714
1715 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
1716 # API Test function: GET /data-producer/v1/info-producers/{infoProducerId}/info-jobs
1717 # args: (V1-2) <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)
1718 # (Function for test scripts)
1719 ecs_api_edp_get_producer_jobs_2() {
1720         __log_test_start $@
1721
1722         #Valid number of parameter 2,3,7,11
1723         paramError=1
1724         if [ $# -eq 2 ]; then
1725                 paramError=0
1726         fi
1727         if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
1728                 paramError=0
1729         fi
1730         variablecount=$(($#-2))
1731         if [ $# -gt 3 ] && [ $(($variablecount%5)) -eq 0 ]; then
1732                 paramError=0
1733         fi
1734         if [ $paramError -eq 1 ]; then
1735                 __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <job-owner> <template-job-file>]+)" $@
1736                 return 1
1737         fi
1738         if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1739                 query="/data-producer/v1/info-producers/$2/info-jobs"
1740         else
1741                 query="/ei-producer/v1/eiproducers/$2/eijobs"
1742         fi
1743     res="$(__do_curl_to_api ECS GET $query)"
1744     status=${res:${#res}-3}
1745         if [ $status -ne $1 ]; then
1746                 __log_test_fail_status_code $1 $status
1747                 return 1
1748         fi
1749         if [ $# -gt 2 ]; then
1750                 body=${res:0:${#res}-3}
1751                 targetJson="["
1752                 if [ $# -gt 3 ]; then
1753                         arr=(${@:3})
1754                         for ((i=0; i<$(($#-3)); i=i+5)); do
1755                                 if [ "$targetJson" != "[" ]; then
1756                                         targetJson=$targetJson","
1757                                 fi
1758                                 if [ -f ${arr[$i+4]} ]; then
1759                                         jobfile=$(cat ${arr[$i+4]})
1760                                         jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
1761                                 else
1762                                         __log_test_fail_general "Job template file "${arr[$i+4]}", does not exist"
1763                                         return 1
1764                                 fi
1765                                 if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
1766                                         targetJson=$targetJson"{\"info_job_identity\":\"${arr[$i]}\",\"info_type_identity\":\"${arr[$i+1]}\",\"target_uri\":\"${arr[$i+2]}\",\"owner\":\"${arr[$i+3]}\",\"info_job_data\":$jobfile, \"last_updated\":\"????\"}"
1767                                 else
1768                                         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\":\"????\"}"
1769                                 fi
1770                         done
1771                 fi
1772                 targetJson=$targetJson"]"
1773
1774                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1775                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1776
1777                 if [ $res -ne 0 ]; then
1778                         __log_test_fail_body
1779                         return 1
1780                 fi
1781         fi
1782
1783         __log_test_pass
1784         return 0
1785 }
1786
1787 ##########################################
1788 ####          Service status          ####
1789 ##########################################
1790 # Function prefix: ecs_api_service
1791
1792 # API Test function: GET â€‹/status
1793 # args: <response-code>
1794 # (Function for test scripts)
1795 ecs_api_service_status() {
1796         __log_test_start $@
1797
1798     if [ $# -lt 1 ]; then
1799                 __print_err "<response-code>" $@
1800                 return 1
1801         fi
1802         res="$(__do_curl_to_api ECS GET /status)"
1803     status=${res:${#res}-3}
1804         if [ $status -ne $1 ]; then
1805                 __log_test_fail_status_code $1 $status
1806                 return 1
1807         fi
1808         __log_test_pass
1809         return 0
1810 }
1811
1812 ###########################################
1813 ######### Info data consumer API ##########
1814 ###########################################
1815 #Function prefix: ecs_api_idc
1816
1817
1818 # API Test function: GET /data-consumer/v1/info-types
1819 # args: <response-code> [ (EMPTY | [<type-id>]+) ]
1820 # (Function for test scripts)
1821 ecs_api_idc_get_type_ids() {
1822         __log_test_start $@
1823
1824     if [ $# -lt 1 ]; then
1825                 __print_err "<response-code> [ (EMPTY | [<type-id>]+) ]" $@
1826                 return 1
1827         fi
1828
1829         query="/data-consumer/v1/info-types"
1830     res="$(__do_curl_to_api ECS GET $query)"
1831     status=${res:${#res}-3}
1832
1833         if [ $status -ne $1 ]; then
1834                 __log_test_fail_status_code $1 $status
1835                 return 1
1836         fi
1837         if [ $# -gt 1 ]; then
1838                 body=${res:0:${#res}-3}
1839                 targetJson="["
1840                 if [ $2 != "EMPTY" ]; then
1841                         for pid in ${@:2} ; do
1842                                 if [ "$targetJson" != "[" ]; then
1843                                         targetJson=$targetJson","
1844                                 fi
1845                                 targetJson=$targetJson"\"$pid\""
1846                         done
1847                 fi
1848                 targetJson=$targetJson"]"
1849                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1850                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1851
1852                 if [ $res -ne 0 ]; then
1853                         __log_test_fail_body
1854                         return 1
1855                 fi
1856         fi
1857
1858         __log_test_pass
1859         return 0
1860 }
1861
1862 # API Test function: GET /data-consumer/v1/info-jobs
1863 # args: <response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
1864 # (Function for test scripts)
1865 ecs_api_idc_get_job_ids() {
1866         __log_test_start $@
1867
1868         # Valid number of parameters 4,5,6 etc
1869         if [ $# -lt 3 ]; then
1870                 __print_err "<response-code> <type-id>|NOTYPE  <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
1871                 return 1
1872         fi
1873         search=""
1874         if [ $3 != "NOWNER" ]; then
1875                 search="?owner="$3
1876         fi
1877
1878         if [ $2 != "NOTYPE" ]; then
1879                 if [ -z "$search" ]; then
1880                         search="?infoTypeId="$2
1881                 else
1882                         search=$search"&infoTypeId="$2
1883                 fi
1884         fi
1885         query="/data-consumer/v1/info-jobs$search"
1886
1887     res="$(__do_curl_to_api ECS GET $query)"
1888     status=${res:${#res}-3}
1889
1890         if [ $status -ne $1 ]; then
1891                 __log_test_fail_status_code $1 $status
1892                 return 1
1893         fi
1894
1895         if [ $# -gt 3 ]; then
1896                 body=${res:0:${#res}-3}
1897                 targetJson="["
1898
1899                 for pid in ${@:4} ; do
1900                         if [ "$targetJson" != "[" ]; then
1901                                 targetJson=$targetJson","
1902                         fi
1903                         if [ $pid != "EMPTY" ]; then
1904                                 targetJson=$targetJson"\"$pid\""
1905                         fi
1906                 done
1907
1908                 targetJson=$targetJson"]"
1909                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1910                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1911
1912                 if [ $res -ne 0 ]; then
1913                         __log_test_fail_body
1914                         return 1
1915                 fi
1916         fi
1917
1918         __log_test_pass
1919         return 0
1920 }
1921
1922 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}
1923 # args: <response-code> <job-id> [<type-id> <target-url> <owner-id> <template-job-file>]
1924 # (Function for test scripts)
1925 ecs_api_idc_get_job() {
1926         __log_test_start $@
1927
1928         if [ $# -ne 2 ] && [ $# -ne 7 ]; then
1929                 __print_err "<response-code> <job-id> [<type-id> <target-url> <owner-id> <notification-url> <template-job-file>]" $@
1930                 return 1
1931         fi
1932         query="/data-consumer/v1/info-jobs/$2"
1933     res="$(__do_curl_to_api ECS GET $query)"
1934     status=${res:${#res}-3}
1935
1936         if [ $status -ne $1 ]; then
1937                 __log_test_fail_status_code $1 $status
1938                 return 1
1939         fi
1940
1941         if [ $# -eq 7 ]; then
1942                 body=${res:0:${#res}-3}
1943
1944                 if [ -f $7 ]; then
1945                         jobfile=$(cat $7)
1946                         jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
1947                 else
1948                         __log_test_fail_general "Job template file "$6", does not exist"
1949                         return 1
1950                 fi
1951                 targetJson="{\"info_type_id\": \"$3\", \"job_result_uri\": \"$4\",\"job_owner\": \"$5\",\"status_notification_uri\": \"$6\",\"job_definition\": $jobfile}"
1952                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
1953                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
1954
1955                 if [ $res -ne 0 ]; then
1956                         __log_test_fail_body
1957                         return 1
1958                 fi
1959         fi
1960
1961         __log_test_pass
1962         return 0
1963 }
1964
1965
1966 # API Test function: PUT â€‹/data-consumer/v1/info-jobs/{infoJobId}
1967 # args: <response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file> [ VALIDATE ]
1968 # (Function for test scripts)
1969 ecs_api_idc_put_job() {
1970         __log_test_start $@
1971
1972         if [ $# -lt 7 ] || [ $# -gt 8 ]; then
1973                 __print_err "<response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file> [ VALIDATE ]" $@
1974                 return 1
1975         fi
1976         if [ -f $7 ]; then
1977                 jobfile=$(cat $7)
1978                 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
1979         else
1980                 __log_test_fail_general "Job template file "$7", does not exist"
1981                 return 1
1982         fi
1983
1984         inputJson="{\"info_type_id\": \"$3\", \"job_result_uri\": \"$4\",\"job_owner\": \"$5\",\"status_notification_uri\": \"$6\",\"job_definition\": $jobfile}"
1985         file="./tmp/.p.json"
1986         echo "$inputJson" > $file
1987
1988         query="/data-consumer/v1/info-jobs/$2"
1989
1990         if [ $# -eq 8 ]; then
1991                 if [ $8 == "VALIDATE" ]; then
1992                         query=$query"?typeCheck=true"
1993                 fi
1994         fi
1995
1996     res="$(__do_curl_to_api ECS PUT $query $file)"
1997     status=${res:${#res}-3}
1998
1999         if [ $status -ne $1 ]; then
2000                 __log_test_fail_status_code $1 $status
2001                 return 1
2002         fi
2003
2004         __log_test_pass
2005         return 0
2006 }
2007
2008 # API Test function: DELETE â€‹/data-consumer/v1/info-jobs/{infoJobId}
2009 # args: <response-code> <job-id>
2010 # (Function for test scripts)
2011 ecs_api_idc_delete_job() {
2012         __log_test_start $@
2013
2014         if [ $# -ne 2 ]; then
2015                 __print_err "<response-code> <job-id>" $@
2016                 return 1
2017         fi
2018         query="/data-consumer/v1/info-jobs/$2"
2019     res="$(__do_curl_to_api ECS DELETE $query)"
2020     status=${res:${#res}-3}
2021
2022         if [ $status -ne $1 ]; then
2023                 __log_test_fail_status_code $1 $status
2024                 return 1
2025         fi
2026
2027         __log_test_pass
2028         return 0
2029 }
2030
2031 # API Test function: GET â€‹/data-consumer/v1/info-types/{infoTypeId}
2032 # args: <response-code> <type-id> [<schema-file> [<type-status> <producers-count]]
2033 # (Function for test scripts)
2034 ecs_api_idc_get_type() {
2035         __log_test_start $@
2036
2037     if [ $# -lt 2 ] || [ $# -gt 5 ]; then
2038                 __print_err "<response-code> <type-id> [<schema-file> [<type-status> <producers-count]]" $@
2039                 return 1
2040         fi
2041
2042         query="/data-consumer/v1/info-types/$2"
2043     res="$(__do_curl_to_api ECS GET $query)"
2044     status=${res:${#res}-3}
2045
2046         if [ $status -ne $1 ]; then
2047                 __log_test_fail_status_code $1 $status
2048                 return 1
2049         fi
2050
2051         if [ $# -gt 2 ]; then
2052                 body=${res:0:${#res}-3}
2053                 if [ -f $3 ]; then
2054                         schema=$(cat $3)
2055                 else
2056                         __log_test_fail_general "Schema file "$3", does not exist"
2057                         return 1
2058                 fi
2059                 if [ $# -eq 5 ]; then
2060                         targetJson="{\"job_data_schema\":$schema, \"type_status\":\"$4\", \"no_of_producers\":$5}"
2061                 else
2062                         targetJson="{\"job_data_schema\":$schema}"
2063                 fi
2064                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2065                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2066
2067                 if [ $res -ne 0 ]; then
2068                         __log_test_fail_body
2069                         return 1
2070                 fi
2071         fi
2072
2073         __log_test_pass
2074         return 0
2075 }
2076
2077 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}/status
2078 # This test only status during an optional timeout. No test of the list of producers
2079 # args: <response-code> <job-id> [<status> [<timeout>]]
2080 # (Function for test scripts)
2081 ecs_api_idc_get_job_status() {
2082         __log_test_start $@
2083
2084         if [ $# -lt 2 ] && [ $# -gt 4 ]; then
2085                 __print_err "<response-code> <job-id> [<status> [<timeout>]]" $@
2086                 return 1
2087         fi
2088
2089         query="/data-consumer/v1/info-jobs/$2/status"
2090
2091         start=$SECONDS
2092         for (( ; ; )); do
2093                 res="$(__do_curl_to_api ECS GET $query)"
2094                 status=${res:${#res}-3}
2095
2096                 if [ $# -eq 4 ]; then
2097                         duration=$((SECONDS-start))
2098                         echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
2099                         if [ $duration -gt $4 ]; then
2100                                 echo ""
2101                                 duration=-1  #Last iteration
2102                         fi
2103                 else
2104                         duration=-1 #single test, no wait
2105                 fi
2106
2107                 if [ $status -ne $1 ]; then
2108                         if [ $duration -eq -1 ]; then
2109                                 __log_test_fail_status_code $1 $status
2110                                 return 1
2111                         fi
2112                 fi
2113                 if [ $# -ge 3 ] && [ $status -eq $1 ]; then
2114                         body=${res:0:${#res}-3}
2115                         targetJson="{\"info_job_status\": \"$3\"}"
2116                         echo " TARGET JSON: $targetJson" >> $HTTPLOG
2117                         res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2118
2119                         if [ $res -ne 0 ]; then
2120                                 if [ $duration -eq -1 ]; then
2121                                         __log_test_fail_body
2122                                         return 1
2123                                 fi
2124                         else
2125                                 duration=-1  #Goto pass
2126                         fi
2127                 fi
2128                 if [ $duration -eq -1 ]; then
2129                         if [ $# -eq 4 ]; then
2130                                 echo ""
2131                         fi
2132                         __log_test_pass
2133                         return 0
2134                 else
2135                         sleep 1
2136                 fi
2137         done
2138
2139         __log_test_pass
2140         return 0
2141 }
2142
2143 # API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}/status
2144 # This function test status and the list of producers with and optional timeout
2145 # args: <response-code> <job-id> [<status> EMPTYPROD|( <prod-count> <producer-id>+ ) [<timeout>]]
2146 # (Function for test scripts)
2147 ecs_api_idc_get_job_status2() {
2148
2149         __log_test_start $@
2150         param_error=0
2151         if [ $# -lt 2 ]; then
2152                 param_error=1
2153         fi
2154         args=("$@")
2155         timeout=0
2156         if [ $# -gt 2 ]; then
2157                 if [ $# -lt 4 ]; then
2158                         param_error=1
2159                 fi
2160                 targetJson="{\"info_job_status\": \"$3\""
2161                 if [ "$4" == "EMPTYPROD" ]; then
2162                         targetJson=$targetJson",\"producers\": []}"
2163                         if [ $# -gt 4 ]; then
2164                                 timeout=$5
2165                         fi
2166                 else
2167                         targetJson=$targetJson",\"producers\": ["
2168                         if [ $# -eq $(($4+5)) ]; then
2169                                 idx=$(($4+4))
2170                                 timeout=${args[$idx]}
2171                         fi
2172                         for ((ecs_i = 0 ; ecs_i < $4 ; ecs_i++)); do
2173                                 idx=$(($ecs_i+4))
2174                                 if [ $ecs_i -gt 0 ]; then
2175                                         targetJson=$targetJson","
2176                                 fi
2177                                 targetJson=$targetJson"\""${args[$idx]}"\""
2178                         done
2179                         targetJson=$targetJson"]}"
2180                 fi
2181         fi
2182
2183         if [ $param_error -ne 0 ]; then
2184                 __print_err "<response-code> <job-id> [<status> EMPTYPROD|( <prod-count> <producer-id>+ ) [<timeout>]]" $@
2185                 return 1
2186         fi
2187
2188         query="/data-consumer/v1/info-jobs/$2/status"
2189
2190         start=$SECONDS
2191         for (( ; ; )); do
2192                 res="$(__do_curl_to_api ECS GET $query)"
2193                 status=${res:${#res}-3}
2194
2195                 if [ $# -gt 2 ]; then
2196                         duration=$((SECONDS-start))
2197                         echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}"
2198                         if [ $duration -gt $timeout ]; then
2199                                 echo ""
2200                                 duration=-1  #Last iteration
2201                         fi
2202                 else
2203                         duration=-1 #single test, no wait
2204                 fi
2205
2206                 if [ $status -ne $1 ]; then
2207                         if [ $duration -eq -1 ]; then
2208                                 __log_test_fail_status_code $1 $status
2209                                 return 1
2210                         fi
2211                 fi
2212                 if [ $# -gt 2 ] && [ $status -eq $1 ]; then
2213                         body=${res:0:${#res}-3}
2214                         echo " TARGET JSON: $targetJson" >> $HTTPLOG
2215                         res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2216
2217                         if [ $res -ne 0 ]; then
2218                                 if [ $duration -eq -1 ]; then
2219                                         __log_test_fail_body
2220                                         return 1
2221                                 fi
2222                         else
2223                                 duration=-1  #Goto pass
2224                         fi
2225                 fi
2226                 if [ $duration -eq -1 ]; then
2227                         if [ $# -eq 4 ]; then
2228                                 echo ""
2229                         fi
2230                         __log_test_pass
2231                         return 0
2232                 else
2233                         sleep 1
2234                 fi
2235         done
2236
2237         __log_test_pass
2238         return 0
2239 }
2240
2241 ##########################################
2242 ####     Type subscriptions           ####
2243 ##########################################
2244
2245 # API Test function: GET /data-consumer/v1/info-type-subscription
2246 # args: <response-code>  <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]
2247 # (Function for test scripts)
2248 ecs_api_idc_get_subscription_ids() {
2249         __log_test_start $@
2250
2251     if [ $# -lt 3 ]; then
2252                 __print_err "<response-code> <owner-id>|NOOWNER [ EMPTY | <subscription-id>+]" $@
2253                 return 1
2254         fi
2255
2256         query="/data-consumer/v1/info-type-subscription"
2257         search=""
2258         if [ $2 != "NOOWNER" ]; then
2259                 search="?owner="$2
2260         fi
2261
2262     res="$(__do_curl_to_api ECS GET $query$search)"
2263     status=${res:${#res}-3}
2264
2265         if [ $status -ne $1 ]; then
2266                 __log_test_fail_status_code $1 $status
2267                 return 1
2268         fi
2269
2270         if [ $# -gt 2 ]; then
2271                 body=${res:0:${#res}-3}
2272                 targetJson="["
2273                 if [ $3 != "EMPTY" ]; then
2274                         for pid in ${@:3} ; do
2275                                 if [ "$targetJson" != "[" ]; then
2276                                         targetJson=$targetJson","
2277                                 fi
2278                                 targetJson=$targetJson"\"$pid\""
2279                         done
2280                 fi
2281                 targetJson=$targetJson"]"
2282                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2283                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2284
2285                 if [ $res -ne 0 ]; then
2286                         __log_test_fail_body
2287                         return 1
2288                 fi
2289         fi
2290
2291         __log_test_pass
2292         return 0
2293 }
2294
2295 # API Test function: GET /data-consumer/v1/info-type-subscription/{subscriptionId}
2296 # args: <response-code>  <subscription-id> [ <owner-id> <status-uri> ]
2297 # (Function for test scripts)
2298 ecs_api_idc_get_subscription() {
2299         __log_test_start $@
2300
2301     if [ $# -ne 2 ] && [ $# -ne 4 ]; then
2302                 __print_err "<response-code>  <subscription-id> [ <owner-id> <status-uri> ]" $@
2303                 return 1
2304         fi
2305
2306         query="/data-consumer/v1/info-type-subscription/$2"
2307     res="$(__do_curl_to_api ECS GET $query)"
2308     status=${res:${#res}-3}
2309
2310         if [ $status -ne $1 ]; then
2311                 __log_test_fail_status_code $1 $status
2312                 return 1
2313         fi
2314
2315         if [ $# -gt 2 ]; then
2316                 body=${res:0:${#res}-3}
2317                 targetJson="{\"owner\":\"$3\",\"status_result_uri\":\"$4\"}"
2318                 echo " TARGET JSON: $targetJson" >> $HTTPLOG
2319                 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
2320
2321                 if [ $res -ne 0 ]; then
2322                         __log_test_fail_body
2323                         return 1
2324                 fi
2325         fi
2326
2327         __log_test_pass
2328         return 0
2329 }
2330
2331 # API Test function: PUT /data-consumer/v1/info-type-subscription/{subscriptionId}
2332 # args: <response-code>  <subscription-id> <owner-id> <status-uri>
2333 # (Function for test scripts)
2334 ecs_api_idc_put_subscription() {
2335         __log_test_start $@
2336
2337     if [ $# -ne 4 ]; then
2338                 __print_err "<response-code>  <subscription-id> <owner-id> <status-uri>" $@
2339                 return 1
2340         fi
2341
2342         inputJson="{\"owner\": \"$3\",\"status_result_uri\": \"$4\"}"
2343         file="./tmp/.p.json"
2344         echo "$inputJson" > $file
2345
2346         query="/data-consumer/v1/info-type-subscription/$2"
2347     res="$(__do_curl_to_api ECS PUT $query $file)"
2348     status=${res:${#res}-3}
2349
2350         if [ $status -ne $1 ]; then
2351                 __log_test_fail_status_code $1 $status
2352                 return 1
2353         fi
2354
2355         __log_test_pass
2356         return 0
2357 }
2358
2359 # API Test function: DELETE /data-consumer/v1/info-type-subscription/{subscriptionId}
2360 # args: <response-code>  <subscription-id>
2361 # (Function for test scripts)
2362 ecs_api_idc_delete_subscription() {
2363         __log_test_start $@
2364
2365         if [ $# -ne 2 ]; then
2366                 __print_err "<response-code>  <subscription-id> " $@
2367                 return 1
2368         fi
2369
2370         query="/data-consumer/v1/info-type-subscription/$2"
2371     res="$(__do_curl_to_api ECS DELETE $query)"
2372     status=${res:${#res}-3}
2373
2374         if [ $status -ne $1 ]; then
2375                 __log_test_fail_status_code $1 $status
2376                 return 1
2377         fi
2378
2379         __log_test_pass
2380         return 0
2381 }
2382
2383 ##########################################
2384 ####          Reset jobs              ####
2385 ##########################################
2386 # Function prefix: ecs_api_admin
2387
2388 # Admin to remove all jobs
2389 # args: <response-code> [ <type> ]
2390 # (Function for test scripts)
2391
2392 ecs_api_admin_reset() {
2393         __log_test_start $@
2394
2395         if [  -z "$FLAT_A1_EI" ]; then
2396                 query="/A1-EI/v1/eitypes/$2/eijobs"
2397         else
2398                 query="/A1-EI/v1/eijobs"
2399         fi
2400     res="$(__do_curl_to_api ECS GET $query)"
2401     status=${res:${#res}-3}
2402
2403         if [ $status -ne 200 ]; then
2404                 __log_test_fail_status_code $1 $status
2405                 return 1
2406         fi
2407
2408         #Remove brackets and response code
2409         body=${res:1:${#res}-4}
2410         list=$(echo ${body//,/ })
2411         list=$(echo ${list//[/})
2412         list=$(echo ${list//]/})
2413         list=$(echo ${list//\"/})
2414         list=$list" "
2415         for job in $list; do
2416                 if [  -z "$FLAT_A1_EI" ]; then
2417                         echo "Not supported for non-flat EI api"
2418                 else
2419                         query="/A1-EI/v1/eijobs/$job"
2420                         res="$(__do_curl_to_api ECS DELETE $query)"
2421                         status=${res:${#res}-3}
2422                         if [ $status -ne 204 ]; then
2423                                 __log_test_fail_status_code $1 $status
2424                                 return 1
2425                         fi
2426                         echo " Deleted job: "$job
2427                 fi
2428         done
2429
2430         __log_test_pass
2431         return 0
2432 }
2433
2434 ##########################################
2435 ####     Reset jobs and producers     ####
2436 ##########################################
2437
2438
2439 # Admin reset to remove all data in ecs; jobs, producers etc
2440 # NOTE - only works in kubernetes and the pod should not be running
2441 # args: -
2442 # (Function for test scripts)
2443
2444 ecs_kube_pvc_reset() {
2445         __log_test_start $@
2446
2447         pvc_name=$(kubectl get pvc -n $KUBE_NONRTRIC_NAMESPACE  --no-headers -o custom-columns=":metadata.name" | grep enrichment)
2448         if [ -z "$pvc_name" ]; then
2449                 pvc_name=enrichmentservice-pvc
2450         fi
2451         echo " Trying to reset pvc: "$pvc_name
2452
2453         __kube_clean_pvc $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE $pvc_name $ECS_CONTAINER_MNT_DIR
2454
2455         __log_test_pass
2456         return 0
2457 }