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