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