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