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