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