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
10 # http://www.apache.org/licenses/LICENSE-2.0
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=================================================
20 TC_ONELINE_DESCR="Change supported policy types and reconfigure rics"
22 #App names to exclude checking pulling images for, space separated list
23 EXCLUDED_IMAGES="SDNC_ONAP"
25 . ../common/testcase_common.sh $@
26 . ../common/agent_api_functions.sh
27 . ../common/ricsimulator_api_functions.sh
31 #Local vars in test script
32 ##########################
33 # Path to callback receiver
34 CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
37 NUM_RICS_2=$(($NUM_RICS-2))
39 # Tested variants of REST/SDNC config
40 TESTED_VARIANTS="REST REST+SDNC"
42 for interface in $TESTED_VARIANTS ; do
44 echo "#####################################################################"
45 echo "#####################################################################"
46 echo "### Testing agent: "$interface
47 echo "#####################################################################"
48 echo "#####################################################################"
51 # Clean container and start all needed containers #
54 #Start simulators and prepare two configs
56 start_ric_simulators ricsim_g1 $NUM_RICS_2 OSC_2.1.0
64 if [[ $interface = *"SDNC"* ]]; then
66 prepare_consul_config SDNC ".consul_config_2.json"
68 prepare_consul_config NOSDNC ".consul_config_2.json"
71 consul_config_app ".consul_config_2.json"
74 # Create 2nd config and save for later
75 start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
77 if [[ $interface = *"SDNC"* ]]; then
79 prepare_consul_config SDNC ".consul_config_all.json"
81 prepare_consul_config NOSDNC ".consul_config_all.json"
90 for ((i=1; i<=${NUM_RICS}; i++))
92 sim_print ricsim_g1_$i interface
95 # All sims running but 2 are not configured in consul
96 api_equal json:rics 8 120
98 api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:NOTYPE:???? \
99 ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:NOTYPE:???? \
100 ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:NOTYPE:???? \
101 ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:NOTYPE:???? \
102 ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:NOTYPE:???? \
103 ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:NOTYPE:???? \
104 ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:NOTYPE:???? \
105 ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:NOTYPE:???? "
108 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
109 sim_put_policy_type 201 ricsim_g1_2 1 testdata/OSC/sim_1.json
110 sim_put_policy_type 201 ricsim_g1_3 1 testdata/OSC/sim_1.json
111 sim_put_policy_type 201 ricsim_g1_4 1 testdata/OSC/sim_1.json
112 sim_put_policy_type 201 ricsim_g1_5 1 testdata/OSC/sim_1.json
114 sim_put_policy_type 201 ricsim_g1_2 2 testdata/OSC/sim_2.json
115 sim_put_policy_type 201 ricsim_g1_3 2 testdata/OSC/sim_2.json
116 sim_put_policy_type 201 ricsim_g1_4 2 testdata/OSC/sim_2.json
117 sim_put_policy_type 201 ricsim_g1_5 2 testdata/OSC/sim_2.json
118 sim_put_policy_type 201 ricsim_g1_6 2 testdata/OSC/sim_2.json
120 sim_put_policy_type 201 ricsim_g1_3 3 testdata/OSC/sim_3.json
121 sim_put_policy_type 201 ricsim_g1_4 3 testdata/OSC/sim_3.json
122 sim_put_policy_type 201 ricsim_g1_5 3 testdata/OSC/sim_3.json
123 sim_put_policy_type 201 ricsim_g1_6 3 testdata/OSC/sim_3.json
124 sim_put_policy_type 201 ricsim_g1_7 3 testdata/OSC/sim_3.json
126 sim_put_policy_type 201 ricsim_g1_4 4 testdata/OSC/sim_4.json
127 sim_put_policy_type 201 ricsim_g1_5 4 testdata/OSC/sim_4.json
128 sim_put_policy_type 201 ricsim_g1_6 4 testdata/OSC/sim_4.json
129 sim_put_policy_type 201 ricsim_g1_7 4 testdata/OSC/sim_4.json
130 sim_put_policy_type 201 ricsim_g1_8 4 testdata/OSC/sim_4.json
132 sim_put_policy_type 201 ricsim_g1_5 5 testdata/OSC/sim_5.json
133 sim_put_policy_type 201 ricsim_g1_6 5 testdata/OSC/sim_5.json
134 sim_put_policy_type 201 ricsim_g1_7 5 testdata/OSC/sim_5.json
135 sim_put_policy_type 201 ricsim_g1_8 5 testdata/OSC/sim_5.json
136 sim_put_policy_type 201 ricsim_g1_9 5 testdata/OSC/sim_5.json
138 api_equal json:policy_types 5 120
140 echo "Check the number of types in the agent for each ric"
141 api_equal json:policy_types?ric=ricsim_g1_1 1 120
142 api_equal json:policy_types?ric=ricsim_g1_2 2 120
143 api_equal json:policy_types?ric=ricsim_g1_3 3 120
144 api_equal json:policy_types?ric=ricsim_g1_4 4 120
145 api_equal json:policy_types?ric=ricsim_g1_5 5 120
146 api_equal json:policy_types?ric=ricsim_g1_6 4 120
147 api_equal json:policy_types?ric=ricsim_g1_7 3 120
148 api_equal json:policy_types?ric=ricsim_g1_8 2 120
150 api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \
151 ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \
152 ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \
153 ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3,4:???? \
154 ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,4,5:???? \
155 ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,4,5:???? \
156 ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,4,5:???? \
157 ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? "
160 #Load config with all rics
161 consul_config_app ".consul_config_all.json"
163 api_equal json:rics 10 120
165 echo "Check the number of types in the agent for each ric"
166 api_equal json:policy_types?ric=ricsim_g1_1 1 120
167 api_equal json:policy_types?ric=ricsim_g1_2 2 120
168 api_equal json:policy_types?ric=ricsim_g1_3 3 120
169 api_equal json:policy_types?ric=ricsim_g1_4 4 120
170 api_equal json:policy_types?ric=ricsim_g1_5 5 120
171 api_equal json:policy_types?ric=ricsim_g1_6 4 120
172 api_equal json:policy_types?ric=ricsim_g1_7 3 120
173 api_equal json:policy_types?ric=ricsim_g1_8 2 120
174 api_equal json:policy_types?ric=ricsim_g1_9 1 120
175 api_equal json:policy_types?ric=ricsim_g1_10 0 120
177 api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \
178 ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \
179 ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \
180 ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3,4:???? \
181 ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,4,5:???? \
182 ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,4,5:???? \
183 ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,4,5:???? \
184 ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? \
185 ricsim_g1_9:me1_ricsim_g1_9,me2_ricsim_g1_9:5:???? \
186 ricsim_g1_10:me1_ricsim_g1_10,me2_ricsim_g1_10:NOTYPE:???? "
189 #No policy type in sim #10
191 api_equal json:policy_types 5
193 api_put_service 201 "serv1" 3600 "$CR_PATH/serv1"
195 api_put_policy 201 "serv1" ricsim_g1_9 5 2000 NOTRANSIENT testdata/OSC/pi5_template.json 1
197 api_equal json:policy_ids 1
199 sim_equal ricsim_g1_9 num_instances 1
202 # Load config with reduced number of rics
203 consul_config_app ".consul_config_2.json"
205 api_equal json:rics 8 120
207 echo "Check the number of types in the agent for each ric"
208 api_equal json:policy_types?ric=ricsim_g1_1 1 120
209 api_equal json:policy_types?ric=ricsim_g1_2 2 120
210 api_equal json:policy_types?ric=ricsim_g1_3 3 120
211 api_equal json:policy_types?ric=ricsim_g1_4 4 120
212 api_equal json:policy_types?ric=ricsim_g1_5 5 120
213 api_equal json:policy_types?ric=ricsim_g1_6 4 120
214 api_equal json:policy_types?ric=ricsim_g1_7 3 120
215 api_equal json:policy_types?ric=ricsim_g1_8 2 120
217 api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \
218 ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \
219 ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \
220 ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3,4:???? \
221 ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,4,5:???? \
222 ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,4,5:???? \
223 ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,4,5:???? \
224 ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? "
228 api_equal json:policy_ids 0
230 api_get_policy_types 404 ricsim_g1_9
232 sim_equal ricsim_g1_9 num_instances 1
234 api_delete_policy 404 2000
236 # Load config with all rics
237 consul_config_app ".consul_config_all.json"
239 api_equal json:rics 10 120
241 echo "Check the number of types in the agent for each ric"
242 api_equal json:policy_types?ric=ricsim_g1_1 1 120
243 api_equal json:policy_types?ric=ricsim_g1_2 2 120
244 api_equal json:policy_types?ric=ricsim_g1_3 3 120
245 api_equal json:policy_types?ric=ricsim_g1_4 4 120
246 api_equal json:policy_types?ric=ricsim_g1_5 5 120
247 api_equal json:policy_types?ric=ricsim_g1_6 4 120
248 api_equal json:policy_types?ric=ricsim_g1_7 3 120
249 api_equal json:policy_types?ric=ricsim_g1_8 2 120
250 api_equal json:policy_types?ric=ricsim_g1_9 1 120
251 api_equal json:policy_types?ric=ricsim_g1_10 0 120
253 api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \
254 ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \
255 ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \
256 ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3,4:???? \
257 ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,4,5:???? \
258 ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,4,5:???? \
259 ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,4,5:???? \
260 ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? \
261 ricsim_g1_9:me1_ricsim_g1_9,me2_ricsim_g1_9:5:???? \
262 ricsim_g1_10:me1_ricsim_g1_10,me2_ricsim_g1_10:NOTYPE:???? "
266 api_equal json:policy_ids 0
268 sim_equal ricsim_g1_9 num_instances 0
271 sim_delete_policy_type 204 ricsim_g1_4 4
272 sim_delete_policy_type 204 ricsim_g1_5 4
273 sim_delete_policy_type 204 ricsim_g1_6 4
274 sim_delete_policy_type 204 ricsim_g1_7 4
278 api_equal json:policy_types?ric=ricsim_g1_1 1 120
279 api_equal json:policy_types?ric=ricsim_g1_2 2 120
280 api_equal json:policy_types?ric=ricsim_g1_3 3 120
281 api_equal json:policy_types?ric=ricsim_g1_4 3 120
282 api_equal json:policy_types?ric=ricsim_g1_5 4 120
283 api_equal json:policy_types?ric=ricsim_g1_6 3 120
284 api_equal json:policy_types?ric=ricsim_g1_7 2 120
285 api_equal json:policy_types?ric=ricsim_g1_8 2 120
286 api_equal json:policy_types?ric=ricsim_g1_9 1 120
287 api_equal json:policy_types?ric=ricsim_g1_10 0 120
289 api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \
290 ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \
291 ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \
292 ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3:???? \
293 ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,5:???? \
294 ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,5:???? \
295 ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,5:???? \
296 ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:4,5:???? \
297 ricsim_g1_9:me1_ricsim_g1_9,me2_ricsim_g1_9:5:???? \
298 ricsim_g1_10:me1_ricsim_g1_10,me2_ricsim_g1_10:NOTYPE:???? "
300 sim_delete_policy_type 204 ricsim_g1_8 4
302 api_equal json:policy_types?ric=ricsim_g1_8 1 120
304 api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:???? \
305 ricsim_g1_2:me1_ricsim_g1_2,me2_ricsim_g1_2:1,2:???? \
306 ricsim_g1_3:me1_ricsim_g1_3,me2_ricsim_g1_3:1,2,3:???? \
307 ricsim_g1_4:me1_ricsim_g1_4,me2_ricsim_g1_4:1,2,3:???? \
308 ricsim_g1_5:me1_ricsim_g1_5,me2_ricsim_g1_5:1,2,3,5:???? \
309 ricsim_g1_6:me1_ricsim_g1_6,me2_ricsim_g1_6:2,3,5:???? \
310 ricsim_g1_7:me1_ricsim_g1_7,me2_ricsim_g1_7:3,5:???? \
311 ricsim_g1_8:me1_ricsim_g1_8,me2_ricsim_g1_8:5:???? \
312 ricsim_g1_9:me1_ricsim_g1_9,me2_ricsim_g1_9:5:???? \
313 ricsim_g1_10:me1_ricsim_g1_10,me2_ricsim_g1_10:NOTYPE:???? "
317 check_policy_agent_logs
318 store_logs ${interface}
325 #### TEST COMPLETE ####
330 auto_clean_containers