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
31 #Local vars in test script
32 ##########################
33 # Path to callback receiver
34 CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
35 # Number of RICs per interface type (OSC and STD)
37 # Number of policy instances per RIC
44 # use http or https for all apis
47 if [ $HTTPX == "http" ]; then
57 start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
59 start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
67 prepare_consul_config SDNC ".consul_config.json"
68 consul_config_app ".consul_config.json"
79 echo "Print the interface for group 1 simulators, shall be OSC"
80 for ((i=1; i<=$NUM_RICS; i++))
82 sim_print ricsim_g1_$i interface
85 echo "Print the interface for group 2 simulators, shall be STD"
86 for ((i=1; i<=$NUM_RICS; i++))
88 sim_print ricsim_g2_$i interface
91 echo "Load policy type in group 1 simulators"
92 for ((i=1; i<=$NUM_RICS; i++))
94 sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
97 echo "Check the number of instances in group 1 simulators, shall be 0"
98 for ((i=1; i<=$NUM_RICS; i++))
100 sim_equal ricsim_g1_$i num_instances 0
103 echo "Check the number of instances in group 2 simulators, shall be 0"
104 for ((i=1; i<=$NUM_RICS; i++))
106 sim_equal ricsim_g2_$i num_instances 0
109 echo "Wait for the agent to refresh types from the simulator"
110 api_equal json:policy_types 2 120
112 echo "Check the number of types in the agent for each ric is 1"
113 for ((i=1; i<=$NUM_RICS; i++))
115 api_equal json:policy_types?ric=ricsim_g1_$i 1 120
118 echo "Register a service"
119 api_put_service 201 "serv1" 0 "$CR_PATH/1"
121 TEST_DURATION=$((24*3600*$DAYS))
124 AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
128 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
131 echo "#########################################################################################################"
132 echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
133 echo "#########################################################################################################"
136 for interface in $AGENT_INTERFACES ; do
138 echo "############################################"
139 echo "## Testing using agent interface: $interface ##"
140 echo "############################################"
142 if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
143 if [ $HTTPX == "http" ]; then
152 echo "Create $NUM_INSTANCES instances in each OSC RIC"
155 if [ $interface == "REST_PARALLEL" ]; then
156 api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES 3
158 for ((i=1; i<=$NUM_RICS; i++))
160 if [ $interface == "DMAAP-BATCH" ]; then
161 api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES
162 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
163 api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES
165 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
166 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
168 sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
169 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
170 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
173 api_equal json:policy_ids $INSTANCES
175 echo "Create $NUM_INSTANCES instances in each STD RIC"
176 if [ $interface == "REST_PARALLEL" ]; then
177 api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES 3
179 for ((i=1; i<=$NUM_RICS; i++))
181 if [ $interface == "DMAAP-BATCH" ]; then
182 api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES
183 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
184 api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES
186 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
187 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
189 sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
190 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
191 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
194 api_equal json:policy_ids $INSTANCES
197 echo "Delete all instances in each OSC RIC"
200 if [ $interface == "REST_PARALLEL" ]; then
201 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
203 for ((i=1; i<=$NUM_RICS; i++))
205 if [ $interface == "DMAAP-BATCH" ]; then
206 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
207 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
208 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
210 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
211 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
213 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
214 sim_equal ricsim_g1_$i num_instances 0
215 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
218 api_equal json:policy_ids $INSTANCES
220 echo "Delete all instances in each STD RIC"
222 if [ $interface == "REST_PARALLEL" ]; then
223 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
225 for ((i=1; i<=$NUM_RICS; i++))
227 if [ $interface == "DMAAP-BATCH" ]; then
228 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
229 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
230 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
232 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
233 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
235 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
236 sim_equal ricsim_g2_$i num_instances 0
237 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
240 api_equal json:policy_ids 0
242 cr_equal received_callbacks 0
244 mr_equal requests_submitted $MR_MESSAGES
245 mr_equal requests_fetched $MR_MESSAGES
246 mr_equal responses_submitted $MR_MESSAGES
247 mr_equal responses_fetched $MR_MESSAGES
248 mr_equal current_requests 0
249 mr_equal current_responses 0
252 for ((i=1; i<=$NUM_RICS; i++))
254 sim_contains_str ricsim_g1_$i remote_hosts "a1-controller"
255 sim_contains_str ricsim_g2_$i remote_hosts "a1-controller"
262 check_policy_agent_logs
264 #### TEST COMPLETE ####
270 auto_clean_containers