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
42 . ../common/consul_cbs_functions.sh
48 #Local vars in test script
49 ##########################
51 # Number of RICs per interface type (OSC and STD)
53 if [ "$PMS_VERSION" == "V2" ]; then
54 NUM_RICS=20 # 3 A1 interfaces test, less sims per interface. total sims will be same
57 # Number of policy instances per RIC
64 # use HTTP or HTTPS for all apis
67 if [ $HTTPX == "HTTP" ]; then
79 start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
81 start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
83 if [ "$PMS_VERSION" == "V2" ]; then
84 start_ric_simulators ricsim_g3 $NUM_RICS STD_2.0.0
91 start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties
93 start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml
95 if [ $RUNMODE == "DOCKER" ]; then
99 prepare_consul_config SDNC ".consul_config.json"
101 if [ $RUNMODE == "KUBE" ]; then
102 agent_load_config ".consul_config.json"
104 consul_config_app ".consul_config.json"
112 echo "Print the interface for group 1 simulators, shall be OSC"
113 for ((i=1; i<=$NUM_RICS; i++))
115 sim_print ricsim_g1_$i interface
118 echo "Print the interface for group 2 simulators, shall be STD"
119 for ((i=1; i<=$NUM_RICS; i++))
121 sim_print ricsim_g2_$i interface
124 if [ "$PMS_VERSION" == "V2" ]; then
125 echo "Print the interface for group 2 simulators, shall be STD 2"
126 for ((i=1; i<=$NUM_RICS; i++))
128 sim_print ricsim_g3_$i interface
132 echo "Load policy type in group 1 simulators"
133 for ((i=1; i<=$NUM_RICS; i++))
135 sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
138 if [ "$PMS_VERSION" == "V2" ]; then
139 echo "Load policy type in group 3 simulators"
140 for ((i=1; i<=$NUM_RICS; i++))
142 sim_put_policy_type 201 ricsim_g3_$i STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
146 echo "Check the number of instances in group 1 simulators, shall be 0"
147 for ((i=1; i<=$NUM_RICS; i++))
149 sim_equal ricsim_g1_$i num_instances 0
152 echo "Check the number of instances in group 2 simulators, shall be 0"
153 for ((i=1; i<=$NUM_RICS; i++))
155 sim_equal ricsim_g2_$i num_instances 0
158 if [ "$PMS_VERSION" == "V2" ]; then
159 echo "Check the number of instances in group 3 simulators, shall be 0"
160 for ((i=1; i<=$NUM_RICS; i++))
162 sim_equal ricsim_g3_$i num_instances 0
166 echo "Wait for the agent to refresh types from the simulator"
167 if [ "$PMS_VERSION" == "V2" ]; then
168 api_equal json:policy-types 3 300
170 api_equal json:policy_types 2 300
173 echo "Check the number of types in the agent for each ric is 1"
174 for ((i=1; i<=$NUM_RICS; i++))
176 if [ "$PMS_VERSION" == "V2" ]; then
177 api_equal json:policy-types?ric_id=ricsim_g1_$i 1 120
178 api_equal json:policy-types?ric_id=ricsim_g3_$i 1 120
180 api_equal json:policy_types?ric=ricsim_g1_$i 1 120
184 echo "Register a service"
185 api_put_service 201 "serv1" 0 "$CR_SERVICE_PATH/1"
187 TEST_DURATION=$((24*3600*$DAYS))
190 AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
194 if [ "$PMS_VERSION" == "V2" ]; then
195 notificationurl=$CR_SERVICE_PATH"/test"
200 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
203 echo "#########################################################################################################"
204 echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
205 echo "#########################################################################################################"
208 for interface in $AGENT_INTERFACES ; do
210 echo "############################################"
211 echo "## Testing using agent interface: $interface ##"
212 echo "############################################"
214 if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
215 if [ $HTTPX == "HTTP" ]; then
221 if [ $HTTPX == "HTTPS" ]; then
222 echo "Using secure ports towards dmaap"
223 use_agent_dmaap_https
225 echo "Using non-secure ports towards dmaap"
230 echo "Create $NUM_INSTANCES instances in each OSC RIC"
233 if [ $interface == "REST_PARALLEL" ]; then
234 api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES 3
236 for ((i=1; i<=$NUM_RICS; i++))
238 if [ $interface == "DMAAP-BATCH" ]; then
239 api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
240 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
241 api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
243 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
244 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
246 sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
247 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
248 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
251 if [ "$PMS_VERSION" == "V2" ]; then
252 api_equal json:policy-instances $INSTANCES
254 api_equal json:policy_ids $INSTANCES
257 echo "Create $NUM_INSTANCES instances in each STD RIC"
258 if [ $interface == "REST_PARALLEL" ]; then
259 api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES 3
261 for ((i=1; i<=$NUM_RICS; i++))
263 if [ $interface == "DMAAP-BATCH" ]; then
264 api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
265 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
266 api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
268 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
269 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
271 sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
272 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
273 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
276 if [ "$PMS_VERSION" == "V2" ]; then
277 api_equal json:policy-instances $INSTANCES
279 api_equal json:policy_ids $INSTANCES
282 if [ "$PMS_VERSION" == "V2" ]; then
283 echo "Create $NUM_INSTANCES instances in each STD 2 RIC"
284 if [ $interface == "REST_PARALLEL" ]; then
285 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
287 for ((i=1; i<=$NUM_RICS; i++))
289 if [ $interface == "DMAAP-BATCH" ]; then
290 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
291 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
292 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
294 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
295 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
297 sim_equal ricsim_g3_$i num_instances $NUM_INSTANCES
298 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
299 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
302 if [ "$PMS_VERSION" == "V2" ]; then
303 api_equal json:policy-instances $INSTANCES
305 api_equal json:policy_ids $INSTANCES
310 echo "Delete all instances in each OSC RIC"
313 if [ $interface == "REST_PARALLEL" ]; then
314 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
316 for ((i=1; i<=$NUM_RICS; i++))
318 if [ $interface == "DMAAP-BATCH" ]; then
319 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
320 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
321 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
323 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
324 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
326 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
327 sim_equal ricsim_g1_$i num_instances 0
328 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
331 if [ "$PMS_VERSION" == "V2" ]; then
332 api_equal json:policy-instances $INSTANCES
334 api_equal json:policy_ids $INSTANCES
337 echo "Delete all instances in each STD RIC"
339 if [ $interface == "REST_PARALLEL" ]; then
340 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
342 for ((i=1; i<=$NUM_RICS; i++))
344 if [ $interface == "DMAAP-BATCH" ]; then
345 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
346 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
347 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
349 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
350 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
352 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
353 sim_equal ricsim_g2_$i num_instances 0
354 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
357 if [ "$PMS_VERSION" == "V2" ]; then
358 api_equal json:policy-instances $INSTANCES
360 api_equal json:policy_ids $INSTANCES
363 if [ "$PMS_VERSION" == "V2" ]; then
364 echo "Delete all instances in each STD 2 RIC"
366 if [ $interface == "REST_PARALLEL" ]; then
367 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
369 for ((i=1; i<=$NUM_RICS; i++))
371 if [ $interface == "DMAAP-BATCH" ]; then
372 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
373 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
374 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
376 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
377 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
379 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
380 sim_equal ricsim_g3_$i num_instances 0
381 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
384 if [ "$PMS_VERSION" == "V2" ]; then
385 api_equal json:policy-instances $INSTANCES
387 api_equal json:policy_ids $INSTANCES
391 mr_equal requests_submitted $MR_MESSAGES
392 mr_equal requests_fetched $MR_MESSAGES
393 mr_equal responses_submitted $MR_MESSAGES
394 mr_equal responses_fetched $MR_MESSAGES
395 mr_equal current_requests 0
396 mr_equal current_responses 0
399 for ((i=1; i<=$NUM_RICS; i++))
401 sim_contains_str ricsim_g1_$i remote_hosts $SDNC_APP_NAME
402 sim_contains_str ricsim_g2_$i remote_hosts $SDNC_APP_NAME
404 if [ "$PMS_VERSION" == "V2" ]; then
405 sim_contains_str ricsim_g3_$i remote_hosts $SDNC_APP_NAME
413 check_policy_agent_logs
416 #### TEST COMPLETE ####
422 auto_clean_environment