3 # ============LICENSE_START===============================================
4 # Copyright (C) 2020 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
10 # http://www.apache.org/licenses/LICENSE-2.0
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=================================================
20 TC_ONELINE_DESCR="Repeatedly create and delete policies in each RICs for 24h (or configured number of days). Via agent REST/DMAAP/DMAAP_BATCH and SDNC using http or https"
22 #App names to include in the test when running docker, space separated list
23 DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
25 #App names to include in the test when running kubernetes, space separated list
26 KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM SDNC"
27 #Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
28 KUBE_PRESTARTED_IMAGES=""
30 #Supported test environment profiles
31 SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN"
33 SUPPORTED_RUNMODES="DOCKER KUBE"
35 . ../common/testcase_common.sh $@
36 . ../common/agent_api_functions.sh
37 . ../common/ricsimulator_api_functions.sh
38 . ../common/cr_api_functions.sh
39 . ../common/mr_api_functions.sh
40 . ../common/control_panel_api_functions.sh
41 . ../common/controller_api_functions.sh
47 #Local vars in test script
48 ##########################
50 # Number of RICs per interface type (OSC and STD)
52 if [ "$PMS_VERSION" == "V2" ]; then
53 NUM_RICS=20 # 3 A1 interfaces test, less sims per interface. total sims will be same
56 # Number of policy instances per RIC
63 # use HTTP or HTTPS for all apis
66 if [ $HTTPX == "HTTP" ]; then
78 start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
80 start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
82 if [ "$PMS_VERSION" == "V2" ]; then
83 start_ric_simulators ricsim_g3 $NUM_RICS STD_2.0.0
90 start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties
92 start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml
94 if [ $RUNMODE == "DOCKER" ]; then
98 prepare_consul_config SDNC ".consul_config.json"
100 if [ $RUNMODE == "KUBE" ]; then
101 agent_load_config ".consul_config.json"
103 consul_config_app ".consul_config.json"
111 echo "Print the interface for group 1 simulators, shall be OSC"
112 for ((i=1; i<=$NUM_RICS; i++))
114 sim_print ricsim_g1_$i interface
117 echo "Print the interface for group 2 simulators, shall be STD"
118 for ((i=1; i<=$NUM_RICS; i++))
120 sim_print ricsim_g2_$i interface
123 if [ "$PMS_VERSION" == "V2" ]; then
124 echo "Print the interface for group 2 simulators, shall be STD 2"
125 for ((i=1; i<=$NUM_RICS; i++))
127 sim_print ricsim_g3_$i interface
131 echo "Load policy type in group 1 simulators"
132 for ((i=1; i<=$NUM_RICS; i++))
134 sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
137 if [ "$PMS_VERSION" == "V2" ]; then
138 echo "Load policy type in group 3 simulators"
139 for ((i=1; i<=$NUM_RICS; i++))
141 sim_put_policy_type 201 ricsim_g3_$i STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
145 echo "Check the number of instances in group 1 simulators, shall be 0"
146 for ((i=1; i<=$NUM_RICS; i++))
148 sim_equal ricsim_g1_$i num_instances 0
151 echo "Check the number of instances in group 2 simulators, shall be 0"
152 for ((i=1; i<=$NUM_RICS; i++))
154 sim_equal ricsim_g2_$i num_instances 0
157 if [ "$PMS_VERSION" == "V2" ]; then
158 echo "Check the number of instances in group 3 simulators, shall be 0"
159 for ((i=1; i<=$NUM_RICS; i++))
161 sim_equal ricsim_g3_$i num_instances 0
165 echo "Wait for the agent to refresh types from the simulator"
166 if [ "$PMS_VERSION" == "V2" ]; then
167 api_equal json:policy-types 3 300
169 api_equal json:policy_types 2 300
172 echo "Check the number of types in the agent for each ric is 1"
173 for ((i=1; i<=$NUM_RICS; i++))
175 if [ "$PMS_VERSION" == "V2" ]; then
176 api_equal json:policy-types?ric_id=ricsim_g1_$i 1 120
177 api_equal json:policy-types?ric_id=ricsim_g3_$i 1 120
179 api_equal json:policy_types?ric=ricsim_g1_$i 1 120
183 echo "Register a service"
184 api_put_service 201 "serv1" 0 "$CR_SERVICE_PATH/1"
186 TEST_DURATION=$((24*3600*$DAYS))
189 AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
193 if [ "$PMS_VERSION" == "V2" ]; then
194 notificationurl=$CR_SERVICE_PATH"/test"
199 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
202 echo "#########################################################################################################"
203 echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
204 echo "#########################################################################################################"
207 for interface in $AGENT_INTERFACES ; do
209 echo "############################################"
210 echo "## Testing using agent interface: $interface ##"
211 echo "############################################"
213 if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
214 if [ $HTTPX == "HTTP" ]; then
220 if [ $HTTPX == "HTTPS" ]; then
221 echo "Using secure ports towards dmaap"
222 use_agent_dmaap_https
224 echo "Using non-secure ports towards dmaap"
229 echo "Create $NUM_INSTANCES instances in each OSC RIC"
232 if [ $interface == "REST_PARALLEL" ]; then
233 api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES 3
235 for ((i=1; i<=$NUM_RICS; i++))
237 if [ $interface == "DMAAP-BATCH" ]; then
238 api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
239 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
240 api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
242 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
243 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
245 sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
246 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
247 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
250 if [ "$PMS_VERSION" == "V2" ]; then
251 api_equal json:policy-instances $INSTANCES
253 api_equal json:policy_ids $INSTANCES
256 echo "Create $NUM_INSTANCES instances in each STD RIC"
257 if [ $interface == "REST_PARALLEL" ]; then
258 api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES 3
260 for ((i=1; i<=$NUM_RICS; i++))
262 if [ $interface == "DMAAP-BATCH" ]; then
263 api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
264 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
265 api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
267 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
268 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
270 sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
271 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
272 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
275 if [ "$PMS_VERSION" == "V2" ]; then
276 api_equal json:policy-instances $INSTANCES
278 api_equal json:policy_ids $INSTANCES
281 if [ "$PMS_VERSION" == "V2" ]; then
282 echo "Create $NUM_INSTANCES instances in each STD 2 RIC"
283 if [ $interface == "REST_PARALLEL" ]; then
284 api_put_policy_parallel 201 "serv1" ricsim_g3_ $NUM_RICS STD_QOS2_0.1.0 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json $NUM_INSTANCES 3
286 for ((i=1; i<=$NUM_RICS; i++))
288 if [ $interface == "DMAAP-BATCH" ]; then
289 api_put_policy_batch 201 "serv1" ricsim_g3_$i STD_QOS2_0.1.0 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json $NUM_INSTANCES
290 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
291 api_put_policy 201 "serv1" ricsim_g3_$i STD_QOS2_0.1.0 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json $NUM_INSTANCES
293 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
294 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
296 sim_equal ricsim_g3_$i num_instances $NUM_INSTANCES
297 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
298 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
301 if [ "$PMS_VERSION" == "V2" ]; then
302 api_equal json:policy-instances $INSTANCES
304 api_equal json:policy_ids $INSTANCES
309 echo "Delete all instances in each OSC RIC"
312 if [ $interface == "REST_PARALLEL" ]; then
313 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
315 for ((i=1; i<=$NUM_RICS; i++))
317 if [ $interface == "DMAAP-BATCH" ]; then
318 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
319 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
320 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
322 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
323 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
325 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
326 sim_equal ricsim_g1_$i num_instances 0
327 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
330 if [ "$PMS_VERSION" == "V2" ]; then
331 api_equal json:policy-instances $INSTANCES
333 api_equal json:policy_ids $INSTANCES
336 echo "Delete all instances in each STD RIC"
338 if [ $interface == "REST_PARALLEL" ]; then
339 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
341 for ((i=1; i<=$NUM_RICS; i++))
343 if [ $interface == "DMAAP-BATCH" ]; then
344 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
345 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
346 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
348 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
349 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
351 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
352 sim_equal ricsim_g2_$i num_instances 0
353 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
356 if [ "$PMS_VERSION" == "V2" ]; then
357 api_equal json:policy-instances $INSTANCES
359 api_equal json:policy_ids $INSTANCES
362 if [ "$PMS_VERSION" == "V2" ]; then
363 echo "Delete all instances in each STD 2 RIC"
365 if [ $interface == "REST_PARALLEL" ]; then
366 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
368 for ((i=1; i<=$NUM_RICS; i++))
370 if [ $interface == "DMAAP-BATCH" ]; then
371 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
372 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
373 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
375 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
376 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
378 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
379 sim_equal ricsim_g3_$i num_instances 0
380 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
383 if [ "$PMS_VERSION" == "V2" ]; then
384 api_equal json:policy-instances $INSTANCES
386 api_equal json:policy_ids $INSTANCES
390 mr_equal requests_submitted $MR_MESSAGES
391 mr_equal requests_fetched $MR_MESSAGES
392 mr_equal responses_submitted $MR_MESSAGES
393 mr_equal responses_fetched $MR_MESSAGES
394 mr_equal current_requests 0
395 mr_equal current_responses 0
398 for ((i=1; i<=$NUM_RICS; i++))
400 sim_contains_str ricsim_g1_$i remote_hosts $SDNC_APP_NAME
401 sim_contains_str ricsim_g2_$i remote_hosts $SDNC_APP_NAME
403 if [ "$PMS_VERSION" == "V2" ]; then
404 sim_contains_str ricsim_g3_$i remote_hosts $SDNC_APP_NAME
412 check_policy_agent_logs
415 #### TEST COMPLETE ####
421 auto_clean_environment