blob: 94afc6e91fe1d59aa56bc440101ce2c0dc3dc22c [file] [log] [blame]
ecaiyanlinux426ce5f2020-05-30 15:17:59 +02001#!/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:
ecaiyanlinuxdc962f42020-10-19 11:13:12 +020028# ./preparePmsData.sh [policy-agent port] [a1-sim-OSC port] [a1-sim-STD port] [http/https]
ecaiyanlinux426ce5f2020-05-30 15:17:59 +020029
30policy_agent_port=${1:-8081}
31a1_sim_OSC_port=${2:-30001}
32a1_sim_STD_port=${3:-30003}
33httpx=${4:-"http"}
34
35echo "using policy_agent port: "$policy_agent_port
36echo "using a1-sim-OSC port: "$a1_sim_OSC_port
37echo "using a1-sim-STD port: "$a1_sim_STD_port
38echo "using protocol: "$httpx
39echo -e "\n"
40
41echo "policy agent status:"
42curl -skw " %{http_code}" $httpx://localhost:$policy_agent_port/status
43echo -e "\n"
44
45echo "ric1 version:"
46curl -skw " %{http_code}" $httpx://localhost:$a1_sim_OSC_port/counter/interface
47echo -e "\n"
48
49echo "ric2 version:"
50curl -skw " %{http_code}" $httpx://localhost:$a1_sim_STD_port/counter/interface
51echo -e "\n"
52
53echo "create policy type 1 to ric1:"
54curl -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
55echo -e "\n"
56
57for i in {1..12}; do
58 echo "policy types from policy agent:"
59 curlString="curl -skw %{http_code} $httpx://localhost:$policy_agent_port/policy_types"
60 res=$($curlString)
61 echo "$res"
62 expect="[\"\",\"1\"]200"
63 if [ "$res" == "$expect" ]; then
64 echo -e "\n"
65 break;
66 else
67 sleep $i
68 fi
69done
70
71echo "create service 1 to policy agent:"
72curl -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
73echo -e "\n"
74
75echo "create policy 2000 to ric1 with type1 and service1 via policy agent:"
76curl -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
77echo -e "\n"
78
79echo "policy numbers from ric1:"
80curl -skw " %{http_code}" $httpx://localhost:$a1_sim_OSC_port/counter/num_instances
81echo -e "\n"
82
83echo "create policy 2100 to ric2 with service1 via policy agent, no type:"
84curl -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
85echo -e "\n"
86
87echo "policy numbers from ric2:"
88curl -skw " %{http_code}" $httpx://localhost:$a1_sim_STD_port/counter/num_instances
89echo -e "\n"
90
91echo "policy id 2000 from policy agent:"
92curl -k -X GET -sw " %{http_code}" $httpx://localhost:$policy_agent_port/policy?id=2000
93echo -e "\n"
94
95echo "policy id 2100 from policy agent:"
96curl -k -X GET -sw " %{http_code}" $httpx://localhost:$policy_agent_port/policy?id=2100
97echo -e "\n"