a6914b4b0fd38d1b9a56b2326e88c75cf618fbed
[nonrtric.git] / test / auto-test / FTC800.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="Create 10000 policies in sequence 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 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 #Local vars in test script
50 ##########################
51 # Number of policies in each sequence
52 NUM_POLICIES=10000
53
54 # Tested variants of SDNC config
55 TESTED_VARIANTS="NOSDNC   SDNC"
56
57 #Test a1pms and simulator protocol versions (others are http only)
58 TESTED_PROTOCOLS="HTTP HTTPS"
59
60 for __httpx in $TESTED_PROTOCOLS ; do
61     for interface in $TESTED_VARIANTS ; do
62
63         echo "#####################################################################"
64         echo "#####################################################################"
65         echo "### Testing a1pms via $interface using $__httpx"
66         echo "#####################################################################"
67         echo "#####################################################################"
68
69         if [ $__httpx == "HTTPS" ]; then
70             use_cr_https
71             use_simulator_https
72             use_mr_https
73             use_a1pms_rest_https
74         else
75             use_cr_http
76             use_simulator_http
77             use_mr_http
78             use_a1pms_rest_http
79         fi
80
81         # Policy instance start id
82         START_ID=1
83
84         clean_environment
85
86         start_kube_proxy
87
88         start_ric_simulators ricsim_g1 1 OSC_2.1.0
89         start_ric_simulators ricsim_g2 1 STD_1.1.3
90         start_ric_simulators ricsim_g3 1  STD_2.0.0
91
92         if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
93             :
94         else
95             start_mr
96         fi
97
98         start_cr 1
99
100         start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
101
102         if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
103             start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
104         fi
105
106         start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
107
108         set_a1pms_debug
109
110         if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
111             :
112         else
113             mr_equal requests_submitted 0
114         fi
115
116         sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
117         sim_put_policy_type 201 ricsim_g3_1 STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
118
119
120         if [[ $interface == "SDNC" ]]; then
121             start_sdnc
122             controller_api_wait_for_status_ok 200 ricsim_g1_1
123             prepare_a1pms_config      SDNC    ".a1pms_config.json"
124         else
125             prepare_a1pms_config      NOSDNC  ".a1pms_config.json"
126         fi
127
128         if [ $RUNMODE == "KUBE" ]; then
129             a1pms_load_config                       ".a1pms_config.json"
130         else
131             a1pms_api_put_configuration 200 ".a1pms_config.json"
132         fi
133
134         sleep_wait 120 "Let A1PMS configuration take effect"
135
136         a1pms_api_get_status 200
137
138         sim_print ricsim_g1_1 interface
139         sim_print ricsim_g2_1 interface
140         sim_print ricsim_g3_1 interface
141
142         a1pms_equal json:policy-types 3 300  #Wait for the a1pms to refresh types from the simulators
143
144         a1pms_api_put_service 201 "serv1" 3600 "$CR_SERVICE_APP_PATH_0/1"
145
146         notificationurl=$CR_SERVICE_APP_PATH_0"/test"
147
148         start_timer "Create polices in OSC via a1pms REST and $interface using "$__httpx
149         a1pms_api_put_policy 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_POLICIES
150         print_timer "Create polices in OSC via a1pms REST and $interface using "$__httpx
151
152         sim_equal ricsim_g1_1 num_instances $NUM_POLICIES
153
154         START_ID=$(($START_ID+$NUM_POLICIES))
155
156         start_timer "Create polices in STD via a1pms REST and $interface using "$__httpx
157         a1pms_api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE $START_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_POLICIES
158         print_timer "Create polices in STD via a1pms REST and $interface using "$__httpx
159
160         sim_equal ricsim_g2_1 num_instances $NUM_POLICIES
161
162
163
164         START_ID=$(($START_ID+$NUM_POLICIES))
165
166         start_timer "Create polices in STD 2 via a1pms REST and $interface using "$__httpx
167         a1pms_api_put_policy 201 "serv1" ricsim_g3_1 STD_QOS2_0.1.0 $START_ID NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json $NUM_POLICIES
168         print_timer "Create polices in STD via a1pms REST and $interface using "$__httpx
169
170         sim_equal ricsim_g3_1 num_instances $NUM_POLICIES
171
172
173         INTERFACE_VARIANT=
174         if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
175             INTERFACE_VARIANT=REST
176             if [ $__httpx == "HTTPS" ]; then
177                 use_a1pms_rest_https
178             else
179                 use_a1pms_rest_http
180             fi
181         else
182             INTERFACE_VARIANT=DMAAP
183             if [ $__httpx == "HTTPS" ]; then
184                 echo "Using secure ports towards dmaap"
185                 use_a1pms_dmaap_https
186             else
187                 echo "Using non-secure ports towards dmaap"
188                 use_a1pms_dmaap_http
189             fi
190         fi
191
192         START_ID=$(($START_ID+$NUM_POLICIES))
193
194         start_timer "Create polices in OSC via a1pms $INTERFACE_VARIANT, one by one, and $interface using "$__httpx
195         a1pms_api_put_policy 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_POLICIES
196         print_timer "Create polices in OSC via a1pms $INTERFACE_VARIANT, one by one, and $interface using "$__httpx
197
198         sim_equal ricsim_g1_1 num_instances $((2*$NUM_POLICIES))
199
200         START_ID=$(($START_ID+$NUM_POLICIES))
201
202         start_timer "Create polices in STD via a1pms $INTERFACE_VARIANT, one by one, and $interface using "$__httpx
203         a1pms_api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE $START_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_POLICIES
204         print_timer "Create polices in STD via a1pms $INTERFACE_VARIANT, one by one, and $interface using "$__httpx
205
206         sim_equal ricsim_g2_1 num_instances $((2*$NUM_POLICIES))
207
208
209         START_ID=$(($START_ID+$NUM_POLICIES))
210
211         start_timer "Create polices in STD 2 via a1pms $INTERFACE_VARIANT, one by one, and $interface using "$__httpx
212         a1pms_api_put_policy 201 "serv1" ricsim_g3_1 STD_QOS2_0.1.0 $START_ID NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json $NUM_POLICIES
213         print_timer "Create polices in STD via a1pms $INTERFACE_VARIANT, one by one, and $interface using "$__httpx
214
215         sim_equal ricsim_g3_1 num_instances $((2*$NUM_POLICIES))
216
217         if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
218             :
219         else
220             START_ID=$(($START_ID+$NUM_POLICIES))
221             start_timer "Create polices in OSC via a1pms $INTERFACE_VARIANT in batch and $interface using "$__httpx
222             a1pms_api_put_policy_batch 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_POLICIES
223             print_timer "Create polices in OSC via a1pms $INTERFACE_VARIANT in batch and $interface using "$__httpx
224
225             sim_equal ricsim_g1_1 num_instances $((3*$NUM_POLICIES))
226
227             START_ID=$(($START_ID+$NUM_POLICIES))
228
229             start_timer "Create polices in STD via a1pms $INTERFACE_VARIANT in batch and $interface using "$__httpx
230             a1pms_api_put_policy_batch 201 "serv1" ricsim_g2_1 NOTYPE $START_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_POLICIES
231             print_timer "Create polices in STD via a1pms $INTERFACE_VARIANT in batch and $interface using "$__httpx
232
233             sim_equal ricsim_g2_1 num_instances $((3*$NUM_POLICIES))
234
235
236             START_ID=$(($START_ID+$NUM_POLICIES))
237
238             start_timer "Create polices in STD via a1pms $INTERFACE_VARIANT in batch and $interface using "$__httpx
239             a1pms_api_put_policy_batch 201 "serv1" ricsim_g3_1 STD_QOS2_0.1.0 $START_ID NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json $NUM_POLICIES
240             print_timer "Create polices in STD via a1pms $INTERFACE_VARIANT in batch and $interface using "$__httpx
241
242             sim_equal ricsim_g3_1 num_instances $((3*$NUM_POLICIES))
243         fi
244
245         if [ $interface == "SDNC" ]; then
246             sim_contains_str ricsim_g1_1 remote_hosts $SDNC_APP_NAME
247             sim_contains_str ricsim_g2_1 remote_hosts $SDNC_APP_NAME
248             sim_contains_str ricsim_g3_1 remote_hosts $SDNC_APP_NAME
249         else
250             sim_contains_str ricsim_g1_1 remote_hosts $A1PMS_APP_NAME
251             sim_contains_str ricsim_g2_1 remote_hosts $A1PMS_APP_NAME
252             sim_contains_str ricsim_g3_1 remote_hosts $A1PMS_APP_NAME
253         fi
254
255         check_a1pms_logs
256         if [[ $interface = *"SDNC"* ]]; then
257             check_sdnc_logs
258         fi
259
260         store_logs          "${__httpx}__${interface}"
261     done
262 done
263
264 #### TEST COMPLETE ####
265
266 print_result
267
268 auto_clean_environment