blob: 503b0d20a36d4675a479304494a7b4ade750764b [file] [log] [blame]
ecaiyanlinux845bc002020-08-12 12:57:09 +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# ./prepareDmaapMsg.sh [dmaap-mr port] [a1-sim-OSC port] [a1-sim-STD port] [http/https]
ecaiyanlinux845bc002020-08-12 12:57:09 +020029
30dmaa_mr_port=${1:-3904}
31a1_sim_OSC_port=${2:-30001}
32a1_sim_STD_port=${3:-30003}
ecaiyanlinux0b47c2b2021-02-03 16:24:33 +010033a1_sim_STD_v1_port=${4:-30005}
34httpx=${5:-"http"}
ecaiyanlinux845bc002020-08-12 12:57:09 +020035
36echo "using dmaap-mr port: "$dmaa_mr_port
37echo "using a1-sim-OSC port: "$a1_sim_OSC_port
38echo "using a1-sim-STD port: "$a1_sim_STD_port
ecaiyanlinux0b47c2b2021-02-03 16:24:33 +010039echo "using a1-sim-STD-v1 port: "$a1_sim_STD_v1_port
ecaiyanlinux845bc002020-08-12 12:57:09 +020040echo "using protocol: "$httpx
41echo -e "\n"
42
43echo "dmaap-mr topics:"
ecaiyanlinux0b47c2b2021-02-03 16:24:33 +010044curl -skw %{http_code} $httpx://localhost:$dmaa_mr_port/topics/listAll
ecaiyanlinux845bc002020-08-12 12:57:09 +020045echo -e "\n"
46
47echo "dmaap-mr create topic A1-POLICY-AGENT-READ:"
ecaiyanlinux0b47c2b2021-02-03 16:24:33 +010048curl -skw %{http_code} -X POST "$httpx://localhost:$dmaa_mr_port/topics/create" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"topicName\": \"A1-POLICY-AGENT-READ\", \"topicDescription\": \"test topic\", \"partitionCount\": 1, \"replicationCount\": 1, \"transactionEnabled\": \"false\"}"
ecaiyanlinux845bc002020-08-12 12:57:09 +020049echo -e "\n"
50
51echo "dmaap-mr create topic A1-POLICY-AGENT-WRITE:"
ecaiyanlinux0b47c2b2021-02-03 16:24:33 +010052curl -skw %{http_code} -X POST "$httpx://localhost:$dmaa_mr_port/topics/create" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"topicName\": \"A1-POLICY-AGENT-WRITE\", \"topicDescription\": \"test topic\", \"partitionCount\": 1, \"replicationCount\": 1, \"transactionEnabled\": \"false\"}"
ecaiyanlinux845bc002020-08-12 12:57:09 +020053echo -e "\n"
54
55echo "dmaap-mr topics:"
ecaiyanlinux0b47c2b2021-02-03 16:24:33 +010056curl -skw %{http_code} $httpx://localhost:$dmaa_mr_port/topics/listAll
ecaiyanlinux845bc002020-08-12 12:57:09 +020057echo -e "\n"
58
59echo "ric1 version:"
ecaiyanlinux0b47c2b2021-02-03 16:24:33 +010060curl -skw %{http_code} $httpx://localhost:$a1_sim_OSC_port/counter/interface
ecaiyanlinux845bc002020-08-12 12:57:09 +020061echo -e "\n"
62
63echo "ric2 version:"
ecaiyanlinux0b47c2b2021-02-03 16:24:33 +010064curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_port/counter/interface
ecaiyanlinux845bc002020-08-12 12:57:09 +020065echo -e "\n"
66
67echo "create policy type 1 to ric1:"
ecaiyanlinux0b47c2b2021-02-03 16:24:33 +010068curl -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
69echo -e "\n"
70
71echo "create policy type 2 to ric3:"
72curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_v1_port/policytype?id=2 -X PUT -H Accept:application/json -H Content-Type:application/json -H X-Requested-With:XMLHttpRequest --data-binary @testdata/v1/policy_type.json
ecaiyanlinux845bc002020-08-12 12:57:09 +020073echo -e "\n"
74
75for i in {1..12}; do
76 echo "policy types from policy agent:"
77 curlString="curl -skw %{http_code} $httpx://localhost:8081/policy_types"
78 res=$($curlString)
79 echo "$res"
ecaiyanlinux0b47c2b2021-02-03 16:24:33 +010080 expect="[\"\",\"1\",\"2\"]200"
ecaiyanlinux845bc002020-08-12 12:57:09 +020081 if [ "$res" == "$expect" ]; then
82 echo -e "\n"
83 break;
84 else
85 sleep $i
86 fi
87done
88
ecaiyanlinux0b47c2b2021-02-03 16:24:33 +010089## Using PMS v1 interface
ecaiyanlinux845bc002020-08-12 12:57:09 +020090echo "create service 1 to policy agent via dmaap_mr:"
ecaiyanlinux0b47c2b2021-02-03 16:24:33 +010091curl -k -X POST -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$dmaa_mr_port/events/A1-POLICY-AGENT-READ/" --data-binary @testdata/dmaap/v1/dmaap-msg-service-create.json
ecaiyanlinux845bc002020-08-12 12:57:09 +020092echo -e "\n"
93
ecaiyanlinux0b47c2b2021-02-03 16:24:33 +010094echo "ger result from mr of previous request:"
95curl -X GET "$httpx://localhost:$dmaa_mr_port/events/A1-POLICY-AGENT-WRITE/users/policy-agent?timeout=15000&limit=100" -H "accept: application/json" -H "Content-Type: application/json" | jq .
ecaiyanlinux845bc002020-08-12 12:57:09 +020096echo -e "\n"
97
ecaiyanlinux0b47c2b2021-02-03 16:24:33 +010098echo "create policies to ric1 & ric2 & ric3 with type1 and service1 via dmaa_mr:"
99curl -k -X POST -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$dmaa_mr_port/events/A1-POLICY-AGENT-READ/" --data-binary @testdata/dmaap/v1/dmaap-msg-policy-create.json
ecaiyanlinux845bc002020-08-12 12:57:09 +0200100echo -e "\n"
101
ecaiyanlinux0b47c2b2021-02-03 16:24:33 +0100102echo "ger result from mr of previous request:"
103curl -X GET "$httpx://localhost:$dmaa_mr_port/events/A1-POLICY-AGENT-WRITE/users/policy-agent?timeout=15000&limit=100" -H "accept: application/json" -H "Content-Type: application/json" | jq .
ecaiyanlinux845bc002020-08-12 12:57:09 +0200104echo -e "\n"
105
106echo "get policy from policy agent via dmaap_mr:"
ecaiyanlinux0b47c2b2021-02-03 16:24:33 +0100107curl -k -X POST -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$dmaa_mr_port/events/A1-POLICY-AGENT-READ/" --data-binary @testdata/dmaap/v1/dmaap-msg-policy-get.json
108echo -e "\n"
109
110echo "ger result from mr of previous request:"
111curl -X GET "$httpx://localhost:$dmaa_mr_port/events/A1-POLICY-AGENT-WRITE/users/policy-agent?timeout=15000&limit=100" -H "accept: application/json" -H "Content-Type: application/json" | jq .
112echo -e "\n"
113
114## Using PMS v2 interface
115echo "create service 2 to policy agent via dmaap_mr:"
116curl -k -X POST -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$dmaa_mr_port/events/A1-POLICY-AGENT-READ/" --data-binary @testdata/dmaap/v2/dmaap-msg-service-create.json
117echo -e "\n"
118
119echo "ger result from mr of previous request:"
120curl -X GET "$httpx://localhost:$dmaa_mr_port/events/A1-POLICY-AGENT-WRITE/users/policy-agent?timeout=15000&limit=100" -H "accept: application/json" -H "Content-Type: application/json" | jq .
121echo -e "\n"
122
123echo "create policies to ric1 & ric2 & ric3 with type1 and service1 via dmaa_mr:"
124curl -k -X POST -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$dmaa_mr_port/events/A1-POLICY-AGENT-READ/" --data-binary @testdata/dmaap/v2/dmaap-msg-policy-create.json
125echo -e "\n"
126
127echo "ger result from mr of previous request:"
128curl -X GET "$httpx://localhost:$dmaa_mr_port/events/A1-POLICY-AGENT-WRITE/users/policy-agent?timeout=15000&limit=100" -H "accept: application/json" -H "Content-Type: application/json" | jq .
129echo -e "\n"
130
131echo "get policy from policy agent via dmaap_mr:"
132curl -k -X POST -sw %{http_code} -H accept:application/json -H Content-Type:application/json "$httpx://localhost:$dmaa_mr_port/events/A1-POLICY-AGENT-READ/" --data-binary @testdata/dmaap/v2/dmaap-msg-policy-get.json
133echo -e "\n"
134
135echo "ger result from mr of previous request:"
136curl -X GET "$httpx://localhost:$dmaa_mr_port/events/A1-POLICY-AGENT-WRITE/users/policy-agent?timeout=15000&limit=100" -H "accept: application/json" -H "Content-Type: application/json" | jq .
137echo -e "\n"
138
139## Get metric from rics
140echo "policy numbers from ric1:"
141curl -skw %{http_code} $httpx://localhost:$a1_sim_OSC_port/counter/num_instances
142echo -e "\n"
143
144echo "policy numbers from ric2:"
145curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_port/counter/num_instances
146echo -e "\n"
147
148echo "policy numbers from ric3:"
149curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_v1_port/counter/num_instances
150echo -e "\n"
151