Merge "Adapted test scripts to changes in PMS 2.0"
[nonrtric.git] / test / auto-test / FTC100.sh
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
21 TC_ONELINE_DESCR="Full agent API walk through using agent REST/DMAAP and with/without SDNC A1 Controller"
22
23 #App names to include in the test, space separated list
24 INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
25
26
27 #SUPPORTED TEST ENV FILE
28 SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN"
29
30 . ../common/testcase_common.sh  $@
31 . ../common/agent_api_functions.sh
32 . ../common/ricsimulator_api_functions.sh
33 . ../common/cr_api_functions.sh
34
35 #### TEST BEGIN ####
36
37 generate_uuid
38
39 # Tested variants of REST/DMAAP/SDNC config
40 TESTED_VARIANTS="REST   DMAAP   REST+SDNC   DMAAP+SDNC"
41
42 #Test agent and simulator protocol versions (others are http only)
43 TESTED_PROTOCOLS="HTTP HTTPS"
44
45 for __httpx in $TESTED_PROTOCOLS ; do
46     for interface in $TESTED_VARIANTS ; do
47
48         echo "#####################################################################"
49         echo "#####################################################################"
50         echo "### Testing agent: $interface using $__httpx"
51         echo "#####################################################################"
52         echo "#####################################################################"
53
54         # Clean container and start all needed containers #
55         clean_containers
56
57         if [ $__httpx == "HTTPS" ]; then
58             use_agent_rest_https
59         else
60             use_agent_rest_http
61         fi
62
63         start_policy_agent
64
65         set_agent_trace
66
67         # Create service to be able to receive events when rics becomes available
68         # Must use rest towards the agent since dmaap is not configured yet
69         api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration"
70
71
72         if [ $__httpx == "HTTPS" ]; then
73             use_cr_https
74             use_simulator_https
75             use_mr_https
76             if [[ $interface = *"SDNC"* ]]; then
77                 use_sdnc_https
78             fi
79             if [[ $interface = *"DMAAP"* ]]; then
80                 use_agent_dmaap_https
81             else
82                 use_agent_rest_https
83             fi
84         else
85             use_cr_http
86             use_simulator_http
87             use_mr_http
88             if [[ $interface = *"SDNC"* ]]; then
89                 use_sdnc_http
90             fi
91             if [[ $interface = *"DMAAP"* ]]; then
92                 use_agent_dmaap_http
93             else
94                 use_agent_rest_http
95             fi
96         fi
97
98         start_ric_simulators ricsim_g1 1  OSC_2.1.0
99         start_ric_simulators ricsim_g2 1  STD_1.1.3
100         if [ "$PMS_VERSION" == "V2" ]; then
101             start_ric_simulators ricsim_g3 1  STD_2.0.0
102         fi
103
104         start_mr
105
106         start_cr
107
108         start_control_panel
109
110         start_consul_cbs
111
112         if [[ $interface = *"SDNC"* ]]; then
113             start_sdnc
114             prepare_consul_config      SDNC    ".consul_config.json"
115         else
116             prepare_consul_config      NOSDNC  ".consul_config.json"
117         fi
118
119         consul_config_app                      ".consul_config.json"
120
121         sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
122         sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json
123
124         if [ "$PMS_VERSION" == "V2" ]; then
125             api_equal json:rics 3 60
126
127             api_equal json:policy-types 3 120
128
129             api_equal json:policies 0
130
131             api_equal json:policy-instances 0
132         else
133             api_equal json:rics 2 60
134
135             api_equal json:policy_schemas 3 120
136
137             api_equal json:policy_types 3
138
139             api_equal json:policies 0
140
141             api_equal json:policy_ids 0
142         fi
143
144         if [ "$PMS_VERSION" == "V2" ]; then
145             cr_equal received_callbacks 3 120
146             cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
147         fi
148         mr_equal requests_submitted 0
149
150
151         echo "############################################"
152         echo "############## Health check ################"
153         echo "############################################"
154
155         api_get_status 200
156
157         echo "############################################"
158         echo "##### Service registry and supervision #####"
159         echo "############################################"
160
161         api_get_services 404 "service1"
162
163         api_put_service 201 "service1" 1000 "$CR_PATH/1"
164
165         api_put_service 200 "service1" 2000 "$CR_PATH/1"
166
167
168         api_put_service 400 "service2" -1 "$CR_PATH/2"
169
170         api_put_service 400 "service2" "wrong" "$CR_PATH/2"
171
172         api_put_service 400 "service2" 100 "/test"
173
174         api_put_service 400 "service2" 100 "test-path"
175
176         api_put_service 201 "service2" 300 "ftp://localhost:80/test"
177
178         api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1"
179
180         api_get_service_ids 200 "service1" "service2" "ric-registration"
181
182
183         api_put_service 201 "service3" 5000 "$CR_PATH/3"
184
185
186         api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
187
188
189         api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1"
190
191         api_get_services 200 NOSERVICE "service1" 2000 "$CR_PATH/1" "service2" 300 "ftp://localhost:80/test" "service3" 5000 "$CR_PATH/3"  "ric-registration" 0 "$CR_PATH/ric-registration"
192
193         api_get_services 200
194
195         deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
196         #The below should work, keept here until fixed or other decision made
197         #api_put_services_keepalive 201 "service1"
198         #Using the below until decision
199         api_put_services_keepalive 200 "service1"
200
201         deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
202         #The below should work, keept here until fixed or other decision made
203         #api_put_services_keepalive 201 "service3"
204         #Using the below until decision
205         api_put_services_keepalive 200 "service3"
206
207         api_put_services_keepalive 200 "service1"
208
209         api_put_services_keepalive 200 "service3"
210
211         api_put_services_keepalive 404 "service5"
212
213         api_get_service_ids 200 "service1" "service2" "service3"  "ric-registration"
214
215         api_delete_services 204 "service1"
216
217         api_get_service_ids 200 "service2" "service3" "ric-registration"
218
219
220         api_put_service 201 "service1" 50 "$CR_PATH/1"
221
222         api_get_service_ids 200 "service1" "service2" "service3"  "ric-registration"
223
224
225         api_delete_services 204 "service1"
226         api_delete_services 204 "service3"
227
228         api_equal json:services 2
229
230         api_delete_services 204 "service2"
231
232         api_equal json:services 1
233
234
235         echo "############################################"
236         echo "############## RIC Repository ##############"
237         echo "############################################"
238
239         if [ "$PMS_VERSION" == "V2" ]; then
240             api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE  ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE ricsim_g3_1:me1_ricsim_g3_1,me2_ricsim_g3_1:NOTYPE:AVAILABLE"
241         else
242             api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE  ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
243         fi
244         api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
245
246         api_get_rics 404 47
247
248         api_get_rics 404 "test"
249
250         if [ "$PMS_VERSION" == "V2" ]; then
251             api_get_ric 200 me1_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
252
253             api_get_ric 200 me2_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
254
255             api_get_ric 200 me1_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
256
257             api_get_ric 200 me2_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
258
259             api_get_ric 200 NOME      ricsim_g1_1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
260
261             api_get_ric 200 NOME      ricsim_g2_1 "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
262
263             api_get_ric 404 NOME test1
264
265             api_get_ric 404 test NORIC
266
267             api_get_ric 400 me1_ricsim_g1_1 ricsim_g1_1
268
269             api_get_ric 400 me1_ricsim_g1_1 TESTRIC
270
271             api_get_ric 400 TESTME ricsim_g1_1
272
273         else
274             api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1
275
276             api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1
277
278             api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1
279
280             api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1
281
282             api_get_ric 404 test
283         fi
284
285         echo "############################################"
286         echo "########### A1 Policy Management ###########"
287         echo "############################################"
288
289         if [ "$PMS_VERSION" == "V2" ]; then
290             deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
291             #Behaviour accepted for now
292             api_get_policy_type 200 1 testdata/OSC/1-agent-modified.json
293             deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
294             #Behaviour accepted for now
295             api_get_policy_type 200 2 testdata/OSC/2-agent-modified.json
296
297             api_get_policy_type 404 3
298         else
299             deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
300             #Behaviour accepted for now
301             api_get_policy_schema 200 1 testdata/OSC/1-agent-modified.json
302             deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
303             #Behaviour accepted for now
304             api_get_policy_schema 200 2 testdata/OSC/2-agent-modified.json
305
306             api_get_policy_schema 404 3
307         fi
308
309         if [ "$PMS_VERSION" == "V2" ]; then
310             api_get_policy_schemas 404
311         else
312             deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
313             #Behaviour accepted for now
314             api_get_policy_schemas 200 NORIC testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json NOFILE
315             deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
316             #Behaviour accepted for now
317             api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json
318
319             api_get_policy_schemas 200 ricsim_g2_1 NOFILE
320
321             api_get_policy_schemas 404 test
322         fi
323
324
325
326         api_get_policy_types 200 NORIC 1 2 EMPTY
327
328         api_get_policy_types 200 ricsim_g1_1 1 2
329
330         api_get_policy_types 200 ricsim_g2_1 EMPTY
331
332         api_get_policy_types 404 dummy-ric
333
334
335
336         api_put_service 201 "service10" 3600 "$CR_PATH/1"
337
338         if [ "$PMS_VERSION" == "V2" ]; then
339             notificationurl=$CR_PATH"/test"
340         else
341             notificationurl=""
342         fi
343         deviation "TR10 - agent allows policy creation on unregistered service (orig problem) - test combo $interface and $__httpx"
344         #Kept until decison
345         #api_put_policy 400 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json
346         #Allow 201 for now
347         api_put_policy 201 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
348
349         api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
350         api_put_policy 200 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
351
352         api_put_policy 200 "service10" ricsim_g1_1 1 5000 true $notificationurl testdata/OSC/pi1_template.json
353         api_put_policy 200 "service10" ricsim_g1_1 1 5000 false $notificationurl testdata/OSC/pi1_template.json
354
355         api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
356         api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
357
358         api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 true $notificationurl testdata/STD/pi1_template.json
359         api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 false $notificationurl testdata/STD/pi1_template.json
360
361         VAL='NOT IN EFFECT'
362         api_get_policy_status 200 5000 OSC "$VAL" "false"
363         api_get_policy_status 200 5100 STD "UNDEFINED"
364
365
366         deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
367         #kept until decision
368         #api_equal json:policies 2
369         #Allow 3 for now
370         api_equal json:policies 3
371
372         deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
373         #kept until decision
374         #api_equal json:policy_ids 2
375         #Allow 3 for now
376         if [ "$PMS_VERSION" == "V2" ]; then
377             api_equal json:policy-instances 3
378         else
379             api_equal json:policy_ids 3
380         fi
381
382         deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
383         #kept until decision
384         #api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100
385         #Allow policy create with unregistered service for now
386         api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100 2000
387
388
389         deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
390         #kept until decision
391         #api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000
392         #Allow policy create with unregistered service for now
393         api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000 2000
394
395         api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
396
397
398         api_get_policy_ids 200 NORIC "service10" NOTYPE 5000 5100
399
400         deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
401         #kept until decision
402         #api_get_policy_ids 200 NORIC NOSERVICE 1 5000
403         #Allow policy create with unregistered service for now
404         api_get_policy_ids 200 NORIC NOSERVICE 1 5000 2000
405
406         api_get_policy_ids 200 NORIC NOSERVICE 2 NOID
407
408         api_get_policy_ids 200 ricsim_g2_1 NOSERVICE 1 NOID
409
410         if [ "$PMS_VERSION" == "V2" ]; then
411             api_get_policy 200 5000 testdata/OSC/pi1_template.json "service10" ricsim_g1_1 1 false $notificationurl
412
413             api_get_policy 200 5100 testdata/STD/pi1_template.json "service10" ricsim_g2_1 NOTYPE false $notificationurl
414
415             api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 false $notificationurl testdata/OSC/pi1_template.json
416         else
417             api_get_policy 200 5000 testdata/OSC/pi1_template.json
418
419             api_get_policy 200 5100 testdata/STD/pi1_template.json
420
421             api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 testdata/OSC/pi1_template.json
422         fi
423
424         deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
425         #kept until decision
426         #api_delete_policy 404 2000
427         #Allow policy create with unregistered service for now
428         api_delete_policy 204 2000
429
430         api_delete_policy 404 1500
431
432         api_delete_policy 204 5000
433
434         api_equal json:policies 1
435
436         if [ "$PMS_VERSION" == "V2" ]; then
437             api_equal json:policy-instances 1
438         else
439             api_equal json:policy_ids 1
440         fi
441
442         api_delete_policy 204 5100
443
444         api_equal json:policies 0
445
446         if [ "$PMS_VERSION" == "V2" ]; then
447             api_equal json:policy-instances 0
448         else
449             api_equal json:policy_ids 0
450         fi
451
452         if [ "$PMS_VERSION" == "V2" ]; then
453             cr_equal received_callbacks 3
454         fi
455
456         if [[ $interface = *"DMAAP"* ]]; then
457             mr_greater requests_submitted 0
458             VAL=$(mr_read requests_submitted)
459             mr_equal requests_fetched $VAL
460             mr_equal responses_submitted $VAL
461             mr_equal responses_fetched $VAL
462             mr_equal current_requests 0
463             mr_equal current_responses 0
464         else
465             mr_equal requests_submitted 0
466         fi
467
468         if [[ $interface = *"SDNC"* ]]; then
469             sim_contains_str ricsim_g1_1 remote_hosts "a1-controller"
470             sim_contains_str ricsim_g2_1 remote_hosts "a1-controller"
471             if [ "$PMS_VERSION" == "V2" ]; then
472                 sim_contains_str ricsim_g3_1 remote_hosts "a1-controller"
473             fi
474         else
475             sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
476             sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
477             if [ "$PMS_VERSION" == "V2" ]; then
478                 sim_contains_str ricsim_g3_1 remote_hosts "policy-agent"
479             fi
480         fi
481
482         check_policy_agent_logs
483         check_control_panel_logs
484
485         if [[ $interface = *"SDNC"* ]]; then
486             check_sdnc_logs
487         fi
488
489         store_logs          "${__httpx}__${interface}"
490
491     done
492
493 done
494
495 #### TEST COMPLETE ####
496
497
498 print_result
499
500 auto_clean_containers