New test profile
[nonrtric.git] / test / auto-test / FTC1.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="Sanity test, create service and then create,update and delete a policy using http/https and A1PMS REST/DMAAP with/without SDNC controller"
22
23 #App names to include in the test when running docker, space separated list
24 DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR DMAAPMR A1PMS RICSIM SDNC NGW KUBEPROXY"
25
26 #App names to include in the test when running kubernetes, space separated list
27 KUBE_INCLUDED_IMAGES="CP CR MR DMAAPMR A1PMS RICSIM SDNC NGW KUBEPROXY "
28 #Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
29 KUBE_PRESTARTED_IMAGES=""
30
31 #Ignore image in DOCKER_INCLUDED_IMAGES, KUBE_INCLUDED_IMAGES if
32 #the image is not configured in the supplied env_file
33 #Used for images not applicable to all supported profile
34 CONDITIONALLY_IGNORED_IMAGES="NGW CBS CONSUL"
35
36 #Supported test environment profiles
37 SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ONAP-ISTANBUL ONAP-JAKARTA ORAN-CHERRY ORAN-D-RELEASE ORAN-E-RELEASE ORAN-F-RELEASE"
38 #Supported run modes
39 SUPPORTED_RUNMODES="DOCKER KUBE"
40
41 . ../common/testcase_common.sh $@
42
43 setup_testenvironment
44
45 #### TEST BEGIN ####
46
47 generate_policy_uuid
48
49 # Tested variants of REST/DMAAP/SDNC config
50 TESTED_VARIANTS="REST   DMAAP   REST+SDNC   DMAAP+SDNC"
51 #Test a1pms and simulator protocol versions (others are http only)
52 TESTED_PROTOCOLS="HTTP HTTPS"
53 for __httpx in $TESTED_PROTOCOLS ; do
54     for interface in $TESTED_VARIANTS ; do
55
56         echo "#####################################################################"
57         echo "#####################################################################"
58         echo "### Testing a1pms: $interface using $__httpx"
59         echo "#####################################################################"
60         echo "#####################################################################"
61
62         clean_environment
63
64         start_kube_proxy
65
66         if [ $__httpx == "HTTPS" ]; then
67             use_a1pms_rest_https
68         else
69             use_a1pms_rest_http
70         fi
71
72         start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
73
74         set_a1pms_trace
75
76         # Create service to be able to receive events when rics becomes available
77         # Must use rest towards the a1pms since dmaap is not configured yet
78         a1pms_api_put_service 201 "ric-registration" 0 "$CR_SERVICE_APP_PATH_0/ric-registration"
79
80         if [ $__httpx == "HTTPS" ]; then
81             use_cr_https
82             use_simulator_https
83             use_mr_https
84             if [[ $interface = *"SDNC"* ]]; then
85                 use_sdnc_https
86             fi
87             if [[ $interface = *"DMAAP"* ]]; then
88                 use_a1pms_dmaap_https
89             else
90                 use_a1pms_rest_https
91             fi
92         else
93             use_cr_http
94             use_simulator_http
95             use_mr_http
96             if [[ $interface = *"SDNC"* ]]; then
97                 use_sdnc_http
98             fi
99             if [[ $interface = *"DMAAP"* ]]; then
100                 use_a1pms_dmaap_http
101             else
102                 use_a1pms_rest_http
103             fi
104         fi
105
106         start_ric_simulators ricsim_g1 1  OSC_2.1.0
107         start_ric_simulators ricsim_g2 1  STD_1.1.3
108         if [ "$A1PMS_VERSION" == "V2" ]; then
109             start_ric_simulators ricsim_g3 1  STD_2.0.0
110         fi
111
112         start_mr    "$MR_READ_TOPIC"  "/events" "users/policy-agent" \
113                     "$MR_WRITE_TOPIC" "/events" "users/mr-stub"
114
115         start_cr 1
116
117         start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
118
119         if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
120             start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
121         fi
122
123         __CONFIG_HEADER="NOHEADER"
124         if [ $RUNMODE == "KUBE" ]; then
125             __CONFIG_HEADER="HEADER"
126         else
127             if [[ "$A1PMS_FEATURE_LEVEL" == *"NOCONSUL"* ]]; then
128                 __CONFIG_HEADER="HEADER"
129             fi
130         fi
131         if [[ $interface = *"SDNC"* ]]; then
132             start_sdnc
133             prepare_consul_config      SDNC    ".consul_config.json" $__CONFIG_HEADER
134         else
135             prepare_consul_config      NOSDNC  ".consul_config.json" $__CONFIG_HEADER
136         fi
137
138         if [ $RUNMODE == "KUBE" ]; then
139             a1pms_load_config                       ".consul_config.json"
140         else
141             if [[ "$A1PMS_FEATURE_LEVEL" == *"NOCONSUL"* ]]; then
142                 #Temporary switch to http/https if dmaap use. Otherwise it is not possibble to push config
143                 if [ $__httpx == "HTTPS" ]; then
144                     use_a1pms_rest_https
145                 else
146                     use_a1pms_rest_http
147                 fi
148                 a1pms_api_put_configuration 200 ".consul_config.json"
149                 if [ $__httpx == "HTTPS" ]; then
150                     if [[ $interface = *"DMAAP"* ]]; then
151                         use_a1pms_dmaap_https
152                     else
153                         use_a1pms_rest_https
154                     fi
155                 else
156                     if [[ $interface = *"DMAAP"* ]]; then
157                         use_a1pms_dmaap_http
158                     else
159                         use_a1pms_rest_http
160                     fi
161                 fi
162             else
163                 start_consul_cbs
164                 consul_config_app                   ".consul_config.json"
165             fi
166         fi
167
168         mr_equal requests_submitted 0
169
170         sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
171
172         if [ "$A1PMS_VERSION" == "V2" ]; then
173
174             sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
175
176             a1pms_equal json:rics 3 300
177
178             a1pms_equal json:policy-types 3 120
179
180             a1pms_equal json:policies 0
181
182             a1pms_equal json:policy-instances 0
183
184             cr_equal 0 received_callbacks 3 120
185
186             cr_api_check_all_sync_events 200 0 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
187
188         else
189             a1pms_equal json:rics 2 300
190
191             a1pms_equal json:policy_schemas 2 120
192
193             a1pms_equal json:policy_types 2
194
195             a1pms_equal json:policies 0
196
197             a1pms_equal json:policy_ids 0
198         fi
199
200         echo "############################################"
201         echo "############## Health check ################"
202         echo "############################################"
203
204         a1pms_api_get_status 200
205
206         echo "############################################"
207         echo "##### Service registry and supervision #####"
208         echo "############################################"
209
210         a1pms_api_put_service 201 "serv1" 1000 "$CR_SERVICE_APP_PATH_0/1"
211
212         a1pms_api_get_service_ids 200 "serv1" "ric-registration"
213
214         a1pms_api_put_services_keepalive 200 "serv1"
215
216         echo "############################################"
217         echo "############## RIC Repository ##############"
218         echo "############################################"
219
220         if [ "$A1PMS_VERSION" == "V2" ]; then
221             a1pms_api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:AVAILABLE  ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE ricsim_g3_1:me1_ricsim_g3_1,me2_ricsim_g3_1:STD_QOS_0_2_0:AVAILABLE"
222         else
223             a1pms_api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:AVAILABLE  ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
224         fi
225
226         echo "############################################"
227         echo "########### A1 Policy Management ###########"
228         echo "############################################"
229
230         if [ "$A1PMS_VERSION" == "V2" ]; then
231             notificationurl=$CR_SERVICE_APP_PATH_0"/test"
232         else
233             notificationurl=""
234         fi
235         a1pms_api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
236         a1pms_api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
237         if [ "$A1PMS_VERSION" == "V2" ]; then
238             a1pms_api_put_policy 201 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
239             a1pms_api_put_policy 200 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
240         fi
241
242         a1pms_api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
243         a1pms_api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
244
245         if [ "$A1PMS_VERSION" == "V2" ]; then
246             a1pms_equal json:policies 3
247         else
248             a1pms_equal json:policies 2
249         fi
250
251         a1pms_api_delete_policy 204 5000
252
253         a1pms_api_delete_policy 204 5100
254
255         if [ "$A1PMS_VERSION" == "V2" ]; then
256             a1pms_api_delete_policy 204 5200
257         fi
258
259         if [ "$A1PMS_VERSION" == "V2" ]; then
260             a1pms_equal json:policies 0
261
262             a1pms_equal json:policy-instances 0
263         else
264             a1pms_equal json:policies 0
265
266             a1pms_equal json:policy_ids 0
267         fi
268
269         if [ "$A1PMS_VERSION" == "V2" ]; then
270             cr_equal 0 received_callbacks 3
271         fi
272
273         if [[ $interface = *"DMAAP"* ]]; then
274
275             if [ "$A1PMS_VERSION" == "V2" ]; then
276                 VAL=14 # Number of a1pms API calls over DMAAP
277             else
278                 VAL=11 # Number of a1pms API calls over DMAAP
279             fi
280             mr_equal requests_fetched $VAL
281             mr_equal responses_submitted $VAL
282             mr_equal responses_fetched $VAL
283             mr_equal current_requests 0
284             mr_equal current_responses 0
285         else
286             mr_equal requests_submitted 0
287         fi
288
289         if [[ $interface = *"SDNC"* ]]; then
290             sim_contains_str ricsim_g1_1 remote_hosts $SDNC_APP_NAME
291             sim_contains_str ricsim_g2_1 remote_hosts $SDNC_APP_NAME
292             if [ "$A1PMS_VERSION" == "V2" ]; then
293                 sim_contains_str ricsim_g3_1 remote_hosts $SDNC_APP_NAME
294             fi
295         else
296             sim_contains_str ricsim_g1_1 remote_hosts $A1PMS_APP_NAME
297             sim_contains_str ricsim_g2_1 remote_hosts $A1PMS_APP_NAME
298             if [ "$A1PMS_VERSION" == "V2" ]; then
299                 sim_contains_str ricsim_g3_1 remote_hosts $A1PMS_APP_NAME
300             fi
301         fi
302
303         check_a1pms_logs
304
305
306         if [[ $interface = *"SDNC"* ]]; then
307             check_sdnc_logs
308         fi
309
310         store_logs          "${__httpx}__${interface}"
311
312     done
313
314 done
315
316 #### TEST COMPLETE ####
317
318
319 print_result
320
321 auto_clean_environment