BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +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 | TC_ONELINE_DESCR="Change supported policy types and reconfigure rics" |
| 21 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 22 | #App names to include in the test, space separated list |
| 23 | INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +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 | bbd2e9d | 2020-05-27 21:24:06 +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" |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 37 | use_cr_http |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 38 | |
| 39 | NUM_RICS=10 |
| 40 | NUM_RICS_2=$(($NUM_RICS-2)) |
| 41 | |
| 42 | # Tested variants of REST/SDNC config |
| 43 | TESTED_VARIANTS="REST REST+SDNC" |
| 44 | |
| 45 | for interface in $TESTED_VARIANTS ; do |
| 46 | |
| 47 | echo "#####################################################################" |
| 48 | echo "#####################################################################" |
| 49 | echo "### Testing agent: "$interface |
| 50 | echo "#####################################################################" |
| 51 | echo "#####################################################################" |
| 52 | |
| 53 | |
| 54 | # Clean container and start all needed containers # |
| 55 | clean_containers |
| 56 | |
| 57 | #Start simulators and prepare two configs |
| 58 | |
| 59 | start_ric_simulators ricsim_g1 $NUM_RICS_2 OSC_2.1.0 |
| 60 | |
| 61 | start_cr |
| 62 | |
| 63 | start_mr |
| 64 | |
| 65 | start_consul_cbs |
| 66 | |
| 67 | if [[ $interface = *"SDNC"* ]]; then |
| 68 | start_sdnc |
| 69 | prepare_consul_config SDNC ".consul_config_2.json" |
| 70 | else |
| 71 | prepare_consul_config NOSDNC ".consul_config_2.json" |
| 72 | fi |
| 73 | |
| 74 | consul_config_app ".consul_config_2.json" |
| 75 | |
| 76 | |
| 77 | # Create 2nd config and save for later |
| 78 | start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0 |
| 79 | |
| 80 | if [[ $interface = *"SDNC"* ]]; then |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 81 | prepare_consul_config SDNC ".consul_config_all.json" |
| 82 | else |
| 83 | prepare_consul_config NOSDNC ".consul_config_all.json" |
| 84 | fi |
| 85 | |
| 86 | start_policy_agent |
| 87 | |
| 88 | set_agent_debug |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 89 | set_agent_trace |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 90 | |
| 91 | api_get_status 200 |
| 92 | |
| 93 | for ((i=1; i<=${NUM_RICS}; i++)) |
| 94 | do |
| 95 | sim_print ricsim_g1_$i interface |
| 96 | done |
| 97 | |
| 98 | # All sims running but 2 are not configured in consul |
| 99 | api_equal json:rics 8 120 |
| 100 | |
| 101 | api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:NOTYPE:???? \ |
| 102 | ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:NOTYPE:???? \ |
| 103 | ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:NOTYPE:???? \ |
| 104 | ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:NOTYPE:???? \ |
| 105 | ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:NOTYPE:???? \ |
| 106 | ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:NOTYPE:???? \ |
| 107 | ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:NOTYPE:???? \ |
| 108 | ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:NOTYPE:???? " |
| 109 | |
| 110 | |
| 111 | sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json |
| 112 | sim_put_policy_type 201 ricsim_g1_2 1 testdata/OSC/sim_1.json |
| 113 | sim_put_policy_type 201 ricsim_g1_3 1 testdata/OSC/sim_1.json |
| 114 | sim_put_policy_type 201 ricsim_g1_4 1 testdata/OSC/sim_1.json |
| 115 | sim_put_policy_type 201 ricsim_g1_5 1 testdata/OSC/sim_1.json |
| 116 | |
| 117 | sim_put_policy_type 201 ricsim_g1_2 2 testdata/OSC/sim_2.json |
| 118 | sim_put_policy_type 201 ricsim_g1_3 2 testdata/OSC/sim_2.json |
| 119 | sim_put_policy_type 201 ricsim_g1_4 2 testdata/OSC/sim_2.json |
| 120 | sim_put_policy_type 201 ricsim_g1_5 2 testdata/OSC/sim_2.json |
| 121 | sim_put_policy_type 201 ricsim_g1_6 2 testdata/OSC/sim_2.json |
| 122 | |
| 123 | sim_put_policy_type 201 ricsim_g1_3 3 testdata/OSC/sim_3.json |
| 124 | sim_put_policy_type 201 ricsim_g1_4 3 testdata/OSC/sim_3.json |
| 125 | sim_put_policy_type 201 ricsim_g1_5 3 testdata/OSC/sim_3.json |
| 126 | sim_put_policy_type 201 ricsim_g1_6 3 testdata/OSC/sim_3.json |
| 127 | sim_put_policy_type 201 ricsim_g1_7 3 testdata/OSC/sim_3.json |
| 128 | |
| 129 | sim_put_policy_type 201 ricsim_g1_4 4 testdata/OSC/sim_4.json |
| 130 | sim_put_policy_type 201 ricsim_g1_5 4 testdata/OSC/sim_4.json |
| 131 | sim_put_policy_type 201 ricsim_g1_6 4 testdata/OSC/sim_4.json |
| 132 | sim_put_policy_type 201 ricsim_g1_7 4 testdata/OSC/sim_4.json |
| 133 | sim_put_policy_type 201 ricsim_g1_8 4 testdata/OSC/sim_4.json |
| 134 | |
| 135 | sim_put_policy_type 201 ricsim_g1_5 5 testdata/OSC/sim_5.json |
| 136 | sim_put_policy_type 201 ricsim_g1_6 5 testdata/OSC/sim_5.json |
| 137 | sim_put_policy_type 201 ricsim_g1_7 5 testdata/OSC/sim_5.json |
| 138 | sim_put_policy_type 201 ricsim_g1_8 5 testdata/OSC/sim_5.json |
| 139 | sim_put_policy_type 201 ricsim_g1_9 5 testdata/OSC/sim_5.json |
| 140 | |
| 141 | api_equal json:policy_types 5 120 |
| 142 | |
| 143 | echo "Check the number of types in the agent for each ric" |
| 144 | api_equal json:policy_types?ric=ricsim_g1_1 1 120 |
| 145 | api_equal json:policy_types?ric=ricsim_g1_2 2 120 |
| 146 | api_equal json:policy_types?ric=ricsim_g1_3 3 120 |
| 147 | api_equal json:policy_types?ric=ricsim_g1_4 4 120 |
| 148 | api_equal json:policy_types?ric=ricsim_g1_5 5 120 |
| 149 | api_equal json:policy_types?ric=ricsim_g1_6 4 120 |
| 150 | api_equal json:policy_types?ric=ricsim_g1_7 3 120 |
| 151 | api_equal json:policy_types?ric=ricsim_g1_8 2 120 |
| 152 | |
| 153 | api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \ |
| 154 | ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \ |
| 155 | ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \ |
| 156 | ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3,4:???? \ |
| 157 | ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,4,5:???? \ |
| 158 | ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,4,5:???? \ |
| 159 | ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,4,5:???? \ |
| 160 | ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? " |
| 161 | |
| 162 | |
| 163 | #Load config with all rics |
| 164 | consul_config_app ".consul_config_all.json" |
| 165 | |
| 166 | api_equal json:rics 10 120 |
| 167 | |
| 168 | echo "Check the number of types in the agent for each ric" |
| 169 | api_equal json:policy_types?ric=ricsim_g1_1 1 120 |
| 170 | api_equal json:policy_types?ric=ricsim_g1_2 2 120 |
| 171 | api_equal json:policy_types?ric=ricsim_g1_3 3 120 |
| 172 | api_equal json:policy_types?ric=ricsim_g1_4 4 120 |
| 173 | api_equal json:policy_types?ric=ricsim_g1_5 5 120 |
| 174 | api_equal json:policy_types?ric=ricsim_g1_6 4 120 |
| 175 | api_equal json:policy_types?ric=ricsim_g1_7 3 120 |
| 176 | api_equal json:policy_types?ric=ricsim_g1_8 2 120 |
| 177 | api_equal json:policy_types?ric=ricsim_g1_9 1 120 |
| 178 | api_equal json:policy_types?ric=ricsim_g1_10 0 120 |
| 179 | |
| 180 | api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \ |
| 181 | ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \ |
| 182 | ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \ |
| 183 | ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3,4:???? \ |
| 184 | ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,4,5:???? \ |
| 185 | ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,4,5:???? \ |
| 186 | ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,4,5:???? \ |
| 187 | ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? \ |
| 188 | ricsim_g1_9:me1_ricsim_g1_9,me2_ricsim_g1_9:5:???? \ |
| 189 | ricsim_g1_10:me1_ricsim_g1_10,me2_ricsim_g1_10:NOTYPE:???? " |
| 190 | |
| 191 | |
| 192 | #No policy type in sim #10 |
| 193 | |
| 194 | api_equal json:policy_types 5 |
| 195 | |
| 196 | api_put_service 201 "serv1" 3600 "$CR_PATH/serv1" |
| 197 | |
| 198 | api_put_policy 201 "serv1" ricsim_g1_9 5 2000 NOTRANSIENT testdata/OSC/pi5_template.json 1 |
| 199 | |
| 200 | api_equal json:policy_ids 1 |
| 201 | |
| 202 | sim_equal ricsim_g1_9 num_instances 1 |
| 203 | |
| 204 | |
| 205 | # Load config with reduced number of rics |
| 206 | consul_config_app ".consul_config_2.json" |
| 207 | |
| 208 | api_equal json:rics 8 120 |
| 209 | |
| 210 | echo "Check the number of types in the agent for each ric" |
| 211 | api_equal json:policy_types?ric=ricsim_g1_1 1 120 |
| 212 | api_equal json:policy_types?ric=ricsim_g1_2 2 120 |
| 213 | api_equal json:policy_types?ric=ricsim_g1_3 3 120 |
| 214 | api_equal json:policy_types?ric=ricsim_g1_4 4 120 |
| 215 | api_equal json:policy_types?ric=ricsim_g1_5 5 120 |
| 216 | api_equal json:policy_types?ric=ricsim_g1_6 4 120 |
| 217 | api_equal json:policy_types?ric=ricsim_g1_7 3 120 |
| 218 | api_equal json:policy_types?ric=ricsim_g1_8 2 120 |
| 219 | |
| 220 | api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \ |
| 221 | ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \ |
| 222 | ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \ |
| 223 | ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3,4:???? \ |
| 224 | ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,4,5:???? \ |
| 225 | ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,4,5:???? \ |
| 226 | ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,4,5:???? \ |
| 227 | ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? " |
| 228 | |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 229 | sleep_wait 120 |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 230 | |
| 231 | api_equal json:policy_ids 0 |
| 232 | |
| 233 | api_get_policy_types 404 ricsim_g1_9 |
| 234 | |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 235 | sim_equal ricsim_g1_9 num_instances 0 |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 236 | |
| 237 | api_delete_policy 404 2000 |
| 238 | |
| 239 | # Load config with all rics |
| 240 | consul_config_app ".consul_config_all.json" |
| 241 | |
| 242 | api_equal json:rics 10 120 |
| 243 | |
| 244 | echo "Check the number of types in the agent for each ric" |
| 245 | api_equal json:policy_types?ric=ricsim_g1_1 1 120 |
| 246 | api_equal json:policy_types?ric=ricsim_g1_2 2 120 |
| 247 | api_equal json:policy_types?ric=ricsim_g1_3 3 120 |
| 248 | api_equal json:policy_types?ric=ricsim_g1_4 4 120 |
| 249 | api_equal json:policy_types?ric=ricsim_g1_5 5 120 |
| 250 | api_equal json:policy_types?ric=ricsim_g1_6 4 120 |
| 251 | api_equal json:policy_types?ric=ricsim_g1_7 3 120 |
| 252 | api_equal json:policy_types?ric=ricsim_g1_8 2 120 |
| 253 | api_equal json:policy_types?ric=ricsim_g1_9 1 120 |
| 254 | api_equal json:policy_types?ric=ricsim_g1_10 0 120 |
| 255 | |
| 256 | api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \ |
| 257 | ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \ |
| 258 | ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \ |
| 259 | ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3,4:???? \ |
| 260 | ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,4,5:???? \ |
| 261 | ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,4,5:???? \ |
| 262 | ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,4,5:???? \ |
| 263 | ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? \ |
| 264 | ricsim_g1_9:me1_ricsim_g1_9,me2_ricsim_g1_9:5:???? \ |
| 265 | ricsim_g1_10:me1_ricsim_g1_10,me2_ricsim_g1_10:NOTYPE:???? " |
| 266 | |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 267 | sleep_wait 120 |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 268 | |
| 269 | api_equal json:policy_ids 0 |
| 270 | |
| 271 | sim_equal ricsim_g1_9 num_instances 0 |
| 272 | |
| 273 | |
| 274 | sim_delete_policy_type 204 ricsim_g1_4 4 |
| 275 | sim_delete_policy_type 204 ricsim_g1_5 4 |
| 276 | sim_delete_policy_type 204 ricsim_g1_6 4 |
| 277 | sim_delete_policy_type 204 ricsim_g1_7 4 |
| 278 | |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 279 | sleep_wait 120 |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 280 | |
| 281 | api_equal json:policy_types?ric=ricsim_g1_1 1 120 |
| 282 | api_equal json:policy_types?ric=ricsim_g1_2 2 120 |
| 283 | api_equal json:policy_types?ric=ricsim_g1_3 3 120 |
| 284 | api_equal json:policy_types?ric=ricsim_g1_4 3 120 |
| 285 | api_equal json:policy_types?ric=ricsim_g1_5 4 120 |
| 286 | api_equal json:policy_types?ric=ricsim_g1_6 3 120 |
| 287 | api_equal json:policy_types?ric=ricsim_g1_7 2 120 |
| 288 | api_equal json:policy_types?ric=ricsim_g1_8 2 120 |
| 289 | api_equal json:policy_types?ric=ricsim_g1_9 1 120 |
| 290 | api_equal json:policy_types?ric=ricsim_g1_10 0 120 |
| 291 | |
| 292 | api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \ |
| 293 | ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \ |
| 294 | ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \ |
| 295 | ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3:???? \ |
| 296 | ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,5:???? \ |
| 297 | ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,5:???? \ |
| 298 | ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,5:???? \ |
| 299 | ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? \ |
| 300 | ricsim_g1_9:me1_ricsim_g1_9,me2_ricsim_g1_9:5:???? \ |
| 301 | ricsim_g1_10:me1_ricsim_g1_10,me2_ricsim_g1_10:NOTYPE:???? " |
| 302 | |
| 303 | sim_delete_policy_type 204 ricsim_g1_8 4 |
| 304 | |
| 305 | api_equal json:policy_types?ric=ricsim_g1_8 1 120 |
| 306 | |
| 307 | api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \ |
| 308 | ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \ |
| 309 | ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \ |
| 310 | ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3:???? \ |
| 311 | ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,5:???? \ |
| 312 | ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,5:???? \ |
| 313 | ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,5:???? \ |
| 314 | ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:5:???? \ |
| 315 | ricsim_g1_9:me1_ricsim_g1_9,me2_ricsim_g1_9:5:???? \ |
| 316 | ricsim_g1_10:me1_ricsim_g1_10,me2_ricsim_g1_10:NOTYPE:???? " |
| 317 | |
| 318 | |
| 319 | |
| 320 | check_policy_agent_logs |
| 321 | store_logs ${interface} |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 322 | |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 323 | done |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | #### TEST COMPLETE #### |
| 330 | |
| 331 | |
| 332 | print_result |
| 333 | |
| 334 | auto_clean_containers |