X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=docker-compose%2Fdata%2FpreparePmsData.sh;h=bc1ad97e613d3736bca33ccb524aa0c0c4c11984;hb=1ed3146635bb9cb256e8ea7b47df985b5afde310;hp=94afc6e91fe1d59aa56bc440101ce2c0dc3dc22c;hpb=dc962f458879109f8c4c346befcd242fa3749f6c;p=nonrtric.git diff --git a/docker-compose/data/preparePmsData.sh b/docker-compose/data/preparePmsData.sh index 94afc6e9..bc1ad97e 100755 --- a/docker-compose/data/preparePmsData.sh +++ b/docker-compose/data/preparePmsData.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. @@ -29,8 +29,9 @@ policy_agent_port=${1:-8081} a1_sim_OSC_port=${2:-30001} -a1_sim_STD_port=${3:-30003} +a1_sim_STD_port=${3:-30005} httpx=${4:-"http"} +SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) echo "using policy_agent port: "$policy_agent_port echo "using a1-sim-OSC port: "$a1_sim_OSC_port @@ -38,28 +39,59 @@ echo "using a1-sim-STD port: "$a1_sim_STD_port echo "using protocol: "$httpx echo -e "\n" +checkRes (){ + if [ "$res" != "$expect" ]; then + echo "$res is not expected! exit!" + exit 1; + fi +} + echo "policy agent status:" -curl -skw " %{http_code}" $httpx://localhost:$policy_agent_port/status +curlString="curl -skw %{http_code} $httpx://localhost:$policy_agent_port/status" +res=$($curlString) +echo "$res" +expect="hunky dory200" +checkRes echo -e "\n" echo "ric1 version:" -curl -skw " %{http_code}" $httpx://localhost:$a1_sim_OSC_port/counter/interface +curlString="curl -skw %{http_code} $httpx://localhost:$a1_sim_OSC_port/counter/interface" +res=$($curlString) +echo "$res" +expect="OSC_2.1.0200" +checkRes echo -e "\n" echo "ric2 version:" -curl -skw " %{http_code}" $httpx://localhost:$a1_sim_STD_port/counter/interface +curlString="curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_port/counter/interface" +res=$($curlString) +echo "$res" +expect="STD_2.0.0200" +checkRes echo -e "\n" echo "create policy type 1 to ric1:" -curl -X PUT -skw " %{http_code}" $httpx://localhost:$a1_sim_OSC_port/policytype?id=1 -H Content-Type:application/json --data-binary @testdata/OSC/policy_type.json +curlString="curl -X PUT -skw %{http_code} $httpx://localhost:$a1_sim_OSC_port/policytype?id=1 -H Content-Type:application/json --data-binary @${SHELL_FOLDER}/testdata/OSC/policy_type.json" +res=$($curlString) +echo "$res" +expect="Policy type 1 is OK.201" +checkRes +echo -e "\n" + +echo "create policy type 2 to ric2:" +curlString="curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_port/policytype?id=2 -X PUT -H Accept:application/json -H Content-Type:application/json -H X-Requested-With:XMLHttpRequest --data-binary @${SHELL_FOLDER}/testdata/v2/policy_type.json" +res=$($curlString) +echo "$res" +expect="Policy type 2 is OK.201" +checkRes echo -e "\n" -for i in {1..12}; do +for i in {1..60}; do echo "policy types from policy agent:" - curlString="curl -skw %{http_code} $httpx://localhost:$policy_agent_port/policy_types" + curlString="curl -skw %{http_code} $httpx://localhost:$policy_agent_port/a1-policy/v2/policy-types" res=$($curlString) echo "$res" - expect="[\"\",\"1\"]200" + expect="{\"policytype_ids\":[\"\",\"1\",\"2\"]}200" if [ "$res" == "$expect" ]; then echo -e "\n" break; @@ -68,30 +100,58 @@ for i in {1..12}; do fi done -echo "create service 1 to policy agent:" -curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$policy_agent_port/service" --data-binary @testdata/service.json +echo "create service ric-registration to policy agent:" +curlString="curl -k -X PUT -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$policy_agent_port/a1-policy/v2/services" --data-binary @${SHELL_FOLDER}/testdata/v2/service.json" +res=$($curlString) +echo "$res" +expect="201" +checkRes echo -e "\n" -echo "create policy 2000 to ric1 with type1 and service1 via policy agent:" -curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$policy_agent_port/policy?id=2000&ric=ric1&service=service1&type=1" --data-binary @testdata/policy.json +echo "create policy aa8feaa88d944d919ef0e83f2172a5000 to ric1 with type 1 and service controlpanel via policy agent:" +curlString="curl -k -X PUT -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$policy_agent_port/a1-policy/v2/policies" --data-binary @${SHELL_FOLDER}/testdata/v2/policy_osc.json" +res=$($curlString) +echo "$res" +expect="201" +checkRes echo -e "\n" echo "policy numbers from ric1:" -curl -skw " %{http_code}" $httpx://localhost:$a1_sim_OSC_port/counter/num_instances +curlString="curl -skw %{http_code} $httpx://localhost:$a1_sim_OSC_port/counter/num_instances" +res=$($curlString) +echo "$res" +expect="1200" +checkRes echo -e "\n" -echo "create policy 2100 to ric2 with service1 via policy agent, no type:" -curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$policy_agent_port/policy?id=2100&ric=ric2&service=service1" --data-binary @testdata/policy.json +echo "create policy aa8feaa88d944d919ef0e83f2172a5100 to ric2 with type 2 and service controlpanel via policy agent:" +curlString="curl -k -X PUT -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$policy_agent_port/a1-policy/v2/policies" --data-binary @${SHELL_FOLDER}/testdata/v2/policy_std_v2.json" +res=$($curlString) +echo "$res" +expect="201" +checkRes echo -e "\n" echo "policy numbers from ric2:" -curl -skw " %{http_code}" $httpx://localhost:$a1_sim_STD_port/counter/num_instances +curlString="curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_port/counter/num_instances" +res=$($curlString) +echo "$res" +expect="1200" +checkRes echo -e "\n" -echo "policy id 2000 from policy agent:" -curl -k -X GET -sw " %{http_code}" $httpx://localhost:$policy_agent_port/policy?id=2000 +echo "policy id aa8feaa88d944d919ef0e83f2172a5000 from policy agent:" +curlString="curl -s -o /dev/null -I -w %{http_code} $httpx://localhost:$policy_agent_port/a1-policy/v2/policies/aa8feaa88d944d919ef0e83f2172a5000" +res=$($curlString) +echo "$res" +expect="200" +checkRes echo -e "\n" -echo "policy id 2100 from policy agent:" -curl -k -X GET -sw " %{http_code}" $httpx://localhost:$policy_agent_port/policy?id=2100 -echo -e "\n" \ No newline at end of file +echo "policy id aa8feaa88d944d919ef0e83f2172a5100 from policy agent:" +curlString="curl -s -o /dev/null -I -w %{http_code} $httpx://localhost:$policy_agent_port/a1-policy/v2/policies/aa8feaa88d944d919ef0e83f2172a5100" +res=$($curlString) +echo "$res" +expect="200" +checkRes +echo -e "\n"