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 NGW KUBEPROXY"
25 #App names to include in the test when running kubernetes, space separated list
26 KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM SDNC KUBEPROXY NGW"
27 #Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
28 KUBE_PRESTARTED_IMAGES=""
30 #Ignore image in DOCKER_INCLUDED_IMAGES, KUBE_INCLUDED_IMAGES if
31 #the image is not configured in the supplied env_file
32 #Used for images not applicable to all supported profile
33 CONDITIONALLY_IGNORED_IMAGES="NGW"
35 #Supported test environment profiles
36 SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ONAP-ISTANBUL ORAN-CHERRY ORAN-D-RELEASE ORAN-E-RELEASE"
38 SUPPORTED_RUNMODES="DOCKER KUBE"
40 . ../common/testcase_common.sh $@
41 . ../common/agent_api_functions.sh
42 . ../common/ricsimulator_api_functions.sh
43 . ../common/cr_api_functions.sh
44 . ../common/mr_api_functions.sh
45 . ../common/control_panel_api_functions.sh
46 . ../common/controller_api_functions.sh
47 . ../common/consul_cbs_functions.sh
48 . ../common/kube_proxy_api_functions.sh
49 . ../common/gateway_api_functions.sh
57 #Local vars in test script
58 ##########################
60 # Number of RICs per interface type (OSC and STD)
62 if [ "$PMS_VERSION" == "V2" ]; then
63 NUM_RICS=20 # 3 A1 interfaces test, less sims per interface. total sims will be same
66 # Number of policy instances per RIC
75 # use HTTP or HTTPS for all apis
78 if [ $HTTPX == "HTTP" ]; then
90 start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
92 start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
94 if [ "$PMS_VERSION" == "V2" ]; then
95 start_ric_simulators ricsim_g3 $NUM_RICS STD_2.0.0
102 start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
104 if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
105 start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
108 start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/$POLICY_AGENT_CONFIG_FILE
110 if [ $RUNMODE == "DOCKER" ]; then
114 prepare_consul_config SDNC ".consul_config.json"
116 if [ $RUNMODE == "KUBE" ]; then
117 agent_load_config ".consul_config.json"
119 consul_config_app ".consul_config.json"
127 echo "Print the interface for group 1 simulators, shall be OSC"
128 for ((i=1; i<=$NUM_RICS; i++))
130 sim_print ricsim_g1_$i interface
133 echo "Print the interface for group 2 simulators, shall be STD"
134 for ((i=1; i<=$NUM_RICS; i++))
136 sim_print ricsim_g2_$i interface
139 if [ "$PMS_VERSION" == "V2" ]; then
140 echo "Print the interface for group 2 simulators, shall be STD 2"
141 for ((i=1; i<=$NUM_RICS; i++))
143 sim_print ricsim_g3_$i interface
147 echo "Load policy type in group 1 simulators"
148 for ((i=1; i<=$NUM_RICS; i++))
150 sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
153 if [ "$PMS_VERSION" == "V2" ]; then
154 echo "Load policy type in group 3 simulators"
155 for ((i=1; i<=$NUM_RICS; i++))
157 sim_put_policy_type 201 ricsim_g3_$i STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
161 echo "Check the number of instances in group 1 simulators, shall be 0"
162 for ((i=1; i<=$NUM_RICS; i++))
164 sim_equal ricsim_g1_$i num_instances 0
167 echo "Check the number of instances in group 2 simulators, shall be 0"
168 for ((i=1; i<=$NUM_RICS; i++))
170 sim_equal ricsim_g2_$i num_instances 0
173 if [ "$PMS_VERSION" == "V2" ]; then
174 echo "Check the number of instances in group 3 simulators, shall be 0"
175 for ((i=1; i<=$NUM_RICS; i++))
177 sim_equal ricsim_g3_$i num_instances 0
181 echo "Wait for the agent to refresh types from the simulator"
182 if [ "$PMS_VERSION" == "V2" ]; then
183 api_equal json:policy-types 3 300
185 api_equal json:policy_types 2 300
188 echo "Check the number of types in the agent for each ric is 1"
189 for ((i=1; i<=$NUM_RICS; i++))
191 if [ "$PMS_VERSION" == "V2" ]; then
192 api_equal json:policy-types?ric_id=ricsim_g1_$i 1 120
193 api_equal json:policy-types?ric_id=ricsim_g3_$i 1 120
195 api_equal json:policy_types?ric=ricsim_g1_$i 1 120
199 echo "Register a service"
200 api_put_service 201 "serv1" 0 "$CR_SERVICE_APP_PATH/1"
202 TEST_DURATION=$((24*3600*$DAYS))
205 AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
209 if [ "$PMS_VERSION" == "V2" ]; then
210 notificationurl=$CR_SERVICE_APP_PATH"/test"
215 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
218 echo "#########################################################################################################"
219 echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
220 echo "#########################################################################################################"
223 for interface in $AGENT_INTERFACES ; do
225 echo "############################################"
226 echo "## Testing using agent interface: $interface ##"
227 echo "############################################"
229 if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
230 if [ $HTTPX == "HTTP" ]; then
236 if [ $HTTPX == "HTTPS" ]; then
237 echo "Using secure ports towards dmaap"
238 use_agent_dmaap_https
240 echo "Using non-secure ports towards dmaap"
245 echo "Create $NUM_INSTANCES instances in each OSC RIC"
248 if [ $interface == "REST_PARALLEL" ]; then
249 api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES 3
251 for ((i=1; i<=$NUM_RICS; i++))
253 if [ $interface == "DMAAP-BATCH" ]; then
254 api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
255 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
256 api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
258 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
259 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
261 sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
262 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
263 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
266 if [ "$PMS_VERSION" == "V2" ]; then
267 api_equal json:policy-instances $INSTANCES
269 api_equal json:policy_ids $INSTANCES
272 echo "Create $NUM_INSTANCES instances in each STD RIC"
273 if [ $interface == "REST_PARALLEL" ]; then
274 api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES 3
276 for ((i=1; i<=$NUM_RICS; i++))
278 if [ $interface == "DMAAP-BATCH" ]; then
279 api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
280 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
281 api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
283 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
284 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
286 sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
287 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
288 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
291 if [ "$PMS_VERSION" == "V2" ]; then
292 api_equal json:policy-instances $INSTANCES
294 api_equal json:policy_ids $INSTANCES
297 if [ "$PMS_VERSION" == "V2" ]; then
298 echo "Create $NUM_INSTANCES instances in each STD 2 RIC"
299 if [ $interface == "REST_PARALLEL" ]; then
300 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
302 for ((i=1; i<=$NUM_RICS; i++))
304 if [ $interface == "DMAAP-BATCH" ]; then
305 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
306 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
307 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
309 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
310 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
312 sim_equal ricsim_g3_$i num_instances $NUM_INSTANCES
313 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
314 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
317 if [ "$PMS_VERSION" == "V2" ]; then
318 api_equal json:policy-instances $INSTANCES
320 api_equal json:policy_ids $INSTANCES
325 echo "Delete all instances in each OSC RIC"
328 if [ $interface == "REST_PARALLEL" ]; then
329 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
331 for ((i=1; i<=$NUM_RICS; i++))
333 if [ $interface == "DMAAP-BATCH" ]; then
334 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
335 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
336 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
338 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
339 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
341 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
342 sim_equal ricsim_g1_$i num_instances 0
343 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
346 if [ "$PMS_VERSION" == "V2" ]; then
347 api_equal json:policy-instances $INSTANCES
349 api_equal json:policy_ids $INSTANCES
352 echo "Delete all instances in each STD RIC"
354 if [ $interface == "REST_PARALLEL" ]; then
355 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
357 for ((i=1; i<=$NUM_RICS; i++))
359 if [ $interface == "DMAAP-BATCH" ]; then
360 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
361 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
362 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
364 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
365 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
367 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
368 sim_equal ricsim_g2_$i num_instances 0
369 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
372 if [ "$PMS_VERSION" == "V2" ]; then
373 api_equal json:policy-instances $INSTANCES
375 api_equal json:policy_ids $INSTANCES
378 if [ "$PMS_VERSION" == "V2" ]; then
379 echo "Delete all instances in each STD 2 RIC"
381 if [ $interface == "REST_PARALLEL" ]; then
382 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
384 for ((i=1; i<=$NUM_RICS; i++))
386 if [ $interface == "DMAAP-BATCH" ]; then
387 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
388 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
389 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
391 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
392 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
394 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
395 sim_equal ricsim_g3_$i num_instances 0
396 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
399 if [ "$PMS_VERSION" == "V2" ]; then
400 api_equal json:policy-instances $INSTANCES
402 api_equal json:policy_ids $INSTANCES
406 mr_equal requests_submitted $MR_MESSAGES
407 mr_equal requests_fetched $MR_MESSAGES
408 mr_equal responses_submitted $MR_MESSAGES
409 mr_equal responses_fetched $MR_MESSAGES
410 mr_equal current_requests 0
411 mr_equal current_responses 0
414 for ((i=1; i<=$NUM_RICS; i++))
416 sim_contains_str ricsim_g1_$i remote_hosts $SDNC_APP_NAME
417 sim_contains_str ricsim_g2_$i remote_hosts $SDNC_APP_NAME
419 if [ "$PMS_VERSION" == "V2" ]; then
420 sim_contains_str ricsim_g3_$i remote_hosts $SDNC_APP_NAME
428 check_policy_agent_logs
431 #### TEST COMPLETE ####
437 auto_clean_environment