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} |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 33 | a1_sim_STD_v1_port=${4:-30005} |
| 34 | httpx=${5:-"http"} |
ecaiyanlinux | 845bc00 | 2020-08-12 12:57:09 +0200 | [diff] [blame] | 35 | |
| 36 | echo "using dmaap-mr port: "$dmaa_mr_port |
| 37 | echo "using a1-sim-OSC port: "$a1_sim_OSC_port |
| 38 | echo "using a1-sim-STD port: "$a1_sim_STD_port |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 39 | echo "using a1-sim-STD-v1 port: "$a1_sim_STD_v1_port |
ecaiyanlinux | 845bc00 | 2020-08-12 12:57:09 +0200 | [diff] [blame] | 40 | echo "using protocol: "$httpx |
| 41 | echo -e "\n" |
| 42 | |
| 43 | echo "dmaap-mr topics:" |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 44 | curl -skw %{http_code} $httpx://localhost:$dmaa_mr_port/topics/listAll |
ecaiyanlinux | 845bc00 | 2020-08-12 12:57:09 +0200 | [diff] [blame] | 45 | echo -e "\n" |
| 46 | |
| 47 | echo "dmaap-mr create topic A1-POLICY-AGENT-READ:" |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 48 | 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\"}" |
ecaiyanlinux | 845bc00 | 2020-08-12 12:57:09 +0200 | [diff] [blame] | 49 | echo -e "\n" |
| 50 | |
| 51 | echo "dmaap-mr create topic A1-POLICY-AGENT-WRITE:" |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 52 | 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\"}" |
ecaiyanlinux | 845bc00 | 2020-08-12 12:57:09 +0200 | [diff] [blame] | 53 | echo -e "\n" |
| 54 | |
| 55 | echo "dmaap-mr topics:" |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 56 | curl -skw %{http_code} $httpx://localhost:$dmaa_mr_port/topics/listAll |
ecaiyanlinux | 845bc00 | 2020-08-12 12:57:09 +0200 | [diff] [blame] | 57 | echo -e "\n" |
| 58 | |
| 59 | echo "ric1 version:" |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 60 | curl -skw %{http_code} $httpx://localhost:$a1_sim_OSC_port/counter/interface |
ecaiyanlinux | 845bc00 | 2020-08-12 12:57:09 +0200 | [diff] [blame] | 61 | echo -e "\n" |
| 62 | |
| 63 | echo "ric2 version:" |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 64 | curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_port/counter/interface |
ecaiyanlinux | 845bc00 | 2020-08-12 12:57:09 +0200 | [diff] [blame] | 65 | echo -e "\n" |
| 66 | |
| 67 | echo "create policy type 1 to ric1:" |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 68 | 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 |
| 69 | echo -e "\n" |
| 70 | |
| 71 | echo "create policy type 2 to ric3:" |
ecaiyanlinux | e29568d | 2021-05-27 14:18:21 +0800 | [diff] [blame^] | 72 | curl -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/v2/policy_type.json |
ecaiyanlinux | 845bc00 | 2020-08-12 12:57:09 +0200 | [diff] [blame] | 73 | echo -e "\n" |
| 74 | |
| 75 | for 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" |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 80 | expect="[\"\",\"1\",\"2\"]200" |
ecaiyanlinux | 845bc00 | 2020-08-12 12:57:09 +0200 | [diff] [blame] | 81 | if [ "$res" == "$expect" ]; then |
| 82 | echo -e "\n" |
| 83 | break; |
| 84 | else |
| 85 | sleep $i |
| 86 | fi |
| 87 | done |
| 88 | |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 89 | ## Using PMS v1 interface |
ecaiyanlinux | 845bc00 | 2020-08-12 12:57:09 +0200 | [diff] [blame] | 90 | echo "create service 1 to policy agent via dmaap_mr:" |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 91 | 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/v1/dmaap-msg-service-create.json |
ecaiyanlinux | 845bc00 | 2020-08-12 12:57:09 +0200 | [diff] [blame] | 92 | echo -e "\n" |
| 93 | |
ecaiyanlinux | e29568d | 2021-05-27 14:18:21 +0800 | [diff] [blame^] | 94 | echo "get result from mr of previous request:" |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 95 | 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 . |
ecaiyanlinux | 845bc00 | 2020-08-12 12:57:09 +0200 | [diff] [blame] | 96 | echo -e "\n" |
| 97 | |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 98 | echo "create policies to ric1 & ric2 & ric3 with type1 and service1 via dmaa_mr:" |
| 99 | 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/v1/dmaap-msg-policy-create.json |
ecaiyanlinux | 845bc00 | 2020-08-12 12:57:09 +0200 | [diff] [blame] | 100 | echo -e "\n" |
| 101 | |
ecaiyanlinux | e29568d | 2021-05-27 14:18:21 +0800 | [diff] [blame^] | 102 | echo "get result from mr of previous request:" |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 103 | 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 . |
ecaiyanlinux | 845bc00 | 2020-08-12 12:57:09 +0200 | [diff] [blame] | 104 | echo -e "\n" |
| 105 | |
| 106 | echo "get policy from policy agent via dmaap_mr:" |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 107 | 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/v1/dmaap-msg-policy-get.json |
| 108 | echo -e "\n" |
| 109 | |
ecaiyanlinux | e29568d | 2021-05-27 14:18:21 +0800 | [diff] [blame^] | 110 | echo "get result from mr of previous request:" |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 111 | 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 . |
| 112 | echo -e "\n" |
| 113 | |
| 114 | ## Using PMS v2 interface |
| 115 | echo "create service 2 to policy agent via dmaap_mr:" |
| 116 | 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/v2/dmaap-msg-service-create.json |
| 117 | echo -e "\n" |
| 118 | |
ecaiyanlinux | e29568d | 2021-05-27 14:18:21 +0800 | [diff] [blame^] | 119 | echo "get result from mr of previous request:" |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 120 | 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 . |
| 121 | echo -e "\n" |
| 122 | |
| 123 | echo "create policies to ric1 & ric2 & ric3 with type1 and service1 via dmaa_mr:" |
| 124 | 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/v2/dmaap-msg-policy-create.json |
| 125 | echo -e "\n" |
| 126 | |
ecaiyanlinux | e29568d | 2021-05-27 14:18:21 +0800 | [diff] [blame^] | 127 | echo "get result from mr of previous request:" |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 128 | 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 . |
| 129 | echo -e "\n" |
| 130 | |
| 131 | echo "get policy from policy agent via dmaap_mr:" |
| 132 | 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/v2/dmaap-msg-policy-get.json |
| 133 | echo -e "\n" |
| 134 | |
ecaiyanlinux | e29568d | 2021-05-27 14:18:21 +0800 | [diff] [blame^] | 135 | echo "get result from mr of previous request:" |
ecaiyanlinux | 0b47c2b | 2021-02-03 16:24:33 +0100 | [diff] [blame] | 136 | 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 . |
| 137 | echo -e "\n" |
| 138 | |
| 139 | ## Get metric from rics |
| 140 | echo "policy numbers from ric1:" |
| 141 | curl -skw %{http_code} $httpx://localhost:$a1_sim_OSC_port/counter/num_instances |
| 142 | echo -e "\n" |
| 143 | |
| 144 | echo "policy numbers from ric2:" |
| 145 | curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_port/counter/num_instances |
| 146 | echo -e "\n" |
| 147 | |
| 148 | echo "policy numbers from ric3:" |
| 149 | curl -skw %{http_code} $httpx://localhost:$a1_sim_STD_v1_port/counter/num_instances |
| 150 | echo -e "\n" |
| 151 | |