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, space separated list
23 INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
25 #SUPPORTED TEST ENV FILE
26 SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY"
28 . ../common/testcase_common.sh $@
29 . ../common/agent_api_functions.sh
30 . ../common/ricsimulator_api_functions.sh
31 . ../common/cr_api_functions.sh
37 #Local vars in test script
38 ##########################
40 # Number of RICs per interface type (OSC and STD)
42 if [ "$PMS_VERSION" == "V2" ]; then
43 NUM_RICS=20 # 3 A1 interfaces test, less sims per interface. total sims will be same
46 # Number of policy instances per RIC
53 # use HTTP or HTTPS for all apis
56 if [ $HTTPX == "HTTP" ]; then
68 start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
70 start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
72 if [ "$PMS_VERSION" == "V2" ]; then
73 start_ric_simulators ricsim_g3 $NUM_RICS STD_2.0.0
82 prepare_consul_config SDNC ".consul_config.json"
83 consul_config_app ".consul_config.json"
94 echo "Print the interface for group 1 simulators, shall be OSC"
95 for ((i=1; i<=$NUM_RICS; i++))
97 sim_print ricsim_g1_$i interface
100 echo "Print the interface for group 2 simulators, shall be STD"
101 for ((i=1; i<=$NUM_RICS; i++))
103 sim_print ricsim_g2_$i interface
106 if [ "$PMS_VERSION" == "V2" ]; then
107 echo "Print the interface for group 2 simulators, shall be STD 2"
108 for ((i=1; i<=$NUM_RICS; i++))
110 sim_print ricsim_g3_$i interface
114 echo "Load policy type in group 1 simulators"
115 for ((i=1; i<=$NUM_RICS; i++))
117 sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
120 if [ "$PMS_VERSION" == "V2" ]; then
121 echo "Load policy type in group 3 simulators"
122 for ((i=1; i<=$NUM_RICS; i++))
124 sim_put_policy_type 201 ricsim_g3_$i STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
128 echo "Check the number of instances in group 1 simulators, shall be 0"
129 for ((i=1; i<=$NUM_RICS; i++))
131 sim_equal ricsim_g1_$i num_instances 0
134 echo "Check the number of instances in group 2 simulators, shall be 0"
135 for ((i=1; i<=$NUM_RICS; i++))
137 sim_equal ricsim_g2_$i num_instances 0
140 if [ "$PMS_VERSION" == "V2" ]; then
141 echo "Check the number of instances in group 3 simulators, shall be 0"
142 for ((i=1; i<=$NUM_RICS; i++))
144 sim_equal ricsim_g3_$i num_instances 0
148 echo "Wait for the agent to refresh types from the simulator"
149 if [ "$PMS_VERSION" == "V2" ]; then
150 api_equal json:policy-types 3 120
152 api_equal json:policy_types 2 120
155 echo "Check the number of types in the agent for each ric is 1"
156 for ((i=1; i<=$NUM_RICS; i++))
158 if [ "$PMS_VERSION" == "V2" ]; then
159 api_equal json:policy-types?ric_id=ricsim_g1_$i 1 120
160 api_equal json:policy-types?ric_id=ricsim_g3_$i 1 120
162 api_equal json:policy_types?ric=ricsim_g1_$i 1 120
166 echo "Register a service"
167 api_put_service 201 "serv1" 0 "$CR_PATH/1"
169 TEST_DURATION=$((24*3600*$DAYS))
172 AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
176 if [ "$PMS_VERSION" == "V2" ]; then
177 notificationurl=$CR_PATH"/test"
182 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
185 echo "#########################################################################################################"
186 echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
187 echo "#########################################################################################################"
190 for interface in $AGENT_INTERFACES ; do
192 echo "############################################"
193 echo "## Testing using agent interface: $interface ##"
194 echo "############################################"
196 if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
197 if [ $HTTPX == "HTTP" ]; then
203 if [ $HTTPX == "HTTPS" ]; then
204 echo "Using secure ports towards dmaap"
205 use_agent_dmaap_https
207 echo "Using non-secure ports towards dmaap"
212 echo "Create $NUM_INSTANCES instances in each OSC RIC"
215 if [ $interface == "REST_PARALLEL" ]; then
216 api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES 3
218 for ((i=1; i<=$NUM_RICS; i++))
220 if [ $interface == "DMAAP-BATCH" ]; then
221 api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
222 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
223 api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
225 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
226 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
228 sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
229 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
230 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
233 if [ "$PMS_VERSION" == "V2" ]; then
234 api_equal json:policy-instances $INSTANCES
236 api_equal json:policy_ids $INSTANCES
239 echo "Create $NUM_INSTANCES instances in each STD RIC"
240 if [ $interface == "REST_PARALLEL" ]; then
241 api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES 3
243 for ((i=1; i<=$NUM_RICS; i++))
245 if [ $interface == "DMAAP-BATCH" ]; then
246 api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
247 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
248 api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
250 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
251 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
253 sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
254 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
255 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
258 if [ "$PMS_VERSION" == "V2" ]; then
259 api_equal json:policy-instances $INSTANCES
261 api_equal json:policy_ids $INSTANCES
264 if [ "$PMS_VERSION" == "V2" ]; then
265 echo "Create $NUM_INSTANCES instances in each STD 2 RIC"
266 if [ $interface == "REST_PARALLEL" ]; then
267 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
269 for ((i=1; i<=$NUM_RICS; i++))
271 if [ $interface == "DMAAP-BATCH" ]; then
272 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
273 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
274 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
276 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
277 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
279 sim_equal ricsim_g3_$i num_instances $NUM_INSTANCES
280 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
281 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
284 if [ "$PMS_VERSION" == "V2" ]; then
285 api_equal json:policy-instances $INSTANCES
287 api_equal json:policy_ids $INSTANCES
292 echo "Delete all instances in each OSC RIC"
295 if [ $interface == "REST_PARALLEL" ]; then
296 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
298 for ((i=1; i<=$NUM_RICS; i++))
300 if [ $interface == "DMAAP-BATCH" ]; then
301 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
302 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
303 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
305 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
306 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
308 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
309 sim_equal ricsim_g1_$i num_instances 0
310 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
313 if [ "$PMS_VERSION" == "V2" ]; then
314 api_equal json:policy-instances $INSTANCES
316 api_equal json:policy_ids $INSTANCES
319 echo "Delete all instances in each STD RIC"
321 if [ $interface == "REST_PARALLEL" ]; then
322 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
324 for ((i=1; i<=$NUM_RICS; i++))
326 if [ $interface == "DMAAP-BATCH" ]; then
327 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
328 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
329 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
331 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
332 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
334 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
335 sim_equal ricsim_g2_$i num_instances 0
336 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
339 if [ "$PMS_VERSION" == "V2" ]; then
340 api_equal json:policy-instances $INSTANCES
342 api_equal json:policy_ids $INSTANCES
345 if [ "$PMS_VERSION" == "V2" ]; then
346 echo "Delete all instances in each STD 2 RIC"
348 if [ $interface == "REST_PARALLEL" ]; then
349 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
351 for ((i=1; i<=$NUM_RICS; i++))
353 if [ $interface == "DMAAP-BATCH" ]; then
354 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
355 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
356 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
358 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
359 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
361 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
362 sim_equal ricsim_g3_$i num_instances 0
363 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
366 if [ "$PMS_VERSION" == "V2" ]; then
367 api_equal json:policy-instances $INSTANCES
369 api_equal json:policy_ids $INSTANCES
373 mr_equal requests_submitted $MR_MESSAGES
374 mr_equal requests_fetched $MR_MESSAGES
375 mr_equal responses_submitted $MR_MESSAGES
376 mr_equal responses_fetched $MR_MESSAGES
377 mr_equal current_requests 0
378 mr_equal current_responses 0
381 for ((i=1; i<=$NUM_RICS; i++))
383 sim_contains_str ricsim_g1_$i remote_hosts "a1-controller"
384 sim_contains_str ricsim_g2_$i remote_hosts "a1-controller"
386 if [ "$PMS_VERSION" == "V2" ]; then
387 sim_contains_str ricsim_g3_$i remote_hosts "a1-controller"
395 check_policy_agent_logs
398 #### TEST COMPLETE ####
404 auto_clean_containers