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 exclude checking pulling images for, space separated list
23 EXCLUDED_IMAGES="SDNC_ONAP"
25 . ../common/testcase_common.sh $@
26 . ../common/agent_api_functions.sh
27 . ../common/ricsimulator_api_functions.sh
33 #Local vars in test script
34 ##########################
35 # Path to callback receiver
36 CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
37 # Number of RICs per interface type (OSC and STD)
39 # Number of policy instances per RIC
46 # use http or https for all apis
49 if [ $HTTPX == "http" ]; then
59 start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
61 start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
69 prepare_consul_config SDNC ".consul_config.json"
70 consul_config_app ".consul_config.json"
81 echo "Print the interface for group 1 simulators, shall be OSC"
82 for ((i=1; i<=$NUM_RICS; i++))
84 sim_print ricsim_g1_$i interface
87 echo "Print the interface for group 2 simulators, shall be STD"
88 for ((i=1; i<=$NUM_RICS; i++))
90 sim_print ricsim_g2_$i interface
93 echo "Load policy type in group 1 simulators"
94 for ((i=1; i<=$NUM_RICS; i++))
96 sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
99 echo "Check the number of instances in group 1 simulators, shall be 0"
100 for ((i=1; i<=$NUM_RICS; i++))
102 sim_equal ricsim_g1_$i num_instances 0
105 echo "Check the number of instances in group 2 simulators, shall be 0"
106 for ((i=1; i<=$NUM_RICS; i++))
108 sim_equal ricsim_g2_$i num_instances 0
111 echo "Wait for the agent to refresh types from the simulator"
112 api_equal json:policy_types 2 120
114 echo "Check the number of types in the agent for each ric is 1"
115 for ((i=1; i<=$NUM_RICS; i++))
117 api_equal json:policy_types?ric=ricsim_g1_$i 1 120
120 echo "Register a service"
121 api_put_service 201 "serv1" 0 "$CR_PATH/1"
123 TEST_DURATION=$((24*3600*$DAYS))
126 AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
130 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
133 echo "#########################################################################################################"
134 echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
135 echo "#########################################################################################################"
138 for interface in $AGENT_INTERFACES ; do
140 echo "############################################"
141 echo "## Testing using agent interface: $interface ##"
142 echo "############################################"
144 if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
145 if [ $HTTPX == "http" ]; then
154 echo "Create $NUM_INSTANCES instances in each OSC RIC"
157 if [ $interface == "REST_PARALLEL" ]; then
158 api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES 3
160 for ((i=1; i<=$NUM_RICS; i++))
162 if [ $interface == "DMAAP-BATCH" ]; then
163 api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES
164 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
165 api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES
167 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
168 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
170 sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
171 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
172 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
175 api_equal json:policy_ids $INSTANCES
177 echo "Create $NUM_INSTANCES instances in each STD RIC"
178 if [ $interface == "REST_PARALLEL" ]; then
179 api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES 3
181 for ((i=1; i<=$NUM_RICS; i++))
183 if [ $interface == "DMAAP-BATCH" ]; then
184 api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES
185 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
186 api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES
188 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
189 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
191 sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
192 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
193 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
196 api_equal json:policy_ids $INSTANCES
199 echo "Delete all instances in each OSC RIC"
202 if [ $interface == "REST_PARALLEL" ]; then
203 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
205 for ((i=1; i<=$NUM_RICS; i++))
207 if [ $interface == "DMAAP-BATCH" ]; then
208 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
209 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
210 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
212 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
213 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
215 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
216 sim_equal ricsim_g1_$i num_instances 0
217 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
220 api_equal json:policy_ids $INSTANCES
222 echo "Delete all instances in each STD RIC"
224 if [ $interface == "REST_PARALLEL" ]; then
225 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
227 for ((i=1; i<=$NUM_RICS; i++))
229 if [ $interface == "DMAAP-BATCH" ]; then
230 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
231 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
232 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
234 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
235 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
237 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
238 sim_equal ricsim_g2_$i num_instances 0
239 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
242 api_equal json:policy_ids 0
244 cr_equal received_callbacks 0
246 mr_equal requests_submitted $MR_MESSAGES
247 mr_equal requests_fetched $MR_MESSAGES
248 mr_equal responses_submitted $MR_MESSAGES
249 mr_equal responses_fetched $MR_MESSAGES
250 mr_equal current_requests 0
251 mr_equal current_responses 0
254 for ((i=1; i<=$NUM_RICS; i++))
256 sim_contains_str ricsim_g1_$i remote_hosts "a1-controller"
257 sim_contains_str ricsim_g2_$i remote_hosts "a1-controller"
264 check_policy_agent_logs
266 #### TEST COMPLETE ####
272 auto_clean_containers