ecaiyanlinux | 426ce5f | 2020-05-30 15:17:59 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # ============LICENSE_START=============================================== |
| 4 | # Copyright (C) 2020 Nordix Foundation. All rights reserved. |
| 5 | # ======================================================================== |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # ============LICENSE_END================================================= |
| 18 | # |
| 19 | |
| 20 | # The scripts in data/ will generate some dummy data in the running system. |
| 21 | # It will create: |
| 22 | # one policy type in a1-sim-OSC |
| 23 | # one service in policy agent |
| 24 | # one policy in a1-sim-OSC |
| 25 | # one policy in a1-sim-STD |
| 26 | |
| 27 | # Run command: |
ecaiyanlinux | 30f931f | 2020-11-10 22:45:48 +0100 | [diff] [blame] | 28 | # ./preparePmsData.sh [policy-agent port] [a1-sim-OSC port] [a1-sim-STD port] [a1-sim-STD-v2 port] [http/https] |
ecaiyanlinux | 426ce5f | 2020-05-30 15:17:59 +0200 | [diff] [blame] | 29 | |
| 30 | policy_agent_port=${1:-8081} |
| 31 | a1_sim_OSC_port=${2:-30001} |
| 32 | a1_sim_STD_port=${3:-30003} |
ecaiyanlinux | 30f931f | 2020-11-10 22:45:48 +0100 | [diff] [blame] | 33 | a1_sim_STD_v2_port=${4:-30005} |
| 34 | httpx=${5:-"http"} |
ecaiyanlinux | 426ce5f | 2020-05-30 15:17:59 +0200 | [diff] [blame] | 35 | |
| 36 | echo "using policy_agent port: "$policy_agent_port |
| 37 | echo "using a1-sim-OSC port: "$a1_sim_OSC_port |
| 38 | echo "using a1-sim-STD port: "$a1_sim_STD_port |
ecaiyanlinux | 30f931f | 2020-11-10 22:45:48 +0100 | [diff] [blame] | 39 | echo "using a1-sim-STD-v2 port: "$a1_sim_STD_v2_port |
ecaiyanlinux | 426ce5f | 2020-05-30 15:17:59 +0200 | [diff] [blame] | 40 | echo "using protocol: "$httpx |
| 41 | echo -e "\n" |
| 42 | |
| 43 | echo "policy agent status:" |
ecaiyanlinux | 30f931f | 2020-11-10 22:45:48 +0100 | [diff] [blame] | 44 | curl -skw %{http_code} $httpx://localhost:$policy_agent_port/status |
ecaiyanlinux | 426ce5f | 2020-05-30 15:17:59 +0200 | [diff] [blame] | 45 | echo -e "\n" |
| 46 | |
| 47 | echo "ric1 version:" |
ecaiyanlinux | 30f931f | 2020-11-10 22:45:48 +0100 | [diff] [blame] | 48 | curl -skw %{http_code} $httpx://localhost:$a1_sim_OSC_port/counter/interface |
ecaiyanlinux | 426ce5f | 2020-05-30 15:17:59 +0200 | [diff] [blame] | 49 | echo -e "\n" |
| 50 | |
| 51 | echo "ric2 version:" |
ecaiyanlinux | 30f931f | 2020-11-10 22:45:48 +0100 | [diff] [blame] | 52 | curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_port/counter/interface |
| 53 | echo -e "\n" |
| 54 | |
| 55 | echo "ric3 version:" |
| 56 | curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_v2_port/counter/interface |
ecaiyanlinux | 426ce5f | 2020-05-30 15:17:59 +0200 | [diff] [blame] | 57 | echo -e "\n" |
| 58 | |
| 59 | echo "create policy type 1 to ric1:" |
ecaiyanlinux | 30f931f | 2020-11-10 22:45:48 +0100 | [diff] [blame] | 60 | 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 |
| 61 | echo -e "\n" |
| 62 | |
| 63 | echo "create policy type 2 to ric3:" |
| 64 | curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_v2_port/policytype?id=2 -X PUT -H Accept:application/json -H Content-Type:application/json -H X-Requested-With:XMLHttpRequest --data-binary @testdata/v2/policy_type.json |
ecaiyanlinux | 426ce5f | 2020-05-30 15:17:59 +0200 | [diff] [blame] | 65 | echo -e "\n" |
| 66 | |
| 67 | for i in {1..12}; do |
| 68 | echo "policy types from policy agent:" |
ecaiyanlinux | 30f931f | 2020-11-10 22:45:48 +0100 | [diff] [blame] | 69 | curlString="curl -skw %{http_code} $httpx://localhost:$policy_agent_port/a1-policy/v2/policy-types" |
ecaiyanlinux | 426ce5f | 2020-05-30 15:17:59 +0200 | [diff] [blame] | 70 | res=$($curlString) |
| 71 | echo "$res" |
ecaiyanlinux | 30f931f | 2020-11-10 22:45:48 +0100 | [diff] [blame] | 72 | expect="{\"policytype_ids\":[\"\",\"1\",\"2\"]}200" |
ecaiyanlinux | 426ce5f | 2020-05-30 15:17:59 +0200 | [diff] [blame] | 73 | if [ "$res" == "$expect" ]; then |
| 74 | echo -e "\n" |
| 75 | break; |
| 76 | else |
| 77 | sleep $i |
| 78 | fi |
| 79 | done |
| 80 | |
ecaiyanlinux | 30f931f | 2020-11-10 22:45:48 +0100 | [diff] [blame] | 81 | echo "create service ric-registration to policy agent:" |
| 82 | 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 @testdata/v2/service.json |
ecaiyanlinux | 426ce5f | 2020-05-30 15:17:59 +0200 | [diff] [blame] | 83 | echo -e "\n" |
| 84 | |
ecaiyanlinux | 30f931f | 2020-11-10 22:45:48 +0100 | [diff] [blame] | 85 | echo "create policy aa8feaa88d944d919ef0e83f2172a5000 to ric1 with type 1 and service controlpanel via policy agent:" |
| 86 | 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 @testdata/v2/policy_osc.json |
ecaiyanlinux | 426ce5f | 2020-05-30 15:17:59 +0200 | [diff] [blame] | 87 | echo -e "\n" |
| 88 | |
| 89 | echo "policy numbers from ric1:" |
ecaiyanlinux | 30f931f | 2020-11-10 22:45:48 +0100 | [diff] [blame] | 90 | curl -skw %{http_code} $httpx://localhost:$a1_sim_OSC_port/counter/num_instances |
ecaiyanlinux | 426ce5f | 2020-05-30 15:17:59 +0200 | [diff] [blame] | 91 | echo -e "\n" |
| 92 | |
ecaiyanlinux | 30f931f | 2020-11-10 22:45:48 +0100 | [diff] [blame] | 93 | echo "create policy aa8feaa88d944d919ef0e83f2172a5100 to ric2 with type 2 and service controlpanel via policy agent:" |
| 94 | 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 @testdata/v2/policy_std_v2.json |
ecaiyanlinux | 426ce5f | 2020-05-30 15:17:59 +0200 | [diff] [blame] | 95 | echo -e "\n" |
| 96 | |
ecaiyanlinux | 30f931f | 2020-11-10 22:45:48 +0100 | [diff] [blame] | 97 | echo "policy numbers from ric3:" |
| 98 | curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_v2_port/counter/num_instances |
ecaiyanlinux | 426ce5f | 2020-05-30 15:17:59 +0200 | [diff] [blame] | 99 | echo -e "\n" |
| 100 | |
ecaiyanlinux | 30f931f | 2020-11-10 22:45:48 +0100 | [diff] [blame] | 101 | echo "policy id aa8feaa88d944d919ef0e83f2172a5000 from policy agent:" |
| 102 | curl -k -X GET -sw %{http_code} $httpx://localhost:$policy_agent_port/a1-policy/v2/policies/aa8feaa88d944d919ef0e83f2172a5000 |
ecaiyanlinux | 426ce5f | 2020-05-30 15:17:59 +0200 | [diff] [blame] | 103 | echo -e "\n" |
| 104 | |
ecaiyanlinux | 30f931f | 2020-11-10 22:45:48 +0100 | [diff] [blame] | 105 | echo "policy id aa8feaa88d944d919ef0e83f2172a5100 from policy agent:" |
| 106 | curl -k -X GET -sw %{http_code} $httpx://localhost:$policy_agent_port/a1-policy/v2/policies/aa8feaa88d944d919ef0e83f2172a5100 |
ecaiyanlinux | 426ce5f | 2020-05-30 15:17:59 +0200 | [diff] [blame] | 107 | echo -e "\n" |