Function test updates
[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 #  ========================================================================
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 with/without SDNC controller"
22
23 #App names to include in the test when running docker, space separated list
24 DOCKER_INCLUDED_IMAGES="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 "
35
36 #Supported test environment profiles
37 SUPPORTED_PROFILES="ONAP-JAKARTA ONAP-KOHN ONAP-LONDON  ORAN-F-RELEASE ORAN-G-RELEASE ORAN-H-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 sim_generate_policy_uuid
48
49 # Tested variants of REST/DMAAP/SDNC config
50 TESTED_VARIANTS="REST   DMAAP   REST+SDNC   DMAAP+SDNC"
51
52 if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
53     TESTED_VARIANTS="REST   REST+SDNC"
54 fi
55
56 #Test a1pms and simulator protocol versions (others are http only)
57 TESTED_PROTOCOLS="HTTP HTTPS"
58 for __httpx in $TESTED_PROTOCOLS ; do
59     for interface in $TESTED_VARIANTS ; do
60
61         echo "#####################################################################"
62         echo "#####################################################################"
63         echo "### Testing a1pms: $interface using $__httpx"
64         echo "#####################################################################"
65         echo "#####################################################################"
66
67         clean_environment
68
69         start_kube_proxy
70
71         if [ $__httpx == "HTTPS" ]; then
72             use_a1pms_rest_https
73         else
74             use_a1pms_rest_http
75         fi
76
77         start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
78
79         set_a1pms_trace
80
81         # Create service to be able to receive events when rics becomes available
82         # Must use rest towards the a1pms since dmaap is not configured yet
83         a1pms_api_put_service 201 "ric-registration" 0 "$CR_SERVICE_APP_PATH_0/ric-registration"
84
85         if [ $__httpx == "HTTPS" ]; then
86             use_cr_https
87             use_simulator_https
88             if [[ $interface = *"SDNC"* ]]; then
89                 if [[ "$SDNC_FEATURE_LEVEL" == *"NO_NB_HTTPS"* ]]; then
90                     deviation "SDNC does not support NB https"
91                     use_sdnc_http
92                 else
93                     use_sdnc_https
94                 fi
95             fi
96             if [[ $interface = *"DMAAP"* ]]; then
97                 use_a1pms_dmaap_https
98             else
99                 use_a1pms_rest_https
100             fi
101         else
102             use_cr_http
103             use_simulator_http
104             if [[ $interface = *"SDNC"* ]]; then
105                 use_sdnc_http
106             fi
107             if [[ $interface = *"DMAAP"* ]]; then
108                 use_a1pms_dmaap_http
109             else
110                 use_a1pms_rest_http
111             fi
112         fi
113         if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
114             :
115         else
116             if [ $__httpx == "HTTPS" ]; then
117                 use_mr_https
118             else
119                 use_mr_http
120             fi
121         fi
122
123         start_ric_simulators ricsim_g1 1  OSC_2.1.0
124         start_ric_simulators ricsim_g2 1  STD_1.1.3
125         start_ric_simulators ricsim_g3 1  STD_2.0.0
126
127         if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
128             :
129         else
130             start_mr    "$MR_READ_TOPIC"  "/events" "users/policy-agent" \
131                         "$MR_WRITE_TOPIC" "/events" "users/mr-stub"
132         fi
133
134         start_cr 1
135
136         start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
137
138         if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
139             start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
140         fi
141
142
143         if [[ $interface = *"SDNC"* ]]; then
144             start_sdnc
145             controller_api_wait_for_status_ok 200 ricsim_g1_1
146             prepare_a1pms_config      SDNC    ".a1pms_config.json"
147         else
148             prepare_a1pms_config      NOSDNC  ".a1pms_config.json"
149         fi
150
151         if [ $RUNMODE == "KUBE" ]; then
152             a1pms_load_config                       ".a1pms_config.json"
153         else
154             #Temporary switch to http/https if dmaap use. Otherwise it is not possibble to push config
155             if [ $__httpx == "HTTPS" ]; then
156                 use_a1pms_rest_https
157             else
158                 use_a1pms_rest_http
159             fi
160             a1pms_api_put_configuration 200 ".a1pms_config.json"
161             if [ $__httpx == "HTTPS" ]; then
162                 if [[ $interface = *"DMAAP"* ]]; then
163                     use_a1pms_dmaap_https
164                 else
165                     use_a1pms_rest_https
166                 fi
167             else
168                 if [[ $interface = *"DMAAP"* ]]; then
169                     use_a1pms_dmaap_http
170                 else
171                     use_a1pms_rest_http
172                 fi
173             fi
174         fi
175
176         if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
177             :
178         else
179             mr_equal requests_submitted 0
180         fi
181
182         sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
183
184         sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
185
186         a1pms_equal json:rics 3 300
187
188         a1pms_equal json:policy-types 3 120
189
190         a1pms_equal json:policies 0
191
192         a1pms_equal json:policy-instances 0
193
194         cr_equal 0 received_callbacks 3 120
195
196         cr_api_check_all_sync_events 200 0 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
197
198         echo "############################################"
199         echo "############## Health check ################"
200         echo "############################################"
201
202         sleep_wait 120 "Let A1PMS cofiguration take effect"
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         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"
221
222         echo "############################################"
223         echo "########### A1 Policy Management ###########"
224         echo "############################################"
225
226         notificationurl=$CR_SERVICE_APP_PATH_0"/test"
227         a1pms_api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
228         a1pms_api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
229         a1pms_api_put_policy 201 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
230         a1pms_api_put_policy 200 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
231
232         a1pms_api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
233         a1pms_api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
234
235         a1pms_equal json:policies 3
236
237         a1pms_api_delete_policy 204 5000
238
239         a1pms_api_delete_policy 204 5100
240
241         a1pms_api_delete_policy 204 5200
242
243         a1pms_equal json:policies 0
244
245         a1pms_equal json:policy-instances 0
246
247         cr_equal 0 received_callbacks 3
248
249         if [[ $interface = *"DMAAP"* ]]; then
250
251             VAL=14 # Number of a1pms API calls over DMAAP
252             mr_equal requests_fetched $VAL
253             mr_equal responses_submitted $VAL
254             mr_equal responses_fetched $VAL
255             mr_equal current_requests 0
256             mr_equal current_responses 0
257         else
258             if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
259                 :
260             else
261                 mr_equal requests_submitted 0
262             fi
263         fi
264
265         if [[ $interface = *"SDNC"* ]]; then
266             sim_contains_str ricsim_g1_1 remote_hosts $SDNC_APP_NAME
267             sim_contains_str ricsim_g2_1 remote_hosts $SDNC_APP_NAME
268             sim_contains_str ricsim_g3_1 remote_hosts $SDNC_APP_NAME
269         else
270             sim_contains_str ricsim_g1_1 remote_hosts $A1PMS_APP_NAME
271             sim_contains_str ricsim_g2_1 remote_hosts $A1PMS_APP_NAME
272             sim_contains_str ricsim_g3_1 remote_hosts $A1PMS_APP_NAME
273         fi
274
275         check_a1pms_logs
276
277
278         if [[ $interface = *"SDNC"* ]]; then
279             check_sdnc_logs
280         fi
281
282         store_logs          "${__httpx}__${interface}"
283
284     done
285
286 done
287
288 #### TEST COMPLETE ####
289
290
291 print_result
292
293 auto_clean_environment