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