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 ONAP-JAKARTA ORAN-CHERRY ORAN-D-RELEASE ORAN-E-RELEASE ORAN-F-RELEASE"
38 SUPPORTED_RUNMODES="DOCKER KUBE"
40 . ../common/testcase_common.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
66 # use HTTP or HTTPS for all apis
69 if [ $HTTPX == "HTTP" ]; then
81 start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
83 start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
85 if [ "$PMS_VERSION" == "V2" ]; then
86 start_ric_simulators ricsim_g3 $NUM_RICS STD_2.0.0
93 start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
95 if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
96 start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
99 start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/$POLICY_AGENT_CONFIG_FILE
101 if [ $RUNMODE == "DOCKER" ]; then
105 prepare_consul_config SDNC ".consul_config.json"
107 if [ $RUNMODE == "KUBE" ]; then
108 agent_load_config ".consul_config.json"
110 consul_config_app ".consul_config.json"
118 echo "Print the interface for group 1 simulators, shall be OSC"
119 for ((i=1; i<=$NUM_RICS; i++))
121 sim_print ricsim_g1_$i interface
124 echo "Print the interface for group 2 simulators, shall be STD"
125 for ((i=1; i<=$NUM_RICS; i++))
127 sim_print ricsim_g2_$i interface
130 if [ "$PMS_VERSION" == "V2" ]; then
131 echo "Print the interface for group 2 simulators, shall be STD 2"
132 for ((i=1; i<=$NUM_RICS; i++))
134 sim_print ricsim_g3_$i interface
138 echo "Load policy type in group 1 simulators"
139 for ((i=1; i<=$NUM_RICS; i++))
141 sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
144 if [ "$PMS_VERSION" == "V2" ]; then
145 echo "Load policy type in group 3 simulators"
146 for ((i=1; i<=$NUM_RICS; i++))
148 sim_put_policy_type 201 ricsim_g3_$i STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
152 echo "Check the number of instances in group 1 simulators, shall be 0"
153 for ((i=1; i<=$NUM_RICS; i++))
155 sim_equal ricsim_g1_$i num_instances 0
158 echo "Check the number of instances in group 2 simulators, shall be 0"
159 for ((i=1; i<=$NUM_RICS; i++))
161 sim_equal ricsim_g2_$i num_instances 0
164 if [ "$PMS_VERSION" == "V2" ]; then
165 echo "Check the number of instances in group 3 simulators, shall be 0"
166 for ((i=1; i<=$NUM_RICS; i++))
168 sim_equal ricsim_g3_$i num_instances 0
172 echo "Wait for the agent to refresh types from the simulator"
173 if [ "$PMS_VERSION" == "V2" ]; then
174 api_equal json:policy-types 3 300
176 api_equal json:policy_types 2 300
179 echo "Check the number of types in the agent for each ric is 1"
180 for ((i=1; i<=$NUM_RICS; i++))
182 if [ "$PMS_VERSION" == "V2" ]; then
183 api_equal json:policy-types?ric_id=ricsim_g1_$i 1 120
184 api_equal json:policy-types?ric_id=ricsim_g3_$i 1 120
186 api_equal json:policy_types?ric=ricsim_g1_$i 1 120
190 echo "Register a service"
191 api_put_service 201 "serv1" 0 "$CR_SERVICE_APP_PATH_0/1"
193 TEST_DURATION=$((24*3600*$DAYS))
196 AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
200 if [ "$PMS_VERSION" == "V2" ]; then
201 notificationurl=$CR_SERVICE_APP_PATH_0"/test"
206 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
209 echo "#########################################################################################################"
210 echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
211 echo "#########################################################################################################"
214 for interface in $AGENT_INTERFACES ; do
216 echo "############################################"
217 echo "## Testing using agent interface: $interface ##"
218 echo "############################################"
220 if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
221 if [ $HTTPX == "HTTP" ]; then
227 if [ $HTTPX == "HTTPS" ]; then
228 echo "Using secure ports towards dmaap"
229 use_agent_dmaap_https
231 echo "Using non-secure ports towards dmaap"
236 echo "Create $NUM_INSTANCES instances in each OSC RIC"
239 if [ $interface == "REST_PARALLEL" ]; then
240 api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES 3
242 for ((i=1; i<=$NUM_RICS; i++))
244 if [ $interface == "DMAAP-BATCH" ]; then
245 api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
246 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
247 api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
249 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
250 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
252 sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
253 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
254 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
257 if [ "$PMS_VERSION" == "V2" ]; then
258 api_equal json:policy-instances $INSTANCES
260 api_equal json:policy_ids $INSTANCES
263 echo "Create $NUM_INSTANCES instances in each STD RIC"
264 if [ $interface == "REST_PARALLEL" ]; then
265 api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES 3
267 for ((i=1; i<=$NUM_RICS; i++))
269 if [ $interface == "DMAAP-BATCH" ]; then
270 api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
271 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
272 api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
274 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
275 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
277 sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
278 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
279 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
282 if [ "$PMS_VERSION" == "V2" ]; then
283 api_equal json:policy-instances $INSTANCES
285 api_equal json:policy_ids $INSTANCES
288 if [ "$PMS_VERSION" == "V2" ]; then
289 echo "Create $NUM_INSTANCES instances in each STD 2 RIC"
290 if [ $interface == "REST_PARALLEL" ]; then
291 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
293 for ((i=1; i<=$NUM_RICS; i++))
295 if [ $interface == "DMAAP-BATCH" ]; then
296 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
297 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
298 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
300 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
301 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
303 sim_equal ricsim_g3_$i num_instances $NUM_INSTANCES
304 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
305 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
308 if [ "$PMS_VERSION" == "V2" ]; then
309 api_equal json:policy-instances $INSTANCES
311 api_equal json:policy_ids $INSTANCES
316 echo "Delete all instances in each OSC RIC"
319 if [ $interface == "REST_PARALLEL" ]; then
320 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
322 for ((i=1; i<=$NUM_RICS; i++))
324 if [ $interface == "DMAAP-BATCH" ]; then
325 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
326 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
327 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
329 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
330 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
332 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
333 sim_equal ricsim_g1_$i num_instances 0
334 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
337 if [ "$PMS_VERSION" == "V2" ]; then
338 api_equal json:policy-instances $INSTANCES
340 api_equal json:policy_ids $INSTANCES
343 echo "Delete all instances in each STD RIC"
345 if [ $interface == "REST_PARALLEL" ]; then
346 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
348 for ((i=1; i<=$NUM_RICS; i++))
350 if [ $interface == "DMAAP-BATCH" ]; then
351 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
352 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
353 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
355 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
356 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
358 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
359 sim_equal ricsim_g2_$i num_instances 0
360 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
363 if [ "$PMS_VERSION" == "V2" ]; then
364 api_equal json:policy-instances $INSTANCES
366 api_equal json:policy_ids $INSTANCES
369 if [ "$PMS_VERSION" == "V2" ]; then
370 echo "Delete all instances in each STD 2 RIC"
372 if [ $interface == "REST_PARALLEL" ]; then
373 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
375 for ((i=1; i<=$NUM_RICS; i++))
377 if [ $interface == "DMAAP-BATCH" ]; then
378 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
379 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
380 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
382 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
383 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
385 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
386 sim_equal ricsim_g3_$i num_instances 0
387 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
390 if [ "$PMS_VERSION" == "V2" ]; then
391 api_equal json:policy-instances $INSTANCES
393 api_equal json:policy_ids $INSTANCES
397 mr_equal requests_submitted $MR_MESSAGES
398 mr_equal requests_fetched $MR_MESSAGES
399 mr_equal responses_submitted $MR_MESSAGES
400 mr_equal responses_fetched $MR_MESSAGES
401 mr_equal current_requests 0
402 mr_equal current_responses 0
405 for ((i=1; i<=$NUM_RICS; i++))
407 sim_contains_str ricsim_g1_$i remote_hosts $SDNC_APP_NAME
408 sim_contains_str ricsim_g2_$i remote_hosts $SDNC_APP_NAME
410 if [ "$PMS_VERSION" == "V2" ]; then
411 sim_contains_str ricsim_g3_$i remote_hosts $SDNC_APP_NAME
419 check_policy_agent_logs
422 #### TEST COMPLETE ####
428 auto_clean_environment