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"
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
73 if [ $RUNMODE == "KUBE" ]; then
77 # use HTTP or HTTPS for all apis
80 if [ $HTTPX == "HTTP" ]; then
92 start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
94 start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
96 if [ "$PMS_VERSION" == "V2" ]; then
97 start_ric_simulators ricsim_g3 $NUM_RICS STD_2.0.0
104 start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
106 if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
107 start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
110 start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/$POLICY_AGENT_CONFIG_FILE
112 if [ $RUNMODE == "DOCKER" ]; then
116 prepare_consul_config SDNC ".consul_config.json"
118 if [ $RUNMODE == "KUBE" ]; then
119 agent_load_config ".consul_config.json"
121 consul_config_app ".consul_config.json"
129 echo "Print the interface for group 1 simulators, shall be OSC"
130 for ((i=1; i<=$NUM_RICS; i++))
132 sim_print ricsim_g1_$i interface
135 echo "Print the interface for group 2 simulators, shall be STD"
136 for ((i=1; i<=$NUM_RICS; i++))
138 sim_print ricsim_g2_$i interface
141 if [ "$PMS_VERSION" == "V2" ]; then
142 echo "Print the interface for group 2 simulators, shall be STD 2"
143 for ((i=1; i<=$NUM_RICS; i++))
145 sim_print ricsim_g3_$i interface
149 echo "Load policy type in group 1 simulators"
150 for ((i=1; i<=$NUM_RICS; i++))
152 sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
155 if [ "$PMS_VERSION" == "V2" ]; then
156 echo "Load policy type in group 3 simulators"
157 for ((i=1; i<=$NUM_RICS; i++))
159 sim_put_policy_type 201 ricsim_g3_$i STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
163 echo "Check the number of instances in group 1 simulators, shall be 0"
164 for ((i=1; i<=$NUM_RICS; i++))
166 sim_equal ricsim_g1_$i num_instances 0
169 echo "Check the number of instances in group 2 simulators, shall be 0"
170 for ((i=1; i<=$NUM_RICS; i++))
172 sim_equal ricsim_g2_$i num_instances 0
175 if [ "$PMS_VERSION" == "V2" ]; then
176 echo "Check the number of instances in group 3 simulators, shall be 0"
177 for ((i=1; i<=$NUM_RICS; i++))
179 sim_equal ricsim_g3_$i num_instances 0
183 echo "Wait for the agent to refresh types from the simulator"
184 if [ "$PMS_VERSION" == "V2" ]; then
185 api_equal json:policy-types 3 300
187 api_equal json:policy_types 2 300
190 echo "Check the number of types in the agent for each ric is 1"
191 for ((i=1; i<=$NUM_RICS; i++))
193 if [ "$PMS_VERSION" == "V2" ]; then
194 api_equal json:policy-types?ric_id=ricsim_g1_$i 1 120
195 api_equal json:policy-types?ric_id=ricsim_g3_$i 1 120
197 api_equal json:policy_types?ric=ricsim_g1_$i 1 120
201 echo "Register a service"
202 api_put_service 201 "serv1" 0 "$CR_SERVICE_PATH/1"
204 TEST_DURATION=$((24*3600*$DAYS))
207 AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
211 if [ "$PMS_VERSION" == "V2" ]; then
212 notificationurl=$CR_SERVICE_PATH"/test"
217 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
220 echo "#########################################################################################################"
221 echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
222 echo "#########################################################################################################"
225 for interface in $AGENT_INTERFACES ; do
227 echo "############################################"
228 echo "## Testing using agent interface: $interface ##"
229 echo "############################################"
231 if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
232 if [ $HTTPX == "HTTP" ]; then
238 if [ $HTTPX == "HTTPS" ]; then
239 echo "Using secure ports towards dmaap"
240 use_agent_dmaap_https
242 echo "Using non-secure ports towards dmaap"
247 echo "Create $NUM_INSTANCES instances in each OSC RIC"
250 if [ $interface == "REST_PARALLEL" ]; then
251 api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES 3
253 for ((i=1; i<=$NUM_RICS; i++))
255 if [ $interface == "DMAAP-BATCH" ]; then
256 api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
257 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
258 api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
260 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
261 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
263 sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
264 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
265 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
268 if [ "$PMS_VERSION" == "V2" ]; then
269 api_equal json:policy-instances $INSTANCES
271 api_equal json:policy_ids $INSTANCES
274 echo "Create $NUM_INSTANCES instances in each STD RIC"
275 if [ $interface == "REST_PARALLEL" ]; then
276 api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES 3
278 for ((i=1; i<=$NUM_RICS; i++))
280 if [ $interface == "DMAAP-BATCH" ]; then
281 api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
282 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
283 api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
285 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
286 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
288 sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
289 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
290 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
293 if [ "$PMS_VERSION" == "V2" ]; then
294 api_equal json:policy-instances $INSTANCES
296 api_equal json:policy_ids $INSTANCES
299 if [ "$PMS_VERSION" == "V2" ]; then
300 echo "Create $NUM_INSTANCES instances in each STD 2 RIC"
301 if [ $interface == "REST_PARALLEL" ]; then
302 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
304 for ((i=1; i<=$NUM_RICS; i++))
306 if [ $interface == "DMAAP-BATCH" ]; then
307 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
308 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
309 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
311 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
312 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
314 sim_equal ricsim_g3_$i num_instances $NUM_INSTANCES
315 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
316 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
319 if [ "$PMS_VERSION" == "V2" ]; then
320 api_equal json:policy-instances $INSTANCES
322 api_equal json:policy_ids $INSTANCES
327 echo "Delete all instances in each OSC RIC"
330 if [ $interface == "REST_PARALLEL" ]; then
331 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
333 for ((i=1; i<=$NUM_RICS; i++))
335 if [ $interface == "DMAAP-BATCH" ]; then
336 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
337 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
338 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
340 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
341 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
343 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
344 sim_equal ricsim_g1_$i num_instances 0
345 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
348 if [ "$PMS_VERSION" == "V2" ]; then
349 api_equal json:policy-instances $INSTANCES
351 api_equal json:policy_ids $INSTANCES
354 echo "Delete all instances in each STD RIC"
356 if [ $interface == "REST_PARALLEL" ]; then
357 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
359 for ((i=1; i<=$NUM_RICS; i++))
361 if [ $interface == "DMAAP-BATCH" ]; then
362 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
363 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
364 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
366 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
367 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
369 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
370 sim_equal ricsim_g2_$i num_instances 0
371 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
374 if [ "$PMS_VERSION" == "V2" ]; then
375 api_equal json:policy-instances $INSTANCES
377 api_equal json:policy_ids $INSTANCES
380 if [ "$PMS_VERSION" == "V2" ]; then
381 echo "Delete all instances in each STD 2 RIC"
383 if [ $interface == "REST_PARALLEL" ]; then
384 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
386 for ((i=1; i<=$NUM_RICS; i++))
388 if [ $interface == "DMAAP-BATCH" ]; then
389 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
390 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
391 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
393 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
394 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
396 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
397 sim_equal ricsim_g3_$i num_instances 0
398 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
401 if [ "$PMS_VERSION" == "V2" ]; then
402 api_equal json:policy-instances $INSTANCES
404 api_equal json:policy_ids $INSTANCES
408 mr_equal requests_submitted $MR_MESSAGES
409 mr_equal requests_fetched $MR_MESSAGES
410 mr_equal responses_submitted $MR_MESSAGES
411 mr_equal responses_fetched $MR_MESSAGES
412 mr_equal current_requests 0
413 mr_equal current_responses 0
416 for ((i=1; i<=$NUM_RICS; i++))
418 sim_contains_str ricsim_g1_$i remote_hosts $SDNC_APP_NAME
419 sim_contains_str ricsim_g2_$i remote_hosts $SDNC_APP_NAME
421 if [ "$PMS_VERSION" == "V2" ]; then
422 sim_contains_str ricsim_g3_$i remote_hosts $SDNC_APP_NAME
430 check_policy_agent_logs
433 #### TEST COMPLETE ####
439 auto_clean_environment