Functional Test Updates for I Release
[nonrtric.git] / test / auto-test / FTC300.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 TC_ONELINE_DESCR="Resync 10000 policies using OSC and STD interface"
22
23 #App names to include in the test when running docker, space separated list
24 DOCKER_INCLUDED_IMAGES="CP CR MR 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 A1PMS RICSIM SDNC KUBEPROXY NGW"
28 #Pre-started 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-KOHN ONAP-LONDON ONAP-MONTREAL  ORAN-G-RELEASE ORAN-H-RELEASE ORAN-I-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 if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
51     TESTED_VARIANTS="REST   REST+SDNC"
52 else
53     TESTED_VARIANTS="REST   DMAAP   REST+SDNC   DMAAP+SDNC DMAAP_BATCH DMAAP_BATCH+SDNC"
54 fi
55 #Test a1pms and simulator protocol versions (others are http only)
56 TESTED_PROTOCOLS="HTTP HTTPS"
57
58 for __httpx in $TESTED_PROTOCOLS ; do
59     for interface in $TESTED_VARIANTS ; do
60
61         echo "#####################################################################"
62         echo "#####################################################################"
63         echo "### Testing a1pms: "$interface" and "$__httpx
64         echo "#####################################################################"
65         echo "#####################################################################"
66
67         if [ $__httpx == "HTTPS" ]; then
68             use_cr_https
69             use_simulator_https
70             if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
71                 :
72             else
73                 use_mr_https
74             fi
75             if [[ $interface = *"SDNC"* ]]; then
76                 if [[ "$SDNC_FEATURE_LEVEL" == *"NO_NB_HTTPS"* ]]; then
77                     deviation "SDNC does not support NB https"
78                     use_sdnc_http
79                 else
80                     use_sdnc_https
81                 fi
82             fi
83             if [[ $interface = *"DMAAP"* ]]; then
84                 use_a1pms_dmaap_https
85             else
86                 use_a1pms_rest_https
87             fi
88         else
89             use_cr_http
90             use_simulator_http
91             if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
92                 :
93             else
94                 use_mr_http
95             fi
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         # Clean container and start all needed containers #
107         clean_environment
108
109         start_kube_proxy
110
111         start_ric_simulators ricsim_g1 4 OSC_2.1.0
112
113         start_ric_simulators ricsim_g2 4 STD_1.1.3
114
115         start_ric_simulators ricsim_g3 4  STD_2.0.0
116
117         if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
118             :
119         else
120             start_mr
121         fi
122
123         start_cr 1
124
125         start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
126
127         if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
128             start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
129         fi
130
131         start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
132
133         set_a1pms_debug
134
135
136         if [[ $interface = *"SDNC"* ]]; then
137             start_sdnc
138             controller_api_wait_for_status_ok 200 ricsim_g1_1
139             prepare_a1pms_config      SDNC    ".a1pms_config.json"
140         else
141             prepare_a1pms_config      NOSDNC  ".a1pms_config.json"
142         fi
143
144         if [ $RUNMODE == "KUBE" ]; then
145             a1pms_load_config                       ".a1pms_config.json"
146         else
147             #Temporary switch to http/https if dmaap use. Otherwise it is not possible to push config
148             if [ $__httpx == "HTTPS" ]; then
149                 use_a1pms_rest_https
150             else
151                 use_a1pms_rest_http
152             fi
153             a1pms_api_put_configuration 200 ".a1pms_config.json"
154             if [ $__httpx == "HTTPS" ]; then
155                 if [[ $interface = *"DMAAP"* ]]; then
156                     use_a1pms_dmaap_https
157                 else
158                     use_a1pms_rest_https
159                 fi
160             else
161                 if [[ $interface = *"DMAAP"* ]]; then
162                     use_a1pms_dmaap_http
163                 else
164                     use_a1pms_rest_http
165                 fi
166             fi
167         fi
168
169         sleep_wait 120 "Let A1PMS configuration take effect"
170
171         a1pms_api_get_status 200
172
173         sim_print ricsim_g1_1 interface
174
175         sim_print ricsim_g2_1 interface
176
177         sim_print ricsim_g3_1 interface
178
179         sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
180
181         a1pms_equal json:policy-types 2 120  #Wait for the a1pms to refresh types from the simulator
182
183         a1pms_api_put_service 201 "serv1" 3600 "$CR_SERVICE_APP_PATH_0/1"
184
185         START_ID=2000
186         NUM_POLICIES=10000  # Must be at least 100
187
188         notificationurl=$CR_SERVICE_APP_PATH_0"/test"
189
190         if [[ $interface == *"BATCH"* ]]; then
191             a1pms_api_put_policy_batch 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_POLICIES
192         else
193             a1pms_api_put_policy 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_POLICIES
194         fi
195
196         sim_equal ricsim_g1_1 num_instances $NUM_POLICIES
197
198         sim_post_delete_instances 200 ricsim_g1_1
199
200         sim_equal ricsim_g1_1 num_instances 0
201
202         if [[ $interface = *"SDNC"* ]]; then
203             deviation "Sync over SDNC seem to be slower from Jakarta version..."
204             sim_equal ricsim_g1_1 num_instances $NUM_POLICIES 2000
205         else
206             sim_equal ricsim_g1_1 num_instances $NUM_POLICIES 300
207         fi
208
209         START_ID2=$(($START_ID+$NUM_POLICIES))
210
211         if [[ $interface == *"BATCH"* ]]; then
212             a1pms_api_put_policy_batch 201 "serv1" ricsim_g2_1 NOTYPE $START_ID2 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_POLICIES
213         else
214             a1pms_api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE $START_ID2 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_POLICIES
215         fi
216         sim_equal ricsim_g2_1 num_instances $NUM_POLICIES
217
218         sim_post_delete_instances 200 ricsim_g2_1
219
220         sim_equal ricsim_g2_1 num_instances 0
221         if [[ $interface = *"SDNC"* ]]; then
222             deviation "Sync over SDNC seem to be slower from Jakarta version..."
223             sim_equal ricsim_g2_1 num_instances $NUM_POLICIES 2000
224         else
225             sim_equal ricsim_g2_1 num_instances $NUM_POLICIES 300
226         fi
227
228         a1pms_api_delete_policy 204 $(($START_ID+47))
229
230         a1pms_api_delete_policy 204 $(($START_ID+$NUM_POLICIES-39))
231
232         sim_post_delete_instances 200 ricsim_g1_1
233
234         if [[ $interface = *"SDNC"* ]]; then
235             deviation "Sync over SDNC seem to be slower from Jakarta version..."
236             sim_equal ricsim_g1_1 num_instances $(($NUM_POLICIES-2)) 2000
237         else
238             sim_equal ricsim_g1_1 num_instances $(($NUM_POLICIES-2)) 300
239         fi
240
241         a1pms_api_delete_policy 204 $(($START_ID2+37))
242
243         a1pms_api_delete_policy 204 $(($START_ID2+$NUM_POLICIES-93))
244
245         a1pms_api_delete_policy 204 $(($START_ID2+$NUM_POLICIES-91))
246
247         sim_post_delete_instances 200 ricsim_g2_1
248
249         if [[ $interface = *"SDNC"* ]]; then
250             deviation "Sync over SDNC seem to be slower from Jakarta version..."
251             sim_equal ricsim_g1_1 num_instances $(($NUM_POLICIES-2)) 2000
252
253             sim_equal ricsim_g2_1 num_instances $(($NUM_POLICIES-3)) 2000
254         else
255             sim_equal ricsim_g1_1 num_instances $(($NUM_POLICIES-2)) 300
256
257             sim_equal ricsim_g2_1 num_instances $(($NUM_POLICIES-3)) 300
258         fi
259
260         a1pms_equal json:policies $(($NUM_POLICIES-2+$NUM_POLICIES-3))
261
262
263         if [[ $interface = *"SDNC"* ]]; then
264             check_sdnc_logs
265         fi
266
267         check_a1pms_logs
268         check_sdnc_logs
269         store_logs          "${__httpx}__${interface}"
270
271     done
272
273 done
274
275
276 #### TEST COMPLETE ####
277
278
279 print_result
280
281 auto_clean_environment