ecaiyanlinux | 845bc00 | 2020-08-12 12:57:09 +0200 | [diff] [blame] | 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 |
| 23 | # one service in policy agent |
| 24 | # one policy in a1-sim-OSC |
| 25 | # one policy in a1-sim-STD |
| 26 | |
| 27 | # Run command: |
ecaiyanlinux | dc962f4 | 2020-10-19 11:13:12 +0200 | [diff] [blame] | 28 | # ./prepareDmaapMsg.sh [dmaap-mr port] [a1-sim-OSC port] [a1-sim-STD port] [http/https] |
ecaiyanlinux | 845bc00 | 2020-08-12 12:57:09 +0200 | [diff] [blame] | 29 | |
| 30 | dmaa_mr_port=${1:-3904} |
| 31 | a1_sim_OSC_port=${2:-30001} |
| 32 | a1_sim_STD_port=${3:-30003} |
| 33 | httpx=${4:-"http"} |
| 34 | |
| 35 | echo "using dmaap-mr port: "$dmaa_mr_port |
| 36 | echo "using a1-sim-OSC port: "$a1_sim_OSC_port |
| 37 | echo "using a1-sim-STD port: "$a1_sim_STD_port |
| 38 | echo "using protocol: "$httpx |
| 39 | echo -e "\n" |
| 40 | |
| 41 | echo "dmaap-mr topics:" |
| 42 | curl -skw " %{http_code}" $httpx://localhost:$dmaa_mr_port/topics/listAll |
| 43 | echo -e "\n" |
| 44 | |
| 45 | echo "dmaap-mr create topic A1-POLICY-AGENT-READ:" |
| 46 | 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\"}" |
| 47 | echo -e "\n" |
| 48 | |
| 49 | echo "dmaap-mr create topic A1-POLICY-AGENT-WRITE:" |
| 50 | 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\"}" |
| 51 | echo -e "\n" |
| 52 | |
| 53 | echo "dmaap-mr topics:" |
| 54 | curl -skw " %{http_code}" $httpx://localhost:$dmaa_mr_port/topics/listAll |
| 55 | echo -e "\n" |
| 56 | |
| 57 | echo "ric1 version:" |
| 58 | curl -skw " %{http_code}" $httpx://localhost:$a1_sim_OSC_port/counter/interface |
| 59 | echo -e "\n" |
| 60 | |
| 61 | echo "ric2 version:" |
| 62 | curl -skw " %{http_code}" $httpx://localhost:$a1_sim_STD_port/counter/interface |
| 63 | echo -e "\n" |
| 64 | |
| 65 | echo "create policy type 1 to ric1:" |
| 66 | curl -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 |
| 67 | echo -e "\n" |
| 68 | |
| 69 | for i in {1..12}; do |
| 70 | echo "policy types from policy agent:" |
| 71 | curlString="curl -skw %{http_code} $httpx://localhost:8081/policy_types" |
| 72 | res=$($curlString) |
| 73 | echo "$res" |
| 74 | expect="[\"\",\"1\"]200" |
| 75 | if [ "$res" == "$expect" ]; then |
| 76 | echo -e "\n" |
| 77 | break; |
| 78 | else |
| 79 | sleep $i |
| 80 | fi |
| 81 | done |
| 82 | |
| 83 | echo "create service 1 to policy agent via dmaap_mr:" |
| 84 | 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 @testdata/dmaap-msg-service-create.json |
| 85 | echo -e "\n" |
| 86 | |
| 87 | echo "create policies to ric1 & ric2 with type1 and service1 via dmaa_mr:" |
| 88 | 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 @testdata/dmaap-msg-policy-create.json |
| 89 | echo -e "\n" |
| 90 | |
| 91 | echo "policy numbers from ric1:" |
| 92 | curl -skw " %{http_code}" $httpx://localhost:$a1_sim_OSC_port/counter/num_instances |
| 93 | echo -e "\n" |
| 94 | |
| 95 | echo "policy numbers from ric2:" |
| 96 | curl -skw " %{http_code}" $httpx://localhost:$a1_sim_STD_port/counter/num_instances |
| 97 | echo -e "\n" |
| 98 | |
| 99 | echo "get policy from policy agent via dmaap_mr:" |
| 100 | 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 @testdata/dmaap-msg-policy-get.json |
| 101 | echo -e "\n" |