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