X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=test%2Fcommon%2Fecs_api_functions.sh;h=9bde835e8c5ed0515138210d84f2b4f15e3d680e;hb=84ffd4a403baee1b7aa86f9986f0c1659a5a0881;hp=36b1f43ef2261b88155960b3de11289bb2695c74;hpb=4c571ffb2d7e8b01d7bd2e66f15b7c610532e579;p=nonrtric.git diff --git a/test/common/ecs_api_functions.sh b/test/common/ecs_api_functions.sh index 36b1f43e..9bde835e 100644 --- a/test/common/ecs_api_functions.sh +++ b/test/common/ecs_api_functions.sh @@ -1225,7 +1225,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) [ ] +# args: (v1_2) [ [ ]] # (Function for test scripts) ecs_api_edp_get_type_2() { __log_test_start $@ @@ -1237,8 +1237,13 @@ ecs_api_edp_get_type_2() { if [ $# -eq 3 ]; then paramError=0 fi + if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then + if [ $# -eq 4 ]; then + paramError=0 + fi + fi if [ $paramError -ne 0 ]; then - __print_err " [ ]" $@ + __print_err " [ [ ]]" $@ return 1 fi if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then @@ -1254,7 +1259,7 @@ ecs_api_edp_get_type_2() { __log_test_fail_status_code $1 $status return 1 fi - if [ $# -eq 3 ]; then + if [ $# -ge 3 ]; then body=${res:0:${#res}-3} if [ -f $3 ]; then @@ -1263,8 +1268,18 @@ ecs_api_edp_get_type_2() { __log_test_fail_general "Job template file "$3", does not exist" return 1 fi + info_data="" + if [ $# -gt 3 ]; then + if [ -f $4 ]; then + info_data=$(cat $4) + else + __log_test_fail_general "Info-data file "$4", does not exist" + return 1 + fi + info_data=",\"info_type_information\":$info_data" + fi if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then - targetJson="{\"info_job_data_schema\":$schema}" + targetJson="{\"info_job_data_schema\":$schema $info_data}" else targetJson="{\"ei_job_data_schema\":$schema}" fi @@ -1283,23 +1298,42 @@ 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) +# args: (v1_2) [ ] # (Function for test scripts) ecs_api_edp_put_type_2() { __log_test_start $@ - if [ $# -ne 3 ]; then - __print_err " " $@ - return 1 + if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPE-INFO"* ]]; then + if [ $# -lt 3 ] || [ $# -gt 4 ]; then + __print_err " [ ]" $@ + return 1 + fi + else + if [ $# -ne 3 ]; then + __print_err " " $@ + return 1 + fi fi if [ ! -f $3 ]; then __log_test_fail_general "Job schema file "$3", does not exist" return 1 fi + + info_data="" + if [ $# -gt 3 ]; then + if [ -f $4 ]; then + info_data=$(cat $4) + else + __log_test_fail_general "Info-data file "$4", does not exist" + return 1 + fi + info_data=",\"info_type_information\":$info_data" + fi + if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then schema=$(cat $3) - input_json="{\"info_job_data_schema\":$schema}" + input_json="{\"info_job_data_schema\":$schema $info_data}" file="./tmp/put_type.json" echo $input_json > $file @@ -2017,13 +2051,13 @@ ecs_api_idc_delete_job() { } # API Test function: GET ​/data-consumer/v1/info-types/{infoTypeId} -# args: [] +# args: [ [ []" $@ + if [ $# -lt 2 ] || [ $# -gt 5 ]; then + __print_err " [ [ > $HTTPLOG res=$(python3 ../common/compare_json.py "$targetJson" "$body") @@ -2059,6 +2097,7 @@ ecs_api_idc_get_type() { } # 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() { @@ -2123,6 +2162,245 @@ ecs_api_idc_get_job_status() { 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 +} + +########################################## +#### Type subscriptions #### +########################################## + +# API Test function: GET /data-consumer/v1/info-type-subscription +# args: |NOOWNER [ EMPTY | +] +# (Function for test scripts) +ecs_api_idc_get_subscription_ids() { + __log_test_start $@ + + if [ $# -lt 3 ]; then + __print_err " |NOOWNER [ EMPTY | +]" $@ + return 1 + fi + + query="/data-consumer/v1/info-type-subscription" + search="" + if [ $2 != "NOOWNER" ]; then + search="?owner="$2 + fi + + res="$(__do_curl_to_api ECS GET $query$search)" + status=${res:${#res}-3} + + if [ $status -ne $1 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi + + if [ $# -gt 2 ]; then + body=${res:0:${#res}-3} + targetJson="[" + if [ $3 != "EMPTY" ]; then + for pid in ${@:3} ; 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-type-subscription/{subscriptionId} +# args: [ ] +# (Function for test scripts) +ecs_api_idc_get_subscription() { + __log_test_start $@ + + if [ $# -ne 2 ] && [ $# -ne 4 ]; then + __print_err " [ ]" $@ + return 1 + fi + + query="/data-consumer/v1/info-type-subscription/$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 [ $# -gt 2 ]; then + body=${res:0:${#res}-3} + targetJson="{\"owner\":\"$3\",\"status_result_uri\":\"$4\"}" + 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-type-subscription/{subscriptionId} +# args: +# (Function for test scripts) +ecs_api_idc_put_subscription() { + __log_test_start $@ + + if [ $# -ne 4 ]; then + __print_err " " $@ + return 1 + fi + + inputJson="{\"owner\": \"$3\",\"status_result_uri\": \"$4\"}" + file="./tmp/.p.json" + echo "$inputJson" > $file + + query="/data-consumer/v1/info-type-subscription/$2" + 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-type-subscription/{subscriptionId} +# args: +# (Function for test scripts) +ecs_api_idc_delete_subscription() { + __log_test_start $@ + + if [ $# -ne 2 ]; then + __print_err " " $@ + return 1 + fi + + query="/data-consumer/v1/info-type-subscription/$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 +} ########################################## #### Reset jobs ####