X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fmrstub%2Fbasic_test.sh;h=8b2347dc127f37e9f13734c8f86350c1388fd919;hb=f0a158c3c32b6547c839c559548e4e4b729802e1;hp=13ea3a60744e6fb432d8bcb22b7b7abe0fe22ef4;hpb=34882342628629b55c19e7f6a5369de045ab9102;p=nonrtric.git diff --git a/test/mrstub/basic_test.sh b/test/mrstub/basic_test.sh index 13ea3a60..8b2347dc 100755 --- a/test/mrstub/basic_test.sh +++ b/test/mrstub/basic_test.sh @@ -19,8 +19,27 @@ # Automated test script for mrstub container -# mr-stub port -export PORT=3905 +# Run the build_and_start with the same arg as this script +if [ $# -ne 1 ]; then + echo "Usage: ./basic_test nonsecure|secure" + exit 1 +fi +if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then + echo "Usage: ./basic_test nonsecure|secure" + exit 1 +fi + +if [ $1 == "nonsecure" ]; then + #Default http port for the simulator + PORT=3905 + # Set http protocol + HTTPX="http" +else + #Default https port for the mr-stub + PORT=3906 + # Set https protocol + HTTPX="https" +fi # source function to do curl and check result . ../common/do_curl_function.sh @@ -53,15 +72,25 @@ RESULT="json:[{\"apiVersion\":\"1.0\",\"operation\":\"PUT\",\"correlationId\":\" do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent' 200 echo "=== Send a json response ===" -# Create minimal accepted response message +# Create minimal accepted response message, array echo "[{\"correlationId\": \""$CORRID"\", \"message\": {\"test\":\"testresponse\"}, \"status\": \"200\"}]" > .tmp.json -RESULT="OK" +RESULT="{}" do_curl POST /events/A1-POLICY-AGENT-WRITE 200 .tmp.json echo "=== Fetch a response ===" RESULT="{\"test\": \"testresponse\"}200" do_curl GET '/receive-response?correlationid='$CORRID 200 +echo "=== Send a json response ===" +# Create minimal accepted response message, single message - no array +echo "{\"correlationId\": \""$CORRID"\", \"message\": {\"test\":\"testresponse2\"}, \"status\": \"200\"}" > .tmp.json +RESULT="{}" +do_curl POST /events/A1-POLICY-AGENT-WRITE 200 .tmp.json + +echo "=== Fetch a response ===" +RESULT="{\"test\": \"testresponse2\"}200" +do_curl GET '/receive-response?correlationid='$CORRID 200 + ### Test with plain text response echo "=== Send a request ===" @@ -78,10 +107,57 @@ echo "=== Fetch a request ===" RESULT="json:[{\"apiVersion\":\"1.0\",\"operation\":\"GET\",\"correlationId\":\""$CORRID"\",\"originatorId\": \"849e6c6b420\",\"payload\":{},\"requestId\":\"23343221\", \"target\":\"policy-agent\", \"timestamp\":\"????\", \"type\":\"request\",\"url\":\"/test2\"}]" do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent' 200 +echo "=== Fetch a request, empty. Shall delay 10 seconds ===" +T1=$SECONDS +RESULT="json:[]" +do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent' 200 +T2=$SECONDS +if [ $(($T2-$T1)) -lt 10 ] || [ $(($T2-$T1)) -gt 15 ]; then + echo "Delay to short or too long"$(($T2-$T1))". Should be default 10 sec" + exit 1 +else + echo " Delay ok:"$(($T2-$T1)) +fi + +echo "=== Fetch a request, empty. Shall delay 5 seconds ===" +T1=$SECONDS +RESULT="json:[]" +do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=5000' 200 +T2=$SECONDS +if [ $(($T2-$T1)) -lt 5 ] || [ $(($T2-$T1)) -gt 7 ]; then + echo "Delay too short or too long"$(($T2-$T1))". Should be 10 sec" + exit 1 +else + echo " Delay ok:"$(($T2-$T1)) +fi + +echo "=== Fetch a request with limit 25, shall be empty. ===" +RESULT="json-array-size:0" +do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=1000&limit=25' 200 + +echo "=== Send 5 request to test limit on MR GET===" +RESULT="*" +for i in {1..5} +do + do_curl POST '/send-request?operation=GET&url=/test2' 200 +done + +echo "=== Fetch a request with limit 3. ===" +RESULT="json-array-size:3" +do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=1000&limit=3' 200 + +echo "=== Fetch a request with limit 3, shall return 2. ===" +RESULT="json-array-size:2" +do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=1000&limit=3' 200 + +echo "=== Fetch a request with limit 3, shall return 0. ===" +RESULT="json-array-size:0" +do_curl GET '/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=1000&limit=3' 200 + echo "=== Send a json response ===" # Create minimal accepted response message echo "[{\"correlationId\": \""$CORRID"\", \"message\": \"test2-response\", \"status\": \"200\"}]" > .tmp.json -RESULT="OK" +RESULT="{}" do_curl POST /events/A1-POLICY-AGENT-WRITE 200 .tmp.json echo "=== Fetch a response ===" @@ -90,4 +166,4 @@ do_curl GET '/receive-response?correlationid='$CORRID 200 echo "********************" echo "*** All tests ok ***" -echo "********************" +echo "********************" \ No newline at end of file