BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +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 | |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 20 | TC_ONELINE_DESCR="Repeatedly create and delete policies in each RICs for 24h (or configured number of days). Via agent REST/DMAAP/DMAAP_BATCH and SDNC using http or https" |
| 21 | |
| 22 | #App names to exclude checking pulling images for, space separated list |
| 23 | EXCLUDED_IMAGES="SDNC_ONAP" |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 24 | |
| 25 | . ../common/testcase_common.sh $@ |
| 26 | . ../common/agent_api_functions.sh |
| 27 | . ../common/ricsimulator_api_functions.sh |
| 28 | |
| 29 | #### TEST BEGIN #### |
| 30 | |
BjornMagnussonXA | ad04778 | 2020-06-08 15:54:11 +0200 | [diff] [blame] | 31 | generate_uuid |
| 32 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 33 | #Local vars in test script |
| 34 | ########################## |
| 35 | # Path to callback receiver |
| 36 | CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks" |
| 37 | # Number of RICs per interface type (OSC and STD) |
| 38 | NUM_RICS=30 |
| 39 | # Number of policy instances per RIC |
| 40 | NUM_INSTANCES=5 |
| 41 | |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 42 | DAYS=3 |
| 43 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 44 | clean_containers |
| 45 | |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 46 | # use http or https for all apis |
| 47 | HTTPX=https |
| 48 | |
| 49 | if [ $HTTPX == "http" ]; then |
| 50 | use_agent_rest_http |
| 51 | use_sdnc_http |
| 52 | use_simulator_http |
| 53 | else |
| 54 | use_agent_rest_https |
| 55 | use_sdnc_https |
| 56 | use_simulator_https |
| 57 | fi |
| 58 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 59 | start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0 |
| 60 | |
| 61 | start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3 |
| 62 | |
| 63 | start_mr |
| 64 | |
| 65 | start_cr |
| 66 | |
| 67 | start_consul_cbs |
| 68 | |
| 69 | prepare_consul_config SDNC ".consul_config.json" |
| 70 | consul_config_app ".consul_config.json" |
| 71 | |
| 72 | start_sdnc |
| 73 | |
| 74 | start_control_panel |
| 75 | |
| 76 | start_policy_agent |
| 77 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 78 | |
| 79 | api_get_status 200 |
| 80 | |
| 81 | echo "Print the interface for group 1 simulators, shall be OSC" |
| 82 | for ((i=1; i<=$NUM_RICS; i++)) |
| 83 | do |
| 84 | sim_print ricsim_g1_$i interface |
| 85 | done |
| 86 | |
| 87 | echo "Print the interface for group 2 simulators, shall be STD" |
| 88 | for ((i=1; i<=$NUM_RICS; i++)) |
| 89 | do |
| 90 | sim_print ricsim_g2_$i interface |
| 91 | done |
| 92 | |
| 93 | echo "Load policy type in group 1 simulators" |
| 94 | for ((i=1; i<=$NUM_RICS; i++)) |
| 95 | do |
| 96 | sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json |
| 97 | done |
| 98 | |
| 99 | echo "Check the number of instances in group 1 simulators, shall be 0" |
| 100 | for ((i=1; i<=$NUM_RICS; i++)) |
| 101 | do |
| 102 | sim_equal ricsim_g1_$i num_instances 0 |
| 103 | done |
| 104 | |
| 105 | echo "Check the number of instances in group 2 simulators, shall be 0" |
| 106 | for ((i=1; i<=$NUM_RICS; i++)) |
| 107 | do |
| 108 | sim_equal ricsim_g2_$i num_instances 0 |
| 109 | done |
| 110 | |
| 111 | echo "Wait for the agent to refresh types from the simulator" |
| 112 | api_equal json:policy_types 2 120 |
| 113 | |
| 114 | echo "Check the number of types in the agent for each ric is 1" |
| 115 | for ((i=1; i<=$NUM_RICS; i++)) |
| 116 | do |
| 117 | api_equal json:policy_types?ric=ricsim_g1_$i 1 120 |
| 118 | done |
| 119 | |
| 120 | echo "Register a service" |
| 121 | api_put_service 201 "serv1" 0 "$CR_PATH/1" |
| 122 | |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 123 | TEST_DURATION=$((24*3600*$DAYS)) |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 124 | TEST_START=$SECONDS |
| 125 | |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 126 | AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH" |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 127 | |
| 128 | MR_MESSAGES=0 |
| 129 | |
| 130 | while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do |
| 131 | |
| 132 | echo "" |
| 133 | echo "#########################################################################################################" |
| 134 | echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD |
| 135 | echo "#########################################################################################################" |
| 136 | echo "" |
| 137 | |
| 138 | for interface in $AGENT_INTERFACES ; do |
| 139 | |
| 140 | echo "############################################" |
| 141 | echo "## Testing using agent interface: $interface ##" |
| 142 | echo "############################################" |
| 143 | |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 144 | if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then |
| 145 | if [ $HTTPX == "http" ]; then |
| 146 | use_agent_rest_http |
| 147 | else |
| 148 | use_agent_rest_https |
| 149 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 150 | else |
| 151 | use_agent_dmaap |
| 152 | fi |
| 153 | |
| 154 | echo "Create $NUM_INSTANCES instances in each OSC RIC" |
| 155 | INSTANCE_ID=200000 |
| 156 | INSTANCES=0 |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 157 | if [ $interface == "REST_PARALLEL" ]; then |
| 158 | api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES 3 |
| 159 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 160 | for ((i=1; i<=$NUM_RICS; i++)) |
| 161 | do |
| 162 | if [ $interface == "DMAAP-BATCH" ]; then |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 163 | api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES |
| 164 | elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then |
| 165 | api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 166 | fi |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 167 | if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 168 | MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES)) |
| 169 | fi |
| 170 | sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES |
| 171 | INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) |
| 172 | INSTANCES=$(($INSTANCES+$NUM_INSTANCES)) |
| 173 | done |
| 174 | |
| 175 | api_equal json:policy_ids $INSTANCES |
| 176 | |
| 177 | echo "Create $NUM_INSTANCES instances in each STD RIC" |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 178 | if [ $interface == "REST_PARALLEL" ]; then |
| 179 | api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES 3 |
| 180 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 181 | for ((i=1; i<=$NUM_RICS; i++)) |
| 182 | do |
| 183 | if [ $interface == "DMAAP-BATCH" ]; then |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 184 | api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES |
| 185 | elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then |
| 186 | api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 187 | fi |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 188 | if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 189 | MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES)) |
| 190 | fi |
| 191 | sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES |
| 192 | INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) |
| 193 | INSTANCES=$(($INSTANCES+$NUM_INSTANCES)) |
| 194 | done |
| 195 | |
| 196 | api_equal json:policy_ids $INSTANCES |
| 197 | |
| 198 | |
| 199 | echo "Delete all instances in each OSC RIC" |
| 200 | |
| 201 | INSTANCE_ID=200000 |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 202 | if [ $interface == "REST_PARALLEL" ]; then |
| 203 | api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3 |
| 204 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 205 | for ((i=1; i<=$NUM_RICS; i++)) |
| 206 | do |
| 207 | if [ $interface == "DMAAP-BATCH" ]; then |
| 208 | api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 209 | elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 210 | api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES |
| 211 | fi |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 212 | if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 213 | MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES)) |
| 214 | fi |
| 215 | INSTANCES=$(($INSTANCES-$NUM_INSTANCES)) |
| 216 | sim_equal ricsim_g1_$i num_instances 0 |
| 217 | INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) |
| 218 | done |
| 219 | |
| 220 | api_equal json:policy_ids $INSTANCES |
| 221 | |
| 222 | echo "Delete all instances in each STD RIC" |
| 223 | |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 224 | if [ $interface == "REST_PARALLEL" ]; then |
| 225 | api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3 |
| 226 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 227 | for ((i=1; i<=$NUM_RICS; i++)) |
| 228 | do |
| 229 | if [ $interface == "DMAAP-BATCH" ]; then |
| 230 | api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 231 | elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 232 | api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES |
| 233 | fi |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 234 | if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 235 | MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES)) |
| 236 | fi |
| 237 | INSTANCES=$(($INSTANCES-$NUM_INSTANCES)) |
| 238 | sim_equal ricsim_g2_$i num_instances 0 |
| 239 | INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES)) |
| 240 | done |
| 241 | |
| 242 | api_equal json:policy_ids 0 |
| 243 | |
| 244 | cr_equal received_callbacks 0 |
| 245 | |
| 246 | mr_equal requests_submitted $MR_MESSAGES |
| 247 | mr_equal requests_fetched $MR_MESSAGES |
| 248 | mr_equal responses_submitted $MR_MESSAGES |
| 249 | mr_equal responses_fetched $MR_MESSAGES |
| 250 | mr_equal current_requests 0 |
| 251 | mr_equal current_responses 0 |
| 252 | |
| 253 | |
| 254 | for ((i=1; i<=$NUM_RICS; i++)) |
| 255 | do |
| 256 | sim_contains_str ricsim_g1_$i remote_hosts "a1-controller" |
| 257 | sim_contains_str ricsim_g2_$i remote_hosts "a1-controller" |
| 258 | done |
| 259 | |
| 260 | done |
| 261 | |
| 262 | done |
| 263 | |
| 264 | check_policy_agent_logs |
| 265 | |
| 266 | #### TEST COMPLETE #### |
| 267 | |
| 268 | store_logs END |
| 269 | |
| 270 | print_result |
| 271 | |
| 272 | auto_clean_containers |