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
10 # http://www.apache.org/licenses/LICENSE-2.0
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=================================================
20 # The scripts in data/ will generate some dummy data in the running system.
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
28 # ./prepareDmaapMsg.sh [dmaap-mr port] [a1-sim-OSC port] [a1-sim-STD port] [http/https]
30 dmaa_mr_port=${1:-3904}
31 a1_sim_OSC_port=${2:-30001}
32 a1_sim_STD_port=${3:-30003}
33 a1_sim_STD_v2_port=${4:-30005}
35 SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
37 echo "using dmaap-mr port: "$dmaa_mr_port
38 echo "using a1-sim-OSC port: "$a1_sim_OSC_port
39 echo "using a1-sim-STD port: "$a1_sim_STD_port
40 echo "using a1-sim-STD-v2 port: "$a1_sim_STD_v2_port
41 echo "using protocol: "$httpx
44 echo "dmaap-mr topics:"
45 curl -skw %{http_code} $httpx://localhost:$dmaa_mr_port/topics/listAll
48 echo "dmaap-mr create topic A1-POLICY-AGENT-READ:"
49 curl -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\"}"
52 echo "dmaap-mr create topic A1-POLICY-AGENT-WRITE:"
53 curl -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\"}"
56 echo "dmaap-mr topics:"
57 curl -skw %{http_code} $httpx://localhost:$dmaa_mr_port/topics/listAll
61 curl -skw %{http_code} $httpx://localhost:$a1_sim_OSC_port/counter/interface
65 curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_port/counter/interface
69 curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_v2_port/counter/interface
72 echo "create policy type 1 to ric1:"
73 curl -X PUT -skw %{http_code} $httpx://localhost:$a1_sim_OSC_port/policytype?id=1 -H Content-Type:application/json --data-binary @${SHELL_FOLDER}/testdata/OSC/policy_type.json
76 echo "create policy type 2 to ric3:"
77 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 @${SHELL_FOLDER}/testdata/v2/policy_type.json
81 echo "policy types from policy agent:"
82 curlString="curl -skw %{http_code} $httpx://localhost:8091/policy_types"
85 expect="[\"1\",\"2\"]200"
86 if [ "$res" == "$expect" ]; then
94 ## Using PMS v1 interface
95 echo "create service 1 to policy agent via dmaap_mr:"
96 curl -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 @${SHELL_FOLDER}/testdata/dmaap/v1/dmaap-msg-service-create.json
99 echo "get result from mr of previous request:"
100 curl -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 .
103 echo "create policies to ric1 & ric2 & ric3 with type1 and service1 via dmaa_mr:"
104 curl -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 @${SHELL_FOLDER}/testdata/dmaap/v1/dmaap-msg-policy-create.json
107 echo "get result from mr of previous request:"
108 curl -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 .
111 echo "get policy from policy agent via dmaap_mr:"
112 curl -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 @${SHELL_FOLDER}/testdata/dmaap/v1/dmaap-msg-policy-get.json
115 echo "get result from mr of previous request:"
116 curl -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 .
119 ## Using PMS v2 interface
120 echo "create service 2 to policy agent via dmaap_mr:"
121 curl -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 @${SHELL_FOLDER}/testdata/dmaap/v2/dmaap-msg-service-create.json
124 echo "get result from mr of previous request:"
125 curl -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 .
128 echo "create policies to ric1 & ric2 & ric3 with type1 and service1 via dmaa_mr:"
129 curl -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 @${SHELL_FOLDER}/testdata/dmaap/v2/dmaap-msg-policy-create.json
132 echo "get result from mr of previous request:"
133 curl -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 .
136 echo "get policy from policy agent via dmaap_mr:"
137 curl -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 @${SHELL_FOLDER}/testdata/dmaap/v2/dmaap-msg-policy-get.json
140 echo "get result from mr of previous request:"
141 curl -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 .
144 ## Get metric from rics
145 echo "policy numbers from ric1:"
146 curl -skw %{http_code} $httpx://localhost:$a1_sim_OSC_port/counter/num_instances
149 echo "policy numbers from ric2:"
150 curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_port/counter/num_instances
153 echo "policy numbers from ric3:"
154 curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_v2_port/counter/num_instances