Further updates to the auto-test environment
[nonrtric.git] / test / auto-test / FTC100.sh
1 #!/usr/bin/env 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 . ../common/controller_api_functions.sh
27
28 #### TEST BEGIN ####
29
30 #Local vars in test script
31 ##########################
32
33 # Path to callback receiver
34 CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
35
36 # Tested variants of REST/DMAAP/SDNC config
37 TESTED_VARIANTS="REST   DMAAP   REST+SDNC   DMAAP+SDNC"
38
39 #Test agent and simulator protocol versions (others are http only)
40 TESTED_PROTOCOLS="HTTP HTTPS"
41
42 for __httpx in $TESTED_PROTOCOLS ; do
43     for interface in $TESTED_VARIANTS ; do
44
45         echo "#####################################################################"
46         echo "#####################################################################"
47         echo "### Testing agent: "$interface
48         echo "#####################################################################"
49         echo "#####################################################################"
50
51
52         # Clean container and start all needed containers #
53         clean_containers
54
55         if [ $__httpx == "HTTPS" ]; then
56             echo "Using secure ports towards simulators"
57             use_simulator_https
58         else
59             echo "Using non-secure ports towards simulators"
60             use_simulator_http
61         fi
62
63         start_ric_simulators ricsim_g1 1  OSC_2.1.0
64         start_ric_simulators ricsim_g2 1  STD_1.1.3
65
66         start_mr
67
68         start_cr
69
70         start_consul_cbs
71
72         if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
73             prepare_consul_config      SDNC    ".consul_config.json"
74         else
75             prepare_consul_config      NOSDNC  ".consul_config.json"
76         fi
77
78         consul_config_app                      ".consul_config.json"
79
80         start_control_panel
81
82         if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
83             start_sdnc
84         fi
85
86         start_policy_agent
87
88         if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
89             use_agent_dmaap
90         else
91             if [ $__httpx == "HTTPS" ]; then
92                 echo "Using secure ports towards the agent"
93                 use_agent_rest_https
94             else
95                 echo "Using non-secure ports towards the agent"
96                 use_agent_rest_http
97             fi
98         fi
99
100
101         cr_equal received_callbacks 0
102         mr_equal requests_submitted 0
103
104         sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
105         sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json
106
107         api_equal json:rics 2 60
108
109         api_equal json:policy_schemas 3 120
110
111         api_equal json:policy_types 3
112
113         api_equal json:policies 0
114
115         api_equal json:policy_ids 0
116
117
118
119
120         echo "############################################"
121         echo "############## Health check ################"
122         echo "############################################"
123
124         api_get_status 200
125
126         echo "############################################"
127         echo "##### Service registry and supervision #####"
128         echo "############################################"
129
130         api_get_services 404 "rapp1"
131
132         api_put_service 201 "rapp1" 1000 "$CR_PATH/1"
133
134         api_put_service 200 "rapp1" 2000 "$CR_PATH/1"
135
136
137         api_put_service 400 "rapp2" -1 "$CR_PATH/2"
138
139         api_put_service 400 "rapp2" "wrong" "$CR_PATH/2"
140
141         api_put_service 400 "rapp2" 100 "/test"
142
143         api_put_service 400 "rapp2" 100 "test-path"
144
145         api_put_service 201 "rapp2" 300 "ftp://localhost:80/test"
146
147         api_get_services 200 "rapp1" "rapp1" 2000 "$CR_PATH/1"
148
149         api_get_service_ids 200 "rapp1" "rapp2"
150
151
152         api_put_service 201 "rapp3" 5000 "$CR_PATH/3"
153
154
155         api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
156
157
158         api_get_services 200 "rapp1" "rapp1" 2000 "$CR_PATH/1"
159
160         api_get_services 200 NOSERVICE "rapp1" 2000 "$CR_PATH/1" "rapp2" 300 "ftp://localhost:80/test" "rapp3" 5000 "$CR_PATH/3"
161
162         api_get_services 200
163
164         echo -e $YELLOW"TR2"$EYELLOW
165         api_put_services_keepalive 201 "rapp1"
166         echo -e $YELLOW"TR2"$EYELLOW
167         api_put_services_keepalive 201 "rapp3"
168
169         api_put_services_keepalive 200 "rapp1"
170
171         api_put_services_keepalive 200 "rapp3"
172
173         api_put_services_keepalive 404 "rapp5"
174
175         api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
176
177         api_delete_services 204 "rapp1"
178
179         api_get_service_ids 200 "rapp2" "rapp3"
180
181
182         api_put_service 201 "rapp1" 50 "$CR_PATH/1"
183
184         api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
185
186
187         api_delete_services 204 "rapp1"
188         api_delete_services 204 "rapp3"
189
190         api_equal json:services 1
191
192         api_delete_services 204 "rapp2"
193
194         api_equal json:services 0
195
196
197         echo "############################################"
198         echo "############## RIC Repository ##############"
199         echo "############################################"
200
201         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"
202
203         api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
204
205         api_get_rics 404 47
206
207         api_get_rics 404 "test"
208
209
210         api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1
211
212         api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1
213
214         api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1
215
216         api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1
217
218         api_get_ric 404 test
219
220
221         echo "############################################"
222         echo "########### A1 Policy Management ###########"
223         echo "############################################"
224         echo -e $YELLOW"TR9"$EYELLOW
225         api_get_policy_schema 200 1 testdata/OSC/1-agent-modified.json
226         echo -e $YELLOW"TR9"$EYELLOW
227         api_get_policy_schema 200 2 testdata/OSC/2-agent-modified.json
228
229         api_get_policy_schema 404 3
230         echo -e $YELLOW"TR9"$EYELLOW
231         api_get_policy_schemas 200 NORIC testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json NOFILE
232         echo -e $YELLOW"TR9"$EYELLOW
233         api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json
234
235         api_get_policy_schemas 200 ricsim_g2_1 NOFILE
236
237         api_get_policy_schemas 404 test
238
239
240
241         api_get_policy_types 200 NORIC 1 2 EMPTY
242
243         api_get_policy_types 200 ricsim_g1_1 1 2
244
245         api_get_policy_types 200 ricsim_g2_1 EMPTY
246
247         api_get_policy_types 404 dummy-ric
248
249
250
251         api_put_service 201 "rapp10" 3600 "$CR_PATH/1"
252         echo -e $YELLOW"TR10"$EYELLOW
253         api_put_policy 400 "unregistered-r-app" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json
254
255         api_put_policy 201 "rapp10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json
256         api_put_policy 200 "rapp10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json
257
258         api_put_policy 201 "rapp10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json
259         api_put_policy 200 "rapp10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json
260
261         VAL='NOT IN EFFECT'
262         api_get_policy_status 200 5000 OSC "$VAL" "false"
263         api_get_policy_status 200 5100 STD "UNDEFINED"
264
265
266         echo -e $YELLOW"TR10"$EYELLOW
267         api_equal json:policies 2
268         echo -e $YELLOW"TR10"$EYELLOW
269         api_equal json:policy_ids 2
270         echo -e $YELLOW"TR10"$EYELLOW
271         api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100
272         echo -e $YELLOW"TR10"$EYELLOW
273         api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000
274
275         api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
276
277
278         api_get_policy_ids 200 NORIC "rapp10" NOTYPE 5000 5100
279         echo -e $YELLOW"TR10"$EYELLOW
280         api_get_policy_ids 200 NORIC NOSERVICE 1 5000
281
282         api_get_policy_ids 200 NORIC NOSERVICE 2 NOID
283
284         api_get_policy_ids 200 ricsim_g2_1 NOSERVICE 1 NOID
285
286
287         api_get_policy 200 5000 testdata/OSC/pi1_template.json
288
289         api_get_policy 200 5100 testdata/STD/pi1_template.json
290
291
292
293         api_get_policies 200 ricsim_g1_1 "rapp10" 1 5000 ricsim_g1_1 "rapp10" 1 testdata/OSC/pi1_template.json
294
295
296
297
298         echo -e $YELLOW"TR10"$EYELLOW
299         api_delete_policy 404 2000
300
301         api_delete_policy 404 1500
302
303         api_delete_policy 204 5000
304
305         api_equal json:policies 1
306
307         api_equal json:policy_ids 1
308
309         api_delete_policy 204 5100
310
311         api_equal json:policies 0
312
313         api_equal json:policy_ids 0
314
315         cr_equal received_callbacks 0
316
317         if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
318             mr_greater requests_submitted 0
319             VAL=$(mr_read requests_submitted)
320             mr_equal requests_fetched $VAL
321             mr_equal responses_submitted $VAL
322             mr_equal responses_fetched $VAL
323             mr_equal current_requests 0
324             mr_equal current_responses 0
325         else
326             mr_equal requests_submitted 0
327         fi
328
329         check_policy_agent_logs
330         check_control_panel_logs
331
332         store_logs          $interface
333
334     done
335
336 done
337
338 #### TEST COMPLETE ####
339
340
341 print_result
342
343 auto_clean_containers