blob: 6b19a4e3b050a7b9ce70ae78d356c5fd9c7cde27 [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:
ecaiyanlinux30f931f2020-11-10 22:45:48 +010028# ./preparePmsData.sh [policy-agent port] [a1-sim-OSC port] [a1-sim-STD port] [a1-sim-STD-v2 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}
ecaiyanlinux30f931f2020-11-10 22:45:48 +010033a1_sim_STD_v2_port=${4:-30005}
34httpx=${5:-"http"}
ecaiyanlinux426ce5f2020-05-30 15:17:59 +020035
36echo "using policy_agent port: "$policy_agent_port
37echo "using a1-sim-OSC port: "$a1_sim_OSC_port
38echo "using a1-sim-STD port: "$a1_sim_STD_port
ecaiyanlinux30f931f2020-11-10 22:45:48 +010039echo "using a1-sim-STD-v2 port: "$a1_sim_STD_v2_port
ecaiyanlinux426ce5f2020-05-30 15:17:59 +020040echo "using protocol: "$httpx
41echo -e "\n"
42
43echo "policy agent status:"
ecaiyanlinux30f931f2020-11-10 22:45:48 +010044curl -skw %{http_code} $httpx://localhost:$policy_agent_port/status
ecaiyanlinux426ce5f2020-05-30 15:17:59 +020045echo -e "\n"
46
47echo "ric1 version:"
ecaiyanlinux30f931f2020-11-10 22:45:48 +010048curl -skw %{http_code} $httpx://localhost:$a1_sim_OSC_port/counter/interface
ecaiyanlinux426ce5f2020-05-30 15:17:59 +020049echo -e "\n"
50
51echo "ric2 version:"
ecaiyanlinux30f931f2020-11-10 22:45:48 +010052curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_port/counter/interface
53echo -e "\n"
54
55echo "ric3 version:"
56curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_v2_port/counter/interface
ecaiyanlinux426ce5f2020-05-30 15:17:59 +020057echo -e "\n"
58
59echo "create policy type 1 to ric1:"
ecaiyanlinux30f931f2020-11-10 22:45:48 +010060curl -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
61echo -e "\n"
62
63echo "create policy type 2 to ric3:"
64curl -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
ecaiyanlinux426ce5f2020-05-30 15:17:59 +020065echo -e "\n"
66
67for i in {1..12}; do
68 echo "policy types from policy agent:"
ecaiyanlinux30f931f2020-11-10 22:45:48 +010069 curlString="curl -skw %{http_code} $httpx://localhost:$policy_agent_port/a1-policy/v2/policy-types"
ecaiyanlinux426ce5f2020-05-30 15:17:59 +020070 res=$($curlString)
71 echo "$res"
ecaiyanlinux30f931f2020-11-10 22:45:48 +010072 expect="{\"policytype_ids\":[\"\",\"1\",\"2\"]}200"
ecaiyanlinux426ce5f2020-05-30 15:17:59 +020073 if [ "$res" == "$expect" ]; then
74 echo -e "\n"
75 break;
76 else
77 sleep $i
78 fi
79done
80
ecaiyanlinux30f931f2020-11-10 22:45:48 +010081echo "create service ric-registration to policy agent:"
82curl -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
ecaiyanlinux426ce5f2020-05-30 15:17:59 +020083echo -e "\n"
84
ecaiyanlinux30f931f2020-11-10 22:45:48 +010085echo "create policy aa8feaa88d944d919ef0e83f2172a5000 to ric1 with type 1 and service controlpanel via policy agent:"
86curl -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
ecaiyanlinux426ce5f2020-05-30 15:17:59 +020087echo -e "\n"
88
89echo "policy numbers from ric1:"
ecaiyanlinux30f931f2020-11-10 22:45:48 +010090curl -skw %{http_code} $httpx://localhost:$a1_sim_OSC_port/counter/num_instances
ecaiyanlinux426ce5f2020-05-30 15:17:59 +020091echo -e "\n"
92
ecaiyanlinux30f931f2020-11-10 22:45:48 +010093echo "create policy aa8feaa88d944d919ef0e83f2172a5100 to ric2 with type 2 and service controlpanel via policy agent:"
94curl -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
ecaiyanlinux426ce5f2020-05-30 15:17:59 +020095echo -e "\n"
96
ecaiyanlinux30f931f2020-11-10 22:45:48 +010097echo "policy numbers from ric3:"
98curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_v2_port/counter/num_instances
ecaiyanlinux426ce5f2020-05-30 15:17:59 +020099echo -e "\n"
100
ecaiyanlinux30f931f2020-11-10 22:45:48 +0100101echo "policy id aa8feaa88d944d919ef0e83f2172a5000 from policy agent:"
102curl -k -X GET -sw %{http_code} $httpx://localhost:$policy_agent_port/a1-policy/v2/policies/aa8feaa88d944d919ef0e83f2172a5000
ecaiyanlinux426ce5f2020-05-30 15:17:59 +0200103echo -e "\n"
104
ecaiyanlinux30f931f2020-11-10 22:45:48 +0100105echo "policy id aa8feaa88d944d919ef0e83f2172a5100 from policy agent:"
106curl -k -X GET -sw %{http_code} $httpx://localhost:$policy_agent_port/a1-policy/v2/policies/aa8feaa88d944d919ef0e83f2172a5100
ecaiyanlinux426ce5f2020-05-30 15:17:59 +0200107echo -e "\n"