X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fcommon%2Fecs_api_functions.sh;h=5ad1b98e67a9262813b928e65c5a4f624ae0c8c8;hb=a0e0e5c38053553393b341ccdd22e794babfafeb;hp=cf5f580f462e31b3606c09b6c1901ad2d64b3146;hpb=a0139337d35be172ae132bbf836859e41132860f;p=nonrtric.git diff --git a/test/common/ecs_api_functions.sh b/test/common/ecs_api_functions.sh index cf5f580f..5ad1b98e 100644 --- a/test/common/ecs_api_functions.sh +++ b/test/common/ecs_api_functions.sh @@ -185,7 +185,8 @@ start_ecs() { if [ $retcode_p -eq 0 ]; then echo -e " Using existing $ECS_APP_NAME deployment and service" echo " Setting ECS replicas=1" - __kube_scale deployment $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1 + res_type=$(__kube_get_resource_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE) + __kube_scale $res_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1 fi # Check if app shall be fully managed by the test script @@ -366,7 +367,8 @@ stop_ecs() { __check_prestarted_image "ECS" if [ $? -eq 0 ]; then 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 - __kube_scale deployment $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 0 + res_type=$(__kube_get_resource_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE) + __kube_scale $res_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 0 return 0 fi @@ -403,7 +405,8 @@ start_stopped_ecs() { __check_prestarted_image "ECS" if [ $? -eq 0 ]; then 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 - __kube_scale deployment $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1 + res_type=$(__kube_get_resource_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE) + __kube_scale $res_type $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1 __check_service_start $ECS_APP_NAME $ECS_PATH$ECS_ALIVE_URL return 0 fi @@ -806,7 +809,7 @@ ecs_api_a1_get_job() { jobfile=$(cat $6) jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g") else - _log_test_fail_general "Job template file "$6", does not exist" + __log_test_fail_general "Job template file "$6", does not exist" return 1 fi targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}" @@ -826,7 +829,7 @@ ecs_api_a1_get_job() { jobfile=$(cat $7) jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g") else - _log_test_fail_general "Job template file "$6", does not exist" + __log_test_fail_general "Job template file "$6", does not exist" return 1 fi targetJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}" @@ -894,7 +897,7 @@ ecs_api_a1_put_job() { jobfile=$(cat $6) jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g") else - _log_test_fail_general "Job template file "$6", does not exist" + __log_test_fail_general "Job template file "$6", does not exist" return 1 fi @@ -913,7 +916,7 @@ ecs_api_a1_put_job() { jobfile=$(cat $7) jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g") else - _log_test_fail_general "Job template file "$7", does not exist" + __log_test_fail_general "Job template file "$7", does not exist" return 1 fi @@ -943,6 +946,7 @@ ecs_api_a1_put_job() { # Function prefix: ecs_api_edp # API Test function: GET /ei-producer/v1/eitypes +# API Test function: GET /data-producer/v1/info-types # args: [ EMPTY | +] # (Function for test scripts) ecs_api_edp_get_type_ids() { @@ -952,8 +956,11 @@ ecs_api_edp_get_type_ids() { __print_err " [ EMPTY | +]" $@ return 1 fi - - query="/ei-producer/v1/eitypes" + if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then + query="/data-producer/v1/info-types" + else + query="/ei-producer/v1/eitypes" + fi res="$(__do_curl_to_api ECS GET $query)" status=${res:${#res}-3} @@ -988,6 +995,7 @@ ecs_api_edp_get_type_ids() { } # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/status +# API Test function: GET /data-producer/v1/info-producers/{infoProducerId}/status # args: [ []] # (Function for test scripts) ecs_api_edp_get_producer_status() { @@ -997,8 +1005,11 @@ ecs_api_edp_get_producer_status() { __print_err " [ []]" $@ return 1 fi - - query="/ei-producer/v1/eiproducers/$2/status" + if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then + query="/data-producer/v1/info-producers/$2/status" + else + query="/ei-producer/v1/eiproducers/$2/status" + fi start=$SECONDS for (( ; ; )); do res="$(__do_curl_to_api ECS GET $query)" @@ -1097,6 +1108,7 @@ ecs_api_edp_get_producer_ids() { } # API Test function: GET /ei-producer/v1/eiproducers +# API Test function: GET /data-producer/v1/info-producers # args (v1_2): [ ( NOTYPE | ) [ EMPTY | +] ] # (Function for test scripts) ecs_api_edp_get_producer_ids_2() { @@ -1106,10 +1118,16 @@ ecs_api_edp_get_producer_ids_2() { __print_err " [ ( NOTYPE | ) [ EMPTY | +] ]" $@ return 1 fi - - query="/ei-producer/v1/eiproducers" - if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then - query=$query"?ei_type_id=$2" + if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then + query="/data-producer/v1/info-producers" + if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then + query=$query"?info_type_id=$2" + fi + else + query="/ei-producer/v1/eiproducers" + if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then + query=$query"?ei_type_id=$2" + fi fi res="$(__do_curl_to_api ECS GET $query)" status=${res:${#res}-3} @@ -1206,6 +1224,7 @@ ecs_api_edp_get_type() { } # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId} +# API Test function: GET /data-producer/v1/info-types/{infoTypeId} # args: (v1_2) [ ] # (Function for test scripts) ecs_api_edp_get_type_2() { @@ -1222,8 +1241,12 @@ ecs_api_edp_get_type_2() { __print_err " [ ]" $@ return 1 fi + if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then + query="/data-producer/v1/info-types/$2" + else + query="/ei-producer/v1/eitypes/$2" + fi - query="/ei-producer/v1/eitypes/$2" res="$(__do_curl_to_api ECS GET $query)" status=${res:${#res}-3} @@ -1240,8 +1263,11 @@ ecs_api_edp_get_type_2() { __log_test_fail_general "Job template file "$3", does not exist" return 1 fi - - targetJson="{\"ei_job_data_schema\":$schema}" + if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then + targetJson="{\"info_job_data_schema\":$schema}" + else + targetJson="{\"ei_job_data_schema\":$schema}" + fi echo " TARGET JSON: $targetJson" >> $HTTPLOG res=$(python3 ../common/compare_json.py "$targetJson" "$body") @@ -1256,6 +1282,7 @@ ecs_api_edp_get_type_2() { } # API Test function: PUT /ei-producer/v1/eitypes/{eiTypeId} +# API Test function: PUT /data-producer/v1/info-types/{infoTypeId} # args: (v1_2) # (Function for test scripts) ecs_api_edp_put_type_2() { @@ -1270,12 +1297,21 @@ ecs_api_edp_put_type_2() { __log_test_fail_general "Job schema file "$3", does not exist" return 1 fi - schema=$(cat $3) - input_json="{\"ei_job_data_schema\":$schema}" - file="./tmp/put_type.json" - echo $input_json > $file + if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then + schema=$(cat $3) + input_json="{\"info_job_data_schema\":$schema}" + file="./tmp/put_type.json" + echo $input_json > $file - query="/ei-producer/v1/eitypes/$2" + query="/data-producer/v1/info-types/$2" + else + schema=$(cat $3) + input_json="{\"ei_job_data_schema\":$schema}" + file="./tmp/put_type.json" + echo $input_json > $file + + query="/ei-producer/v1/eitypes/$2" + fi res="$(__do_curl_to_api ECS PUT $query $file)" status=${res:${#res}-3} @@ -1289,6 +1325,7 @@ ecs_api_edp_put_type_2() { } # API Test function: DELETE /ei-producer/v1/eitypes/{eiTypeId} +# API Test function: DELETE /data-producer/v1/info-types/{infoTypeId} # args: (v1_2) # (Function for test scripts) ecs_api_edp_delete_type_2() { @@ -1299,7 +1336,11 @@ ecs_api_edp_delete_type_2() { return 1 fi - query="/ei-producer/v1/eitypes/$2" + if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then + query="/data-producer/v1/info-types/$2" + else + query="/ei-producer/v1/eitypes/$2" + fi res="$(__do_curl_to_api ECS DELETE $query)" status=${res:${#res}-3} @@ -1357,7 +1398,7 @@ ecs_api_edp_get_producer() { if [ -f ${arr[$i+1]} ]; then schema=$(cat ${arr[$i+1]}) else - _log_test_fail_general "Schema file "${arr[$i+1]}", does not exist" + __log_test_fail_general "Schema file "${arr[$i+1]}", does not exist" return 1 fi @@ -1382,6 +1423,7 @@ ecs_api_edp_get_producer() { } # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId} +# API Test function: GET /data-producer/v1/info-producers/{infoProducerId} # args (v1_2): [ (EMPTY | +) ] # (Function for test scripts) ecs_api_edp_get_producer_2() { @@ -1403,8 +1445,11 @@ ecs_api_edp_get_producer_2() { __print_err " [ (EMPTY | +) ]" $@ return 1 fi - - query="/ei-producer/v1/eiproducers/$2" + if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then + query="/data-producer/v1/info-producers/$2" + else + query="/ei-producer/v1/eiproducers/$2" + fi res="$(__do_curl_to_api ECS GET $query)" status=${res:${#res}-3} @@ -1427,7 +1472,11 @@ ecs_api_edp_get_producer_2() { fi targetJson=$targetJson"]" if [ $# -gt 4 ]; then - targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}" + if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then + targetJson="{\"supported_info_types\":$targetJson,\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\"}" + else + targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}" + fi fi echo " TARGET JSON: $targetJson" >> $HTTPLOG res=$(python3 ../common/compare_json.py "$targetJson" "$body") @@ -1443,6 +1492,7 @@ ecs_api_edp_get_producer_2() { } # API Test function: DELETE /ei-producer/v1/eiproducers/{eiProducerId} +# API Test function: DELETE /data-producer/v1/info-producers/{infoProducerId} # args: # (Function for test scripts) ecs_api_edp_delete_producer() { @@ -1452,8 +1502,11 @@ ecs_api_edp_delete_producer() { __print_err " " $@ return 1 fi - - query="/ei-producer/v1/eiproducers/$2" + if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then + query="/data-producer/v1/info-producers/$2" + else + query="/ei-producer/v1/eiproducers/$2" + fi res="$(__do_curl_to_api ECS DELETE $query)" status=${res:${#res}-3} @@ -1494,7 +1547,7 @@ ecs_api_edp_put_producer() { if [ -f ${arr[$i+1]} ]; then schema=$(cat ${arr[$i+1]}) else - _log_test_fail_general "Schema file "${arr[$i+1]}", does not exist" + __log_test_fail_general "Schema file "${arr[$i+1]}", does not exist" return 1 fi inputJson=$inputJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}" @@ -1522,6 +1575,7 @@ ecs_api_edp_put_producer() { } # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId} +# API Test function: PUT /data-producer/v1/info-producers/{infoProducerId} # args: (v1_2) NOTYPE|[+] # (Function for test scripts) ecs_api_edp_put_producer_2() { @@ -1549,15 +1603,27 @@ ecs_api_edp_put_producer_2() { inputJson=$inputJson"\""${arr[$i]}"\"" done fi - inputJson="\"supported_ei_types\":"$inputJson"]" + if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then + inputJson="\"supported_info_types\":"$inputJson"]" - inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"" + inputJson=$inputJson",\"info_job_callback_url\": \"$3\",\"info_producer_supervision_callback_url\": \"$4\"" - inputJson="{"$inputJson"}" + inputJson="{"$inputJson"}" - file="./tmp/.p.json" - echo "$inputJson" > $file - query="/ei-producer/v1/eiproducers/$2" + file="./tmp/.p.json" + echo "$inputJson" > $file + query="/data-producer/v1/info-producers/$2" + else + inputJson="\"supported_ei_types\":"$inputJson"]" + + inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"" + + inputJson="{"$inputJson"}" + + file="./tmp/.p.json" + echo "$inputJson" > $file + query="/ei-producer/v1/eiproducers/$2" + fi res="$(__do_curl_to_api ECS PUT $query $file)" status=${res:${#res}-3} @@ -1613,7 +1679,7 @@ ecs_api_edp_get_producer_jobs() { jobfile=$(cat ${arr[$i+4]}) jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g") else - _log_test_fail_general "Job template file "${arr[$i+4]}", does not exist" + __log_test_fail_general "Job template file "${arr[$i+4]}", does not exist" return 1 fi 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}" @@ -1635,6 +1701,7 @@ ecs_api_edp_get_producer_jobs() { } # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs +# API Test function: GET /data-producer/v1/info-producers/{infoProducerId}/info-jobs # args: (V1-2) (EMPTY | [ ]+) # (Function for test scripts) ecs_api_edp_get_producer_jobs_2() { @@ -1656,8 +1723,11 @@ ecs_api_edp_get_producer_jobs_2() { __print_err " (EMPTY | [ ]+)" $@ return 1 fi - - query="/ei-producer/v1/eiproducers/$2/eijobs" + if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then + query="/data-producer/v1/info-producers/$2/info-jobs" + else + query="/ei-producer/v1/eiproducers/$2/eijobs" + fi res="$(__do_curl_to_api ECS GET $query)" status=${res:${#res}-3} if [ $status -ne $1 ]; then @@ -1677,10 +1747,14 @@ ecs_api_edp_get_producer_jobs_2() { jobfile=$(cat ${arr[$i+4]}) jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g") else - _log_test_fail_general "Job template file "${arr[$i+4]}", does not exist" + __log_test_fail_general "Job template file "${arr[$i+4]}", does not exist" return 1 fi - 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\":\"????\"}" + if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then + 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\":\"????\"}" + else + 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\":\"????\"}" + fi done fi targetJson=$targetJson"]" @@ -1710,7 +1784,7 @@ ecs_api_service_status() { __log_test_start $@ if [ $# -lt 1 ]; then - __print_err " []*|NOID" $@ + __print_err "" $@ return 1 fi res="$(__do_curl_to_api ECS GET /status)" @@ -1723,6 +1797,430 @@ ecs_api_service_status() { return 0 } +########################################### +######### Info data consumer API ########## +########################################### +#Function prefix: ecs_api_idc + + +# API Test function: GET /data-consumer/v1/info-types +# args: [ (EMPTY | []+) ] +# (Function for test scripts) +ecs_api_idc_get_type_ids() { + __log_test_start $@ + + if [ $# -lt 1 ]; then + __print_err " [ (EMPTY | []+) ]" $@ + return 1 + fi + + query="/data-consumer/v1/info-types" + res="$(__do_curl_to_api ECS GET $query)" + status=${res:${#res}-3} + + if [ $status -ne $1 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi + if [ $# -gt 1 ]; then + body=${res:0:${#res}-3} + targetJson="[" + if [ $2 != "EMPTY" ]; then + for pid in ${@:2} ; do + if [ "$targetJson" != "[" ]; then + targetJson=$targetJson"," + fi + targetJson=$targetJson"\"$pid\"" + done + fi + targetJson=$targetJson"]" + echo " TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + __log_test_fail_body + return 1 + fi + fi + + __log_test_pass + return 0 +} + +# API Test function: GET /data-consumer/v1/info-jobs +# args: |NOTYPE |NOOWNER [ EMPTY | + ] +# (Function for test scripts) +ecs_api_idc_get_job_ids() { + __log_test_start $@ + + # Valid number of parameters 4,5,6 etc + if [ $# -lt 3 ]; then + __print_err " |NOTYPE |NOOWNER [ EMPTY | + ]" $@ + return 1 + fi + search="" + if [ $3 != "NOWNER" ]; then + search="?owner="$3 + fi + + if [ $2 != "NOTYPE" ]; then + if [ -z "$search" ]; then + search="?infoTypeId="$2 + else + search=$search"&infoTypeId="$2 + fi + fi + query="/data-consumer/v1/info-jobs$search" + + res="$(__do_curl_to_api ECS GET $query)" + status=${res:${#res}-3} + + if [ $status -ne $1 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi + + if [ $# -gt 3 ]; then + body=${res:0:${#res}-3} + targetJson="[" + + for pid in ${@:4} ; do + if [ "$targetJson" != "[" ]; then + targetJson=$targetJson"," + fi + if [ $pid != "EMPTY" ]; then + targetJson=$targetJson"\"$pid\"" + fi + done + + targetJson=$targetJson"]" + echo " TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + __log_test_fail_body + return 1 + fi + fi + + __log_test_pass + return 0 +} + +# API Test function: GET /data-consumer/v1/info-jobs/{infoJobId} +# args: [ ] +# (Function for test scripts) +ecs_api_idc_get_job() { + __log_test_start $@ + + if [ $# -ne 2 ] && [ $# -ne 7 ]; then + __print_err " [ ]" $@ + return 1 + fi + query="/data-consumer/v1/info-jobs/$2" + res="$(__do_curl_to_api ECS GET $query)" + status=${res:${#res}-3} + + if [ $status -ne $1 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi + + if [ $# -eq 7 ]; then + body=${res:0:${#res}-3} + + if [ -f $7 ]; then + jobfile=$(cat $7) + jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g") + else + __log_test_fail_general "Job template file "$6", does not exist" + return 1 + fi + targetJson="{\"info_type_id\": \"$3\", \"job_result_uri\": \"$4\",\"job_owner\": \"$5\",\"status_notification_uri\": \"$6\",\"job_definition\": $jobfile}" + echo " TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + __log_test_fail_body + return 1 + fi + fi + + __log_test_pass + return 0 +} + + +# API Test function: PUT ​/data-consumer/v1/info-jobs/{infoJobId} +# args: [ VALIDATE ] +# (Function for test scripts) +ecs_api_idc_put_job() { + __log_test_start $@ + + if [ $# -lt 7 ] || [ $# -gt 8 ]; then + __print_err " [ VALIDATE ]" $@ + return 1 + fi + if [ -f $7 ]; then + jobfile=$(cat $7) + jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g") + else + __log_test_fail_general "Job template file "$7", does not exist" + return 1 + fi + + inputJson="{\"info_type_id\": \"$3\", \"job_result_uri\": \"$4\",\"job_owner\": \"$5\",\"status_notification_uri\": \"$6\",\"job_definition\": $jobfile}" + file="./tmp/.p.json" + echo "$inputJson" > $file + + query="/data-consumer/v1/info-jobs/$2" + + if [ $# -eq 8 ]; then + if [ $8 == "VALIDATE" ]; then + query=$query"?typeCheck=true" + fi + fi + + res="$(__do_curl_to_api ECS PUT $query $file)" + status=${res:${#res}-3} + + if [ $status -ne $1 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi + + __log_test_pass + return 0 +} + +# API Test function: DELETE ​/data-consumer/v1/info-jobs/{infoJobId} +# args: +# (Function for test scripts) +ecs_api_idc_delete_job() { + __log_test_start $@ + + if [ $# -ne 2 ]; then + __print_err " " $@ + return 1 + fi + query="/data-consumer/v1/info-jobs/$2" + res="$(__do_curl_to_api ECS DELETE $query)" + status=${res:${#res}-3} + + if [ $status -ne $1 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi + + __log_test_pass + return 0 +} + +# API Test function: GET ​/data-consumer/v1/info-types/{infoTypeId} +# args: [] +# (Function for test scripts) +ecs_api_idc_get_type() { + __log_test_start $@ + + if [ $# -lt 2 ] || [ $# -gt 3 ]; then + __print_err " []" $@ + return 1 + fi + + query="/data-consumer/v1/info-types/$2" + res="$(__do_curl_to_api ECS GET $query)" + status=${res:${#res}-3} + + if [ $status -ne $1 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi + + if [ $# -eq 3 ]; then + body=${res:0:${#res}-3} + if [ -f $3 ]; then + schema=$(cat $3) + else + __log_test_fail_general "Schema file "$3", does not exist" + return 1 + fi + targetJson="{\"job_data_schema\":$schema}" + echo " TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + __log_test_fail_body + return 1 + fi + fi + + __log_test_pass + return 0 +} + +# API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}/status +# This test only status during an optional timeout. No test of the list of producers +# args: [ []] +# (Function for test scripts) +ecs_api_idc_get_job_status() { + __log_test_start $@ + + if [ $# -lt 2 ] && [ $# -gt 4 ]; then + __print_err " [ []]" $@ + return 1 + fi + + query="/data-consumer/v1/info-jobs/$2/status" + + start=$SECONDS + for (( ; ; )); do + res="$(__do_curl_to_api ECS GET $query)" + status=${res:${#res}-3} + + if [ $# -eq 4 ]; then + duration=$((SECONDS-start)) + echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}" + if [ $duration -gt $4 ]; then + echo "" + duration=-1 #Last iteration + fi + else + duration=-1 #single test, no wait + fi + + if [ $status -ne $1 ]; then + if [ $duration -eq -1 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi + fi + if [ $# -ge 3 ] && [ $status -eq $1 ]; then + body=${res:0:${#res}-3} + targetJson="{\"info_job_status\": \"$3\"}" + echo " TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + if [ $duration -eq -1 ]; then + __log_test_fail_body + return 1 + fi + else + duration=-1 #Goto pass + fi + fi + if [ $duration -eq -1 ]; then + if [ $# -eq 4 ]; then + echo "" + fi + __log_test_pass + return 0 + else + sleep 1 + fi + done + + __log_test_pass + return 0 +} + +# API Test function: GET /data-consumer/v1/info-jobs/{infoJobId}/status +# This function test status and the list of producers with and optional timeout +# args: [ EMPTYPROD|( + ) []] +# (Function for test scripts) +ecs_api_idc_get_job_status2() { + + __log_test_start $@ + param_error=0 + if [ $# -lt 2 ]; then + param_error=1 + fi + args=("$@") + timeout=0 + if [ $# -gt 2 ]; then + if [ $# -lt 4 ]; then + param_error=1 + fi + targetJson="{\"info_job_status\": \"$3\"" + if [ "$4" == "EMPTYPROD" ]; then + targetJson=$targetJson",\"producers\": []}" + if [ $# -gt 4 ]; then + timeout=$5 + fi + else + targetJson=$targetJson",\"producers\": [" + if [ $# -eq $(($4+5)) ]; then + idx=$(($4+4)) + timeout=${args[$idx]} + fi + for ((ecs_i = 0 ; ecs_i < $4 ; ecs_i++)); do + idx=$(($ecs_i+4)) + if [ $ecs_i -gt 0 ]; then + targetJson=$targetJson"," + fi + targetJson=$targetJson"\""${args[$idx]}"\"" + done + targetJson=$targetJson"]}" + fi + fi + + if [ $param_error -ne 0 ]; then + __print_err " [ EMPTYPROD|( + ) []]" $@ + return 1 + fi + + query="/data-consumer/v1/info-jobs/$2/status" + + start=$SECONDS + for (( ; ; )); do + res="$(__do_curl_to_api ECS GET $query)" + status=${res:${#res}-3} + + if [ $# -gt 2 ]; then + duration=$((SECONDS-start)) + echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}" + if [ $duration -gt $timeout ]; then + echo "" + duration=-1 #Last iteration + fi + else + duration=-1 #single test, no wait + fi + + if [ $status -ne $1 ]; then + if [ $duration -eq -1 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi + fi + if [ $# -gt 2 ] && [ $status -eq $1 ]; then + body=${res:0:${#res}-3} + echo " TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + if [ $duration -eq -1 ]; then + __log_test_fail_body + return 1 + fi + else + duration=-1 #Goto pass + fi + fi + if [ $duration -eq -1 ]; then + if [ $# -eq 4 ]; then + echo "" + fi + __log_test_pass + return 0 + else + sleep 1 + fi + done + + __log_test_pass + return 0 +} ########################################## #### Reset jobs #### @@ -1788,7 +2286,13 @@ ecs_api_admin_reset() { ecs_kube_pvc_reset() { __log_test_start $@ - __kube_clean_pvc $ECS_APP_NAME nonrtric enrichmentservice-pvc /var/enrichment-coordinator-service/database + pvc_name=$(kubectl get pvc -n nonrtric --no-headers -o custom-columns=":metadata.name" | grep enrichment) + if [ -z "$pvc_name" ]; then + pvc_name=enrichmentservice-pvc + fi + echo " Trying to reset pvc: "$pvc_name + + __kube_clean_pvc $ECS_APP_NAME nonrtric $pvc_name /var/enrichment-coordinator-service/database __log_test_pass return 0