Updating FTC 2001, 10, 1 series tests to support a1pms V3 image
[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 VERSIONS_TO_RUN=2
50
51 if [ -n "$A1PMS_V3_FLAG" ] && [ "${A1PMS_V3_FLAG,,}" == "true" ]; then
52   VERSIONS_TO_RUN=3
53 fi
54
55 for version in $(seq 2 $VERSIONS_TO_RUN); do
56
57   if [ "$version" == "3" ]; then
58     if [ -n "$A1PMS_V3" ] && [ -n "$A1PMS_API_PREFIX_V3" ] && [ -n "$A1PMS_ALIVE_URL_V3" ]; then
59       export A1PMS_VERSION="$A1PMS_V3"
60       export A1PMS_API_PREFIX="$A1PMS_API_PREFIX_V3"
61       export A1PMS_ALIVE_URL="$A1PMS_API_PREFIX$A1PMS_ALIVE_URL_V3"
62     else
63       echo "One/All parameters not set in env file (<A1PMS_V3>, <A1PMS_API_PREFIX_V3>, <A1PMS_ALIVE_URL_V3>)"
64       break
65     fi
66   fi
67   # Tested variants of REST/DMAAP/SDNC config
68   TESTED_VARIANTS="REST   DMAAP   REST+SDNC   DMAAP+SDNC"
69
70   if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
71       TESTED_VARIANTS="REST   REST+SDNC"
72   fi
73
74   #Test a1pms and simulator protocol versions (others are http only)
75   TESTED_PROTOCOLS="HTTP HTTPS"
76   for __httpx in $TESTED_PROTOCOLS ; do
77       for interface in $TESTED_VARIANTS ; do
78
79           echo "#####################################################################"
80           echo "#####################################################################"
81           echo "### Testing a1pms: $interface using $__httpx with a1pms V${version}"
82           echo "#####################################################################"
83           echo "#####################################################################"
84
85           clean_environment
86
87           start_kube_proxy
88
89           if [ $__httpx == "HTTPS" ]; then
90               use_a1pms_rest_https
91           else
92               use_a1pms_rest_http
93           fi
94
95           start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
96
97           set_a1pms_trace
98
99           # Create service to be able to receive events when rics becomes available
100           # Must use rest towards the a1pms since dmaap is not configured yet
101           a1pms_api_put_service 201 "ric-registration" 0 "$CR_SERVICE_APP_PATH_0/ric-registration"
102
103           if [ $__httpx == "HTTPS" ]; then
104               use_cr_https
105               use_simulator_https
106               if [[ $interface = *"SDNC"* ]]; then
107                   if [[ "$SDNC_FEATURE_LEVEL" == *"NO_NB_HTTPS"* ]]; then
108                       deviation "SDNC does not support NB https"
109                       use_sdnc_http
110                   else
111                       use_sdnc_https
112                   fi
113               fi
114               if [[ $interface = *"DMAAP"* ]]; then
115                   use_a1pms_dmaap_https
116               else
117                   use_a1pms_rest_https
118               fi
119           else
120               use_cr_http
121               use_simulator_http
122               if [[ $interface = *"SDNC"* ]]; then
123                   use_sdnc_http
124               fi
125               if [[ $interface = *"DMAAP"* ]]; then
126                   use_a1pms_dmaap_http
127               else
128                   use_a1pms_rest_http
129               fi
130           fi
131           if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
132               :
133           else
134               if [ $__httpx == "HTTPS" ]; then
135                   use_mr_https
136               else
137                   use_mr_http
138               fi
139           fi
140
141           start_ric_simulators ricsim_g1 1  OSC_2.1.0
142           start_ric_simulators ricsim_g2 1  STD_1.1.3
143           start_ric_simulators ricsim_g3 1  STD_2.0.0
144
145           if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
146               :
147           else
148               start_mr    "$MR_READ_TOPIC"  "/events" "users/policy-agent" \
149                           "$MR_WRITE_TOPIC" "/events" "users/mr-stub"
150           fi
151
152           start_cr 1
153
154           start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
155
156           if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
157               start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
158           fi
159
160
161           if [[ $interface = *"SDNC"* ]]; then
162               start_sdnc
163               controller_api_wait_for_status_ok 200 ricsim_g1_1
164               prepare_a1pms_config      SDNC    ".a1pms_config.json"
165           else
166               prepare_a1pms_config      NOSDNC  ".a1pms_config.json"
167           fi
168
169           if [ $RUNMODE == "KUBE" ]; then
170               a1pms_load_config                       ".a1pms_config.json"
171           else
172               #Temporary switch to http/https if dmaap use. Otherwise it is not possible to push config
173               if [ $__httpx == "HTTPS" ]; then
174                   use_a1pms_rest_https
175               else
176                   use_a1pms_rest_http
177               fi
178               a1pms_api_put_configuration 200 ".a1pms_config.json"
179               if [ $__httpx == "HTTPS" ]; then
180                   if [[ $interface = *"DMAAP"* ]]; then
181                       use_a1pms_dmaap_https
182                   else
183                       use_a1pms_rest_https
184                   fi
185               else
186                   if [[ $interface = *"DMAAP"* ]]; then
187                       use_a1pms_dmaap_http
188                   else
189                       use_a1pms_rest_http
190                   fi
191               fi
192           fi
193
194           if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
195               :
196           else
197               mr_equal requests_submitted 0
198           fi
199
200           sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
201
202           sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
203
204           a1pms_equal json:rics 3 300
205
206           if [ "$A1PMS_VERSION" == "V3" ]; then
207             a1pms_equal json:policytypes 3 120
208           else
209             a1pms_equal json:policy-types 3 120
210             a1pms_equal json:policy-instances 0
211           fi
212
213           a1pms_equal json:policies 0
214
215           cr_equal 0 received_callbacks 3 120
216
217           cr_api_check_all_sync_events 200 0 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
218
219           echo "############################################"
220           echo "############## Health check ################"
221           echo "############################################"
222
223           sleep_wait 120 "Let A1PMS configuration take effect"
224
225           a1pms_api_get_status 200
226
227           echo "############################################"
228           echo "##### Service registry and supervision #####"
229           echo "############################################"
230
231           a1pms_api_put_service 201 "serv1" 1000 "$CR_SERVICE_APP_PATH_0/1"
232
233           a1pms_api_get_service_ids 200 "serv1" "ric-registration"
234
235           a1pms_api_put_services_keepalive 200 "serv1"
236
237           echo "############################################"
238           echo "############## RIC Repository ##############"
239           echo "############################################"
240
241           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"
242
243           echo "############################################"
244           echo "########### A1 Policy Management ###########"
245           echo "############################################"
246
247           notificationurl=$CR_SERVICE_APP_PATH_0"/test"
248           if [ "$A1PMS_VERSION" == "V3" ]; then
249             a1pms_api_post_policy_v3 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
250             a1pms_api_put_policy_v3 200 5000 testdata/OSC/pi1_template.json
251             a1pms_api_post_policy_v3 201 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
252             a1pms_api_put_policy_v3 200 5200 testdata/STD2/pi_qos_template.json
253             a1pms_api_post_policy_v3 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
254             a1pms_api_put_policy_v3 200 5100 testdata/STD/pi1_template.json
255           else
256             a1pms_api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
257             a1pms_api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
258             a1pms_api_put_policy 201 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
259             a1pms_api_put_policy 200 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
260
261             a1pms_api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
262             a1pms_api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
263           fi
264
265           a1pms_equal json:policies 3
266
267           a1pms_api_delete_policy 204 5000
268
269           a1pms_api_delete_policy 204 5100
270
271           a1pms_api_delete_policy 204 5200
272
273           a1pms_equal json:policies 0
274
275           if [ "$A1PMS_VERSION" != "V3" ]; then
276             a1pms_equal json:policy-instances 0
277           fi
278
279           cr_equal 0 received_callbacks 3
280
281           if [[ $interface = *"DMAAP"* ]]; then
282
283               VAL=14 # Number of a1pms API calls over DMAAP
284               mr_equal requests_fetched $VAL
285               mr_equal responses_submitted $VAL
286               mr_equal responses_fetched $VAL
287               mr_equal current_requests 0
288               mr_equal current_responses 0
289           else
290               if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
291                   :
292               else
293                   mr_equal requests_submitted 0
294               fi
295           fi
296
297           if [[ $interface = *"SDNC"* ]]; then
298               sim_contains_str ricsim_g1_1 remote_hosts $SDNC_APP_NAME
299               sim_contains_str ricsim_g2_1 remote_hosts $SDNC_APP_NAME
300               sim_contains_str ricsim_g3_1 remote_hosts $SDNC_APP_NAME
301           else
302               sim_contains_str ricsim_g1_1 remote_hosts $A1PMS_APP_NAME
303               sim_contains_str ricsim_g2_1 remote_hosts $A1PMS_APP_NAME
304               sim_contains_str ricsim_g3_1 remote_hosts $A1PMS_APP_NAME
305           fi
306
307           check_a1pms_logs
308
309
310           if [[ $interface = *"SDNC"* ]]; then
311               check_sdnc_logs
312           fi
313
314           store_logs          "${__httpx}__${interface}"
315
316       done
317
318   done
319
320 done
321 #### TEST COMPLETE ####
322
323
324 print_result
325
326 auto_clean_environment