Functional Test Updates for I Release
[nonrtric.git] / test / auto-test / FTC1.sh
1 #!/bin/bash
2
3 #  ============LICENSE_START===============================================
4 #  Copyright (C) 2020-2023 Nordix Foundation. All rights reserved.
5 #  Copyright (C) 2023 OpenInfra Foundation Europe. All rights reserved.
6 #  ========================================================================
7 #  Licensed under the Apache License, Version 2.0 (the "License");
8 #  you may not use this file except in compliance with the License.
9 #  You may obtain a copy of the License at
10 #
11 #       http://www.apache.org/licenses/LICENSE-2.0
12 #
13 #  Unless required by applicable law or agreed to in writing, software
14 #  distributed under the License is distributed on an "AS IS" BASIS,
15 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 #  See the License for the specific language governing permissions and
17 #  limitations under the License.
18 #  ============LICENSE_END=================================================
19 #
20
21
22 TC_ONELINE_DESCR="Sanity test, create service and then create,update and delete a policy using http/https and A1PMS REST with/without SDNC controller"
23
24 #App names to include in the test when running docker, space separated list
25 DOCKER_INCLUDED_IMAGES="CP CR MR DMAAPMR A1PMS RICSIM SDNC NGW KUBEPROXY"
26
27 #App names to include in the test when running kubernetes, space separated list
28 KUBE_INCLUDED_IMAGES="CP CR MR DMAAPMR A1PMS RICSIM SDNC NGW KUBEPROXY "
29 #Pre-started app (not started by script) to include in the test when running kubernetes, space separated list
30 KUBE_PRESTARTED_IMAGES=""
31
32 #Ignore image in DOCKER_INCLUDED_IMAGES, KUBE_INCLUDED_IMAGES if
33 #the image is not configured in the supplied env_file
34 #Used for images not applicable to all supported profile
35 CONDITIONALLY_IGNORED_IMAGES="NGW "
36
37 #Supported test environment profiles
38 SUPPORTED_PROFILES="ONAP-KOHN ONAP-LONDON ONAP-MONTREAL  ORAN-G-RELEASE ORAN-H-RELEASE ORAN-I-RELEASE"
39 #Supported run modes
40 SUPPORTED_RUNMODES="DOCKER KUBE"
41
42 . ../common/testcase_common.sh $@
43
44 setup_testenvironment
45
46 #### TEST BEGIN ####
47
48 sim_generate_policy_uuid
49
50 # Tested variants of REST/DMAAP/SDNC config
51 TESTED_VARIANTS="REST   DMAAP   REST+SDNC   DMAAP+SDNC"
52
53 if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
54     TESTED_VARIANTS="REST   REST+SDNC"
55 fi
56
57 #Test a1pms and simulator protocol versions (others are http only)
58 TESTED_PROTOCOLS="HTTP HTTPS"
59 for __httpx in $TESTED_PROTOCOLS ; do
60     for interface in $TESTED_VARIANTS ; do
61
62         echo "#####################################################################"
63         echo "#####################################################################"
64         echo "### Testing a1pms: $interface using $__httpx"
65         echo "#####################################################################"
66         echo "#####################################################################"
67
68         clean_environment
69
70         start_kube_proxy
71
72         if [ $__httpx == "HTTPS" ]; then
73             use_a1pms_rest_https
74         else
75             use_a1pms_rest_http
76         fi
77
78         start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
79
80         set_a1pms_trace
81
82         # Create service to be able to receive events when rics becomes available
83         # Must use rest towards the a1pms since dmaap is not configured yet
84         a1pms_api_put_service 201 "ric-registration" 0 "$CR_SERVICE_APP_PATH_0/ric-registration"
85
86         if [ $__httpx == "HTTPS" ]; then
87             use_cr_https
88             use_simulator_https
89             if [[ $interface = *"SDNC"* ]]; then
90                 if [[ "$SDNC_FEATURE_LEVEL" == *"NO_NB_HTTPS"* ]]; then
91                     deviation "SDNC does not support NB https"
92                     use_sdnc_http
93                 else
94                     use_sdnc_https
95                 fi
96             fi
97             if [[ $interface = *"DMAAP"* ]]; then
98                 use_a1pms_dmaap_https
99             else
100                 use_a1pms_rest_https
101             fi
102         else
103             use_cr_http
104             use_simulator_http
105             if [[ $interface = *"SDNC"* ]]; then
106                 use_sdnc_http
107             fi
108             if [[ $interface = *"DMAAP"* ]]; then
109                 use_a1pms_dmaap_http
110             else
111                 use_a1pms_rest_http
112             fi
113         fi
114         if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
115             :
116         else
117             if [ $__httpx == "HTTPS" ]; then
118                 use_mr_https
119             else
120                 use_mr_http
121             fi
122         fi
123
124         start_ric_simulators ricsim_g1 1  OSC_2.1.0
125         start_ric_simulators ricsim_g2 1  STD_1.1.3
126         start_ric_simulators ricsim_g3 1  STD_2.0.0
127
128         if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
129             :
130         else
131             start_mr    "$MR_READ_TOPIC"  "/events" "users/policy-agent" \
132                         "$MR_WRITE_TOPIC" "/events" "users/mr-stub"
133         fi
134
135         start_cr 1
136
137         start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
138
139         if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
140             start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
141         fi
142
143
144         if [[ $interface = *"SDNC"* ]]; then
145             start_sdnc
146             controller_api_wait_for_status_ok 200 ricsim_g1_1
147             prepare_a1pms_config      SDNC    ".a1pms_config.json"
148         else
149             prepare_a1pms_config      NOSDNC  ".a1pms_config.json"
150         fi
151
152         if [ $RUNMODE == "KUBE" ]; then
153             a1pms_load_config                       ".a1pms_config.json"
154         else
155             #Temporary switch to http/https if dmaap use. Otherwise it is not possible to push config
156             if [ $__httpx == "HTTPS" ]; then
157                 use_a1pms_rest_https
158             else
159                 use_a1pms_rest_http
160             fi
161             a1pms_api_put_configuration 200 ".a1pms_config.json"
162             if [ $__httpx == "HTTPS" ]; then
163                 if [[ $interface = *"DMAAP"* ]]; then
164                     use_a1pms_dmaap_https
165                 else
166                     use_a1pms_rest_https
167                 fi
168             else
169                 if [[ $interface = *"DMAAP"* ]]; then
170                     use_a1pms_dmaap_http
171                 else
172                     use_a1pms_rest_http
173                 fi
174             fi
175         fi
176
177         if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
178             :
179         else
180             mr_equal requests_submitted 0
181         fi
182
183         sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
184
185         sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
186
187         a1pms_equal json:rics 3 300
188
189         a1pms_equal json:policy-types 3 120
190
191         a1pms_equal json:policies 0
192
193         a1pms_equal json:policy-instances 0
194
195         cr_equal 0 received_callbacks 3 120
196
197         cr_api_check_all_sync_events 200 0 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
198
199         echo "############################################"
200         echo "############## Health check ################"
201         echo "############################################"
202
203         sleep_wait 120 "Let A1PMS configuration take effect"
204
205         a1pms_api_get_status 200
206
207         echo "############################################"
208         echo "##### Service registry and supervision #####"
209         echo "############################################"
210
211         a1pms_api_put_service 201 "serv1" 1000 "$CR_SERVICE_APP_PATH_0/1"
212
213         a1pms_api_get_service_ids 200 "serv1" "ric-registration"
214
215         a1pms_api_put_services_keepalive 200 "serv1"
216
217         echo "############################################"
218         echo "############## RIC Repository ##############"
219         echo "############################################"
220
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
223         echo "############################################"
224         echo "########### A1 Policy Management ###########"
225         echo "############################################"
226
227         notificationurl=$CR_SERVICE_APP_PATH_0"/test"
228         a1pms_api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
229         a1pms_api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
230         a1pms_api_put_policy 201 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
231         a1pms_api_put_policy 200 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
232
233         a1pms_api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
234         a1pms_api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
235
236         a1pms_equal json:policies 3
237
238         a1pms_api_delete_policy 204 5000
239
240         a1pms_api_delete_policy 204 5100
241
242         a1pms_api_delete_policy 204 5200
243
244         a1pms_equal json:policies 0
245
246         a1pms_equal json:policy-instances 0
247
248         cr_equal 0 received_callbacks 3
249
250         if [[ $interface = *"DMAAP"* ]]; then
251
252             VAL=14 # Number of a1pms API calls over DMAAP
253             mr_equal requests_fetched $VAL
254             mr_equal responses_submitted $VAL
255             mr_equal responses_fetched $VAL
256             mr_equal current_requests 0
257             mr_equal current_responses 0
258         else
259             if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
260                 :
261             else
262                 mr_equal requests_submitted 0
263             fi
264         fi
265
266         if [[ $interface = *"SDNC"* ]]; then
267             sim_contains_str ricsim_g1_1 remote_hosts $SDNC_APP_NAME
268             sim_contains_str ricsim_g2_1 remote_hosts $SDNC_APP_NAME
269             sim_contains_str ricsim_g3_1 remote_hosts $SDNC_APP_NAME
270         else
271             sim_contains_str ricsim_g1_1 remote_hosts $A1PMS_APP_NAME
272             sim_contains_str ricsim_g2_1 remote_hosts $A1PMS_APP_NAME
273             sim_contains_str ricsim_g3_1 remote_hosts $A1PMS_APP_NAME
274         fi
275
276         check_a1pms_logs
277
278
279         if [[ $interface = *"SDNC"* ]]; then
280             check_sdnc_logs
281         fi
282
283         store_logs          "${__httpx}__${interface}"
284
285     done
286
287 done
288
289 #### TEST COMPLETE ####
290
291
292 print_result
293
294 auto_clean_environment