X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fcommon%2Fcontroller_api_functions.sh;h=e33c61907c1b183b04b1d8e4c2e2ea043e198154;hb=caf750c05d1fdac7165b2368f5cc6882517c6390;hp=ed298f1653902a675b7a7f9699d465cc6643fa78;hpb=7a7a13a47eeebf9a61fa84d14af59b1cbe1598bc;p=nonrtric.git diff --git a/test/common/controller_api_functions.sh b/test/common/controller_api_functions.sh index ed298f16..e33c6190 100644 --- a/test/common/controller_api_functions.sh +++ b/test/common/controller_api_functions.sh @@ -41,9 +41,9 @@ __do_curl_to_controller() { body=$(echo "$3" | sed 's/"/\\"/g') json='{"input":{"near-rt-ric-url":"'$2'","body":"'"$body"'"}}' fi - echo "$json" > .sndc.payload.json + echo "$json" > .sdnc.payload.json echo " FILE: $json" >> $HTTPLOG - curlString="curl -sw %{http_code} -X POST http://$SDNC_USER:$SDNC_PWD@localhost:$SDNC_EXTERNAL_PORT$SDNC_API_URL$1 -H accept:application/json -H Content-Type:application/json --data-binary @.sndc.payload.json" + curlString="curl -skw %{http_code} -X POST $SDNC_HTTPX://$SDNC_USER:$SDNC_PWD@localhost:$SDNC_LOCAL_PORT$SDNC_API_URL$1 -H accept:application/json -H Content-Type:application/json --data-binary @.sdnc.payload.json" echo " CMD: "$curlString >> $HTTPLOG res=$($curlString) retcode=$? @@ -61,8 +61,9 @@ __do_curl_to_controller() { return 1 fi body=${res:0:${#res}-3} + echo " JSON: "$body >> $HTTPLOG echo "$body" > .sdnc-reply.json - res=$(python ../common/extract_sdnc_reply.py .sdnc-reply.json) + res=$(python3 ../common/extract_sdnc_reply.py .sdnc-reply.json) echo " EXTRACED BODY+CODE: "$res >> $HTTPLOG echo "$res" return 0 @@ -97,12 +98,14 @@ controller_api_get_A1_policy_ids() { if [ $? -ne 0 ]; then echo -e $RED" FAIL. Exepected status "$1", got "$status "(likely remote server error)"$ERED ((RES_FAIL++)) + __check_stop_at_error return 1 fi if [ $status -ne $1 ]; then echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED ((RES_FAIL++)) + __check_stop_at_error return 1 fi body=${res:0:${#res}-3} @@ -116,17 +119,18 @@ controller_api_get_A1_policy_ids() { if [ "$targetJson" != "[" ]; then targetJson=$targetJson"," fi - targetJson=$targetJson"\"$pid\"" + targetJson=$targetJson"\"$UUID$pid\"" done targetJson=$targetJson"]" echo " TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python ../common/compare_json.py "$targetJson" "$body") + res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then echo -e $RED" FAIL, returned body not correct"$ERED ((RES_FAIL++)) + __check_stop_at_error return 1 fi @@ -162,12 +166,14 @@ controller_api_get_A1_policy_type() { if [ $? -ne 0 ]; then echo -e $RED" FAIL. Exepected status "$1", got "$status "(likely remote server error)"$ERED ((RES_FAIL++)) + __check_stop_at_error return 1 fi if [ $status -ne $1 ]; then echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED ((RES_FAIL++)) + __check_stop_at_error return 1 fi body=${res:0:${#res}-3} @@ -178,11 +184,12 @@ controller_api_get_A1_policy_type() { targetJson=$(< $5) echo " TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python ../common/compare_json.py "$targetJson" "$body") + res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then echo -e $RED" FAIL, returned body not correct"$ERED ((RES_FAIL++)) + __check_stop_at_error return 1 fi fi @@ -202,10 +209,10 @@ controller_api_delete_A1_policy() { paramError=1 if [ $# -eq 5 ] && [ $2 == "OSC" ]; then - url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$5" + url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$UUID$5" paramError=0 elif [ $# -eq 4 ] && [ $2 == "STD" ]; then - url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$4" + url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$UUID$4" paramError=0 fi @@ -221,12 +228,14 @@ controller_api_delete_A1_policy() { if [ $? -ne 0 ]; then echo -e $RED" FAIL. Exepected status "$1", got "$status "(likely remote server error)"$ERED ((RES_FAIL++)) + __check_stop_at_error return 1 fi if [ $status -ne $1 ]; then echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED ((RES_FAIL++)) + __check_stop_at_error return 1 fi @@ -245,12 +254,12 @@ controller_api_put_A1_policy() { paramError=1 if [ $# -eq 6 ] && [ $2 == "OSC" ]; then - url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$5" + url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$UUID$5" body=$(sed 's/XXX/'${5}'/g' $6) paramError=0 elif [ $# -eq 5 ] && [ $2 == "STD" ]; then - url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$4" + url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$UUID$4" body=$(sed 's/XXX/'${4}'/g' $5) paramError=0 fi @@ -267,12 +276,14 @@ controller_api_put_A1_policy() { if [ $? -ne 0 ]; then echo -e $RED" FAIL. Exepected status "$1", got "$status "(likely remote server error)"$ERED ((RES_FAIL++)) + __check_stop_at_error return 1 fi if [ $status -ne $1 ]; then echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED ((RES_FAIL++)) + __check_stop_at_error return 1 fi @@ -293,7 +304,7 @@ controller_api_get_A1_policy_status() { targetJson="" paramError=1 if [ $# -ge 5 ] && [ $2 == "OSC" ]; then - url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$5/status" + url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$UUID$5/status" if [ $# -gt 5 ]; then targetJson="{\"instance_status\":\"$6\"" targetJson=$targetJson",\"has_been_deleted\":\"$7\"" @@ -301,7 +312,7 @@ controller_api_get_A1_policy_status() { fi paramError=0 elif [ $# -ge 4 ] && [ $2 == "STD" ]; then - url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$4/status" + url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$UUID$4/status" if [ $# -gt 4 ]; then targetJson="{\"enforceStatus\":\"$5\"" if [ $# -eq 6 ]; then @@ -324,12 +335,14 @@ controller_api_get_A1_policy_status() { if [ $? -ne 0 ]; then echo -e $RED" FAIL. Exepected status "$1", got "$status "(likely remote server error)"$ERED ((RES_FAIL++)) + __check_stop_at_error return 1 fi if [ $status -ne $1 ]; then echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED ((RES_FAIL++)) + __check_stop_at_error return 1 fi @@ -337,11 +350,12 @@ controller_api_get_A1_policy_status() { body=${res:0:${#res}-3} echo " TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python ../common/compare_json.py "$targetJson" "$body") + res=$(python3 ../common/compare_json.py "$targetJson" "$body") if [ $res -ne 0 ]; then echo -e $RED" FAIL, returned body not correct"$ERED ((RES_FAIL++)) + __check_stop_at_error return 1 fi fi