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 10000 policies in each RICs for 24h. Via agent REST"
22 . ../common/testcase_common.sh $@
23 . ../common/agent_api_functions.sh
24 . ../common/ricsimulator_api_functions.sh
28 #Local vars in test script
29 ##########################
30 # Path to callback receiver
31 CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
32 # Number of RICs per interface type (OSC and STD)
34 # Number of policy instances per RIC
39 start_ric_simulators ricsim_g1 4 OSC_2.1.0
41 start_ric_simulators ricsim_g2 4 STD_1.1.3
49 prepare_consul_config NOSDNC ".consul_config.json"
50 consul_config_app ".consul_config.json"
60 echo "Print the interface for group 1 simulators, shall be OSC"
61 for ((i=1; i<=$NUM_RICS; i++))
63 sim_print ricsim_g1_$i interface
66 echo "Print the interface for group 2 simulators, shall be STD"
67 for ((i=1; i<=$NUM_RICS; i++))
69 sim_print ricsim_g2_$i interface
72 echo "Load policy type in group 1 simulators"
73 for ((i=1; i<=$NUM_RICS; i++))
75 sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
78 echo "Check the number of instances in group 1 simulators, shall be 0"
79 for ((i=1; i<=$NUM_RICS; i++))
81 sim_equal ricsim_g1_$i num_instances 0
84 echo "Check the number of instances in group 2 simulators, shall be 0"
85 for ((i=1; i<=$NUM_RICS; i++))
87 sim_equal ricsim_g2_$i num_instances 0
90 echo "Wait for the agent to refresh types from the simulator"
91 api_equal json:policy_types 2 120
93 echo "Check the number of types in the agent for each ric is 1"
94 for ((i=1; i<=$NUM_RICS; i++))
96 api_equal json:policy_types?ric=ricsim_g1_$i 1 120
99 echo "Register a service"
100 api_put_service 201 "rapp1" 0 "$CR_PATH/1"
102 TEST_DURATION=$((24*3600))
105 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
108 echo "#########################################################################################################"
109 echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds (24h)."$EBOLD
110 echo "#########################################################################################################"
114 echo "Create 10000 instances in each OSC RIC"
117 for ((i=1; i<=$NUM_RICS; i++))
119 api_put_policy 201 "rapp1" ricsim_g1_$i 1 $INSTANCE_ID testdata/OSC/pi1_template.json $NUM_INSTANCES
120 sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
121 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
122 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
125 api_equal json:policy_ids $INSTANCES
127 echo "Create 10000 instances in each OSC RIC"
128 for ((i=1; i<=$NUM_RICS; i++))
130 api_put_policy 201 "rapp1" ricsim_g2_$i NOTYPE $INSTANCE_ID testdata/STD/pi1_template.json $NUM_INSTANCES
131 sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
132 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
133 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
136 api_equal json:policy_ids $INSTANCES
139 echo "Delete all instances in each OSC RIC"
142 for ((i=1; i<=$NUM_RICS; i++))
144 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
145 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
146 sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
147 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
150 api_equal json:policy_ids $INSTANCES
152 echo "Delete all instances in each STD RIC"
154 for ((i=1; i<=$NUM_RICS; i++))
156 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
157 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
158 sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
159 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
162 api_equal json:policy_ids 0
166 check_policy_agent_logs
168 #### TEST COMPLETE ####