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