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