X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=near-rt-ric-simulator%2Ftest%2FOSC_2.1.0%2Fbasic_test.sh;h=9e6a88e9907a386b501aab87a4f2dc42caeb0c46;hb=d9b25321d9bce8a3db88102c127e2aa4436d81c8;hp=8d205f0992737e4ac800406dbc8f9e4d79f099c8;hpb=109f3f55a3f0eaac94a9b6954fe2f3db611a991d;p=sim%2Fa1-interface.git diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh b/near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh index 8d205f0..9e6a88e 100755 --- a/near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh +++ b/near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh @@ -1,7 +1,7 @@ #!/bin/bash # ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# Copyright (C) 2021 Nordix Foundation. All rights reserved. # ======================================================================== # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,14 +18,25 @@ # # Script for basic test of the simulator. -# Run the build_and_start with the same arg as this script -if [ $# -ne 1 ]; then - echo "Usage: ./basic_test.sh nonsecure|secure" +# Run the build_and_start with the same arg, except arg 'nonsecure|secure', as this script + +print_usage() { + echo "Usage: ./basic_test.sh nonsecure|secure duplicate-check|ignore-duplicate " exit 1 +} + +if [ $# -ne 2 ]; then + print_usage fi if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then - echo "Usage: ./basic_test.sh nonsecure|secure" - exit 1 + print_usage +fi +if [ "$2" == "duplicate-check" ]; then + DUP_CHECK=1 +elif [ "$2" == "ignore-duplicate" ]; then + DUP_CHECK=0 +else + print_usage fi if [ $1 == "nonsecure" ]; then @@ -47,7 +58,7 @@ RESULT="OK" do_curl GET / 200 echo "=== Check used and implemented interfaces ===" -RESULT="Current interface: OSC_2.1.0 All supported A1 interface yamls in this container: ['1.1.x-alpha.2', 'STD_1.1.3', 'OSC_2.1.0']" +RESULT="Current interface: OSC_2.1.0 All supported A1 interface yamls in this container: ['OSC_2.1.0', 'STD_1.1.3', 'STD_2.0.0']" do_curl GET /container_interfaces 200 echo "=== Reset simulator instances ===" @@ -60,7 +71,7 @@ do_curl POST /deleteall 200 echo "=== API: Healthcheck ===" RESULT="" -do_curl get /a1-p/healthcheck 200 +do_curl GET /a1-p/healthcheck 200 echo "=== API: Get policy types, shall be empty array ==" RESULT="json:[]" @@ -95,7 +106,7 @@ RESULT="" do_curl PUT /a1-p/policytypes/1 201 jsonfiles/pt1.json echo "=== API: Get policy type ids, shall contain type 1 ==" -RESULT="json:[ \"1\" ]" +RESULT="json:[ 1 ]" do_curl GET /a1-p/policytypes 200 echo "=== API: Get instances for type 1, shall be empty ===" @@ -104,11 +115,16 @@ do_curl GET '/a1-p/policytypes/1/policies' 200 echo "=== API: Create policy instance pi1 of type: 1 ===" RESULT="" +# res=$(cat jsonfiles/pi1.json) +# RESULT="json:$res" do_curl PUT '/a1-p/policytypes/1/policies/pi1' 202 jsonfiles/pi1.json echo "=== API: Update policy instance pi1 of type: 1 ===" RESULT="" do_curl PUT '/a1-p/policytypes/1/policies/pi1' 202 jsonfiles/pi1.json +# res=$(cat jsonfiles/pi1.json) +# RESULT="json:$res" +# do_curl PUT '/a1-p/policytypes/1/policies/pi1' 200 jsonfiles/pi1.json echo "=== API: Load a policy type: 1, shall fail ===" RESULT="" @@ -118,9 +134,22 @@ echo "=== API: Get instances for type 1, shall contain pi1 ===" RESULT="json:[ \"pi1\" ]" do_curl GET '/a1-p/policytypes/1/policies' 200 -echo "=== API: Create policy instance pi2 (copy of pi1) of type: 1. Shall fail ===" -RESULT="" -do_curl PUT '/a1-p/policytypes/1/policies/pi2' 400 jsonfiles/pi1.json +if [ $DUP_CHECK == 1 ]; then + echo "=== API: Create policy instance pi2 (copy of pi1) of type: 1. Shall fail ===" + RESULT="" + do_curl PUT '/a1-p/policytypes/1/policies/pi2' 400 jsonfiles/pi1.json +else + echo "=== API: Create policy instance pi2 (copy of pi1) of type: 1. Shall succeed ===" + RESULT="" + do_curl PUT '/a1-p/policytypes/1/policies/pi2' 202 jsonfiles/pi1.json + # res=$(cat jsonfiles/pi1.json) + # RESULT="json:$res" + # do_curl PUT '/a1-p/policytypes/1/policies/pi2' 200 jsonfiles/pi1.json + + echo "=== Delete policy instance: pi2 ===" + RESULT="" + do_curl DELETE '/a1-p/policytypes/1/policies/pi2' 202 +fi echo "=== Set force response code 401. ===" RESULT="*" @@ -131,19 +160,19 @@ RESULT="" do_curl GET '/a1-p/policytypes/1' 401 echo "=== API: Get policy status ===" -RESULT="json:{\"instance_status\": \"NOT IN EFFECT\", \"has_been_deleted\": \"false\", \"created_at\": \"????\"}" +RESULT="json:{\"enforceStatus\": \"NOT_ENFORCED\", \"enforceReason\": \"OTHER_REASON\"}" do_curl GET '/a1-p/policytypes/1/policies/pi1/status' 200 echo "=== Load a policy type: 2 ===" RESULT="Policy type 2 is OK." -do_curl PUT '/policytype?id=2' 201 jsonfiles/pt1.json +do_curl PUT '/policytype?id=2' 201 jsonfiles/pt2.json echo "=== Load a policy type: 2 again. ===" RESULT="Policy type 2 is OK." -do_curl PUT '/policytype?id=2' 200 jsonfiles/pt1.json +do_curl PUT '/policytype?id=2' 200 jsonfiles/pt2.json echo "=== API: Get policy type ids, shall contain type 1 and 2 ==" -RESULT="json:[ \"1\", \"2\" ]" +RESULT="json:[ 1, 2 ]" do_curl GET /a1-p/policytypes 200 echo "=== Get policy type ids, shall contain type 1 and 2 ==" @@ -151,15 +180,15 @@ RESULT="json:[\"1\", \"2\"]" do_curl GET /policytypes 200 echo "=== API: Get policy type 2 ==" -RESULT="json:{\"name\": \"pt1\", \"description\": \"pt1 policy type\", \"policy_type_id\": 1, \"create_schema\": {\"\$schema\": \"http://json-schema.org/draft-07/schema#\", \"title\": \"STD_QoSNudging_0.2.0\", \"description\": \"QoS policy type\", \"type\": \"object\", \"properties\": {\"scope\": {\"type\": \"object\", \"properties\": {\"ueId\": {\"type\": \"string\"}, \"qosId\": {\"type\": \"string\"}}, \"additionalProperties\": false, \"required\": [\"ueId\", \"qosId\"]}, \"statement\": {\"type\": \"object\", \"properties\": {\"priorityLevel\": {\"type\": \"number\"}}, \"additionalProperties\": false, \"required\": [\"priorityLevel\"]}}}}" +RESULT="json:{\"name\": \"pt2\", \"description\": \"pt2 policy type\", \"policy_type_id\": 2, \"create_schema\": {\"\$schema\": \"http://json-schema.org/draft-07/schema#\", \"title\": \"STD_QoSNudging_0.2.0\", \"description\": \"QoS policy type\", \"type\": \"object\", \"properties\": {\"scope\": {\"type\": \"object\", \"properties\": {\"ueId\": {\"type\": \"string\"}, \"qosId\": {\"type\": \"string\"}}, \"additionalProperties\": false, \"required\": [\"ueId\", \"qosId\"]}, \"statement\": {\"type\": \"object\", \"properties\": {\"priorityLevel\": {\"type\": \"number\"}}, \"additionalProperties\": false, \"required\": [\"priorityLevel\"]}}}}" do_curl GET /a1-p/policytypes/2 200 echo "=== Delete policy type: 2 ===" RESULT="" -do_curl DELETE '/policytype?id=2' 204 jsonfiles/pt1.json +do_curl DELETE '/policytype?id=2' 204 jsonfiles/pt2.json echo "=== API: Get policy type ids, shall contain type 1 ==" -RESULT="json:[ \"1\" ]" +RESULT="json:[ 1 ]" do_curl GET /a1-p/policytypes 200 echo "=== Load a policy type: 2 ===" @@ -167,14 +196,14 @@ RESULT="Policy type 2 is OK." do_curl PUT '/policytype?id=2' 201 jsonfiles/pt2.json echo "=== API: Get policy type 2 ==" -RESULT="json:{\"name\": \"pt1\", \"description\": \"pt1 policy type\", \"policy_type_id\": 1, \"create_schema\": {\"\$schema\": \"http://json-schema.org/draft-07/schema#\", \"title\": \"STD_QoSNudging_0.2.0\", \"description\": \"QoS policy type\", \"type\": \"object\", \"properties\": {\"scope\": {\"type\": \"object\", \"properties\": {\"ueId\": {\"type\": \"string\"}, \"qosId\": {\"type\": \"string\"}}, \"additionalProperties\": false, \"required\": [\"ueId\", \"qosId\"]}, \"statement\": {\"type\": \"object\", \"properties\": {\"priorityLevel\": {\"type\": \"number\"}}, \"additionalProperties\": false, \"required\": [\"priorityLevel\"]}}}}" -do_curl GET /a1-p/policytypes/1 200 +RESULT="json:{\"name\": \"pt2\", \"description\": \"pt2 policy type\", \"policy_type_id\": 2, \"create_schema\": {\"\$schema\": \"http://json-schema.org/draft-07/schema#\", \"title\": \"STD_QoSNudging_0.2.0\", \"description\": \"QoS policy type\", \"type\": \"object\", \"properties\": {\"scope\": {\"type\": \"object\", \"properties\": {\"ueId\": {\"type\": \"string\"}, \"qosId\": {\"type\": \"string\"}}, \"additionalProperties\": false, \"required\": [\"ueId\", \"qosId\"]}, \"statement\": {\"type\": \"object\", \"properties\": {\"priorityLevel\": {\"type\": \"number\"}}, \"additionalProperties\": false, \"required\": [\"priorityLevel\"]}}}}" +do_curl GET /a1-p/policytypes/2 200 echo "=== API: Get instances for type 2, shall be empty ===" RESULT="json:[]" do_curl GET '/a1-p/policytypes/2/policies' 200 -echo "=== API: Create policy instance pi1 of type: 2, shall fail===" +echo "=== API: Create duplicate policy instance id pi1 of type: 2 (pi1 exist for type 1), shall fail===" RESULT="" do_curl PUT '/a1-p/policytypes/2/policies/pi1' 400 jsonfiles/pi1.json @@ -185,11 +214,22 @@ do_curl PUT '/a1-p/policytypes/2/policies/pi2' 400 jsonfiles/pi2_missing_param.j echo "=== API: Create policy instance pi2 of type: 2 ===" RESULT="" do_curl PUT '/a1-p/policytypes/2/policies/pi2' 202 jsonfiles/pi2.json +# res=$(cat jsonfiles/pi2.json) +# RESULT="json:$res" +# do_curl PUT '/a1-p/policytypes/2/policies/pi2' 200 jsonfiles/pi2.json echo "=== API: Update policy instance pi2 of type: 2 ===" RESULT="" do_curl PUT '/a1-p/policytypes/2/policies/pi2' 202 jsonfiles/pi2.json +echo "=== API: Update policy instance pi2 of type: 2 ===" +RESULT="" +do_curl PUT "/a1-p/policytypes/2/policies/pi2?notificationDestination=http://localhost:${PORT}/statustest" 202 jsonfiles/pi2.json + +echo "=== Send status for pi2===" +RESULT="OK" +do_curl POST '/sendstatus?policyid=pi2' 201 jsonfiles/pi2.json + echo "=== API: Get instances for type 1, shall contain pi1 ===" RESULT="json:[ \"pi1\" ]" do_curl GET '/a1-p/policytypes/1/policies' jsonfiles/200 @@ -198,9 +238,47 @@ echo "=== API: Get instances for type 2, shall contain pi2 ===" RESULT="json:[ \"pi2\" ]" do_curl GET '/a1-p/policytypes/2/policies' 200 -echo "=== API: Create policy instance pi11 (copy of pi1) of type: 1. Shall fail ===" -RESULT="" -do_curl PUT '/a1-p/policytypes/1/policies/pi11' 400 jsonfiles/pi1.json +if [ $DUP_CHECK == 1 ]; then + echo "=== API: Create policy instance pi11 (copy of pi1) of type: 1. Shall fail ===" + RESULT="" + do_curl PUT '/a1-p/policytypes/1/policies/pi11' 400 jsonfiles/pi1.json +else + echo "=== API: Create policy instance pi11 (copy of pi1) of type: 1. Shall succeed ===" + RESULT="" + do_curl PUT '/a1-p/policytypes/1/policies/pi11' 202 jsonfiles/pi1.json + # res=$(cat jsonfiles/pi1.json) + # RESULT="json:$res" + # do_curl PUT '/a1-p/policytypes/1/policies/pi11' 200 jsonfiles/pi1.json + + echo "=== Delete policy instance: pi11 ===" + RESULT="" + do_curl DELETE '/a1-p/policytypes/1/policies/pi11' 202 +fi + +if [ $DUP_CHECK == 1 ]; then + echo "=== API: Create policy instance pi3 (copy of pi1) of type: 2. Shall fail ===" + RESULT="" + do_curl PUT '/a1-p/policytypes/1/policies/pi3' 400 jsonfiles/pi1.json +else + echo "=== API: Create policy instance pi3 (copy of pi1) of type: 1. Shall succeed ===" + RESULT="" + do_curl PUT '/a1-p/policytypes/1/policies/pi3' 202 jsonfiles/pi1.json + # res=$(cat jsonfiles/pi1.json) + # RESULT="json:$res" + # do_curl PUT '/a1-p/policytypes/1/policies/pi3' 200 jsonfiles/pi1.json + + echo "=== Delete policy instance: pi3 ===" + RESULT="" + do_curl DELETE '/a1-p/policytypes/1/policies/pi3' 202 +fi + +echo "=== API: Get instances for type 1, shall contain pi1 ===" +RESULT="json:[ \"pi1\" ]" +do_curl GET '/a1-p/policytypes/1/policies' jsonfiles/200 + +echo "=== API: Get instances for type 2, shall contain pi2 ===" +RESULT="json:[ \"pi2\" ]" +do_curl GET '/a1-p/policytypes/2/policies' 200 echo "=== Set force response code 401. ===" RESULT="*" @@ -215,7 +293,7 @@ RESULT="Force delay: 10 sec set for all A1 responses" do_curl POST '/forcedelay?delay=10' 200 echo "=== API: Get policy status for pi1. Shall delay 10 sec ===" -RESULT="json:{\"instance_status\": \"NOT IN EFFECT\", \"has_been_deleted\": \"false\", \"created_at\": \"????\"}" +RESULT="json:{\"enforceStatus\": \"NOT_ENFORCED\", \"enforceReason\": \"OTHER_REASON\"}" do_curl GET '/a1-p/policytypes/1/policies/pi1/status' 200 echo "=== Reset force delay. ===" @@ -223,19 +301,19 @@ RESULT="Force delay: None sec set for all A1 responses" do_curl POST '/forcedelay' 200 echo "=== Set status for pi1 ===" -RESULT="Status set to IN EFFECT for policy: pi1" -do_curl PUT '/status?policyid=pi1&status=IN%20EFFECT' 200 +RESULT="Status set to ENFORCED for policy: pi1" +do_curl PUT '/status?policyid=pi1&status=ENFORCED' 200 echo "=== API: Get policy status for pi1 ===" -RESULT="json:{\"instance_status\": \"IN EFFECT\", \"has_been_deleted\": \"false\", \"created_at\": \"????\"}" +RESULT="json:{\"enforceStatus\": \"ENFORCED\", \"enforceReason\": null}" do_curl GET '/a1-p/policytypes/1/policies/pi1/status' 200 echo "=== Set status for pi1 ===" -RESULT="Status set to IN EFFECT and has_been_deleted set to true and created_at set to 2020-03-30 12:00:00 for policy: pi1" -do_curl PUT '/status?policyid=pi1&status=IN%20EFFECT&deleted=true&created_at=2020-03-30%2012:00:00' 200 +RESULT="Status set to ENFORCED for policy: pi1" +do_curl PUT '/status?policyid=pi1&status=ENFORCED' 200 echo "=== API: Get policy status for pi1 ===" -RESULT="json:{\"instance_status\": \"IN EFFECT\", \"has_been_deleted\": \"true\", \"created_at\": \"2020-03-30 12:00:00\"}" +RESULT="json:{\"enforceStatus\": \"ENFORCED\", \"enforceReason\": null}" do_curl GET '/a1-p/policytypes/1/policies/pi1/status' 200 echo "=== Get counter: instances ===" @@ -263,13 +341,17 @@ RESULT="[]" do_curl GET /a1-p/policytypes/1/policies 200 echo "=== API: Get instances for type 2, shall contain pi2 ===" -RESULT="[ \"pi2\" ]" +RESULT="json:[ \"pi2\" ]" do_curl GET /a1-p/policytypes/2/policies 200 echo "=== Get counter: instances ===" RESULT="1" do_curl GET /counter/num_instances 200 +echo "=== Get counter: datadelivery ===" +RESULT="0" +do_curl GET /counter/datadelivery 200 + echo "********************" echo "*** All tests ok ***" echo "********************"