Add data scripts for nonrtric k8s deployment
[it/dep.git] / nonrtric / data / run_in_k8s / populate_data.sh
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_0
23 # one service in policy agent
24 # five policies in a1-sim-OSC_0
25 # one policy in a1-sim-STD_0
26
27 policy_agent_host="policymanagementservice"
28 policy_agent_port="9080"
29 a1_sim_osc_0_host="a1-sim-osc-0.a1-sim"
30 a1_sim_osc_0_port="8085"
31 a1_sim_osc_1_host="a1-sim-osc-1.a1-sim"
32 a1_sim_osc_1_port="8085"
33 a1_sim_std_0_host="a1-sim-std-0.a1-sim"
34 a1_sim_std_0_port="8085"
35 a1_sim_std_1_host="a1-sim-std-1.a1-sim"
36 a1_sim_std_1_port="8085"
37 httpx=http
38
39 echo "policy agent status:"
40 curl -skw " %{http_code}" $httpx://$policy_agent_host:$policy_agent_port/status
41 echo -e "\n"
42
43 echo "ric1 version:"
44 curl -skw " %{http_code}" $httpx://$a1_sim_osc_0_host:$a1_sim_osc_0_port/counter/interface
45 echo -e "\n"
46
47 echo "ric2 version:"
48 curl -skw " %{http_code}" $httpx://$a1_sim_osc_1_host:$a1_sim_osc_1_port/counter/interface
49 echo -e "\n"
50
51 echo "ric3 version:"
52 curl -skw " %{http_code}" $httpx://$a1_sim_std_0_host:$a1_sim_std_0_port/counter/interface
53 echo -e "\n"
54
55 echo "ric4 version:"
56 curl -skw " %{http_code}" $httpx://$a1_sim_std_1_host:$a1_sim_std_1_port/counter/interface
57 echo -e "\n"
58
59 echo "create policy type 1 to ric1:"
60 curl -X PUT -skw " %{http_code}" $httpx://$a1_sim_osc_0_host:$a1_sim_osc_0_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 1 to ric2:"
64 curl -X PUT -skw " %{http_code}" $httpx://$a1_sim_osc_1_host:$a1_sim_osc_1_port/policytype?id=1 -H Content-Type:application/json --data-binary @testdata/OSC/policy_type.json
65 echo -e "\n"
66
67 for i in {1..12}; do
68         echo "policy types from policy agent:"
69     curlString="curl -skw %{http_code} $httpx://$policy_agent_host:$policy_agent_port/policy_types"
70     res=$($curlString)
71     echo "$res"
72     expect="[\"\",\"1\"]200"
73     if [ "$res" == "$expect" ]; then
74         echo -e "\n"
75         break;
76     else
77         sleep $i
78     fi
79 done
80
81 echo "create service 1 to policy agent:"
82 curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_host:$policy_agent_port/service" --data-binary @testdata/service.json
83 echo -e "\n"
84
85 echo "create policy 2000 to ric1 with type1 and service1 via policy agent:"
86 curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_host:$policy_agent_port/policy?id=2000&ric=ric1&service=service1&type=1" --data-binary @testdata/policy.json
87 echo -e "\n"
88
89 echo "create policy 2001 to ric1 with type1 and service1 via policy agent:"
90 curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_host:$policy_agent_port/policy?id=2001&ric=ric1&service=service1&type=1" --data '{"scope": {"ueId": "ue3100","qosId": "qos3100"},"qosObjective": {"priorityLevel": 3101}}'
91 echo -e "\n"
92
93 echo "create policy 2002 to ric1 with type1 and service1 via policy agent:"
94 curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_host:$policy_agent_port/policy?id=2002&ric=ric1&service=service1&type=1" --data '{"scope": {"ueId": "ue3100","qosId": "qos3100"},"qosObjective": {"priorityLevel": 3102}}'
95 echo -e "\n"
96
97 echo "create policy 2003 to ric1 with type1 and service1 via policy agent:"
98 curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_host:$policy_agent_port/policy?id=2003&ric=ric1&service=service1&type=1" --data '{"scope": {"ueId": "ue3100","qosId": "qos3100"},"qosObjective": {"priorityLevel": 3103}}'
99 echo -e "\n"
100
101 echo "create policy 2004 to ric1 with type1 and service1 via policy agent:"
102 curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_host:$policy_agent_port/policy?id=2004&ric=ric1&service=service1&type=1" --data '{"scope": {"ueId": "ue3100","qosId": "qos3100"},"qosObjective": {"priorityLevel": 3104}}'
103 echo -e "\n"
104
105 echo "policy numbers from ric1:"
106 curl -skw " %{http_code}" $httpx://$a1_sim_osc_0_host:$a1_sim_osc_0_port/counter/num_instances
107 echo -e "\n"
108
109 echo "create policy 2100 to ric3 with service1 via policy agent, no type:"
110 curl -k -X PUT -sw " %{http_code}" -H accept:application/json -H Content-Type:application/json "$httpx://$policy_agent_host:$policy_agent_port/policy?id=2100&ric=ric3&service=service1" --data-binary @testdata/policy.json
111 echo -e "\n"
112
113 echo "policy numbers from ric3:"
114 curl -skw " %{http_code}" $httpx://$a1_sim_std_0_host:$a1_sim_std_0_port/counter/num_instances
115 echo -e "\n"
116
117 echo "policy id 2000 from policy agent:"
118 curl -k -X GET -sw " %{http_code}" $httpx://$policy_agent_host:$policy_agent_port/policy?id=2000
119 echo -e "\n"
120
121 echo "policy id 2100 from policy agent:"
122 curl -k -X GET -sw " %{http_code}" $httpx://$policy_agent_host:$policy_agent_port/policy?id=2100
123 echo -e "\n"