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. Via agent REST/DMAAP/DMAAP_BATCH and SDNC using http"
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 $NUM_RICS OSC_2.1.0
41 start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
49 prepare_consul_config SDNC ".consul_config.json"
50 consul_config_app ".consul_config.json"
62 echo "Print the interface for group 1 simulators, shall be OSC"
63 for ((i=1; i<=$NUM_RICS; i++))
65 sim_print ricsim_g1_$i interface
68 echo "Print the interface for group 2 simulators, shall be STD"
69 for ((i=1; i<=$NUM_RICS; i++))
71 sim_print ricsim_g2_$i interface
74 echo "Load policy type in group 1 simulators"
75 for ((i=1; i<=$NUM_RICS; i++))
77 sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
80 echo "Check the number of instances in group 1 simulators, shall be 0"
81 for ((i=1; i<=$NUM_RICS; i++))
83 sim_equal ricsim_g1_$i num_instances 0
86 echo "Check the number of instances in group 2 simulators, shall be 0"
87 for ((i=1; i<=$NUM_RICS; i++))
89 sim_equal ricsim_g2_$i num_instances 0
92 echo "Wait for the agent to refresh types from the simulator"
93 api_equal json:policy_types 2 120
95 echo "Check the number of types in the agent for each ric is 1"
96 for ((i=1; i<=$NUM_RICS; i++))
98 api_equal json:policy_types?ric=ricsim_g1_$i 1 120
101 echo "Register a service"
102 api_put_service 201 "serv1" 0 "$CR_PATH/1"
104 TEST_DURATION=$((24*3600))
107 AGENT_INTERFACES="REST DMAAP DMAAP-BATCH"
111 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
114 echo "#########################################################################################################"
115 echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
116 echo "#########################################################################################################"
119 for interface in $AGENT_INTERFACES ; do
121 echo "############################################"
122 echo "## Testing using agent interface: $interface ##"
123 echo "############################################"
125 if [ $interface == "REST" ]; then
131 echo "Create $NUM_INSTANCES instances in each OSC RIC"
134 for ((i=1; i<=$NUM_RICS; i++))
136 if [ $interface == "DMAAP-BATCH" ]; then
137 api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID testdata/OSC/pi1_template.json $NUM_INSTANCES
139 api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID testdata/OSC/pi1_template.json $NUM_INSTANCES
141 if [ $interface != "REST" ]; then
142 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
144 sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
145 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
146 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
149 api_equal json:policy_ids $INSTANCES
151 echo "Create $NUM_INSTANCES instances in each STD RIC"
152 for ((i=1; i<=$NUM_RICS; i++))
154 if [ $interface == "DMAAP-BATCH" ]; then
155 api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID testdata/STD/pi1_template.json $NUM_INSTANCES
157 api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID testdata/STD/pi1_template.json $NUM_INSTANCES
159 if [ $interface != "REST" ]; then
160 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
162 sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
163 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
164 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
167 api_equal json:policy_ids $INSTANCES
170 echo "Delete all instances in each OSC RIC"
173 for ((i=1; i<=$NUM_RICS; i++))
175 if [ $interface == "DMAAP-BATCH" ]; then
176 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
178 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
180 if [ $interface != "REST" ]; then
181 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
183 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
184 sim_equal ricsim_g1_$i num_instances 0
185 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
188 api_equal json:policy_ids $INSTANCES
190 echo "Delete all instances in each STD RIC"
192 for ((i=1; i<=$NUM_RICS; i++))
194 if [ $interface == "DMAAP-BATCH" ]; then
195 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
197 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
199 if [ $interface != "REST" ]; then
200 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
202 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
203 sim_equal ricsim_g2_$i num_instances 0
204 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
207 api_equal json:policy_ids 0
209 cr_equal received_callbacks 0
211 mr_equal requests_submitted $MR_MESSAGES
212 mr_equal requests_fetched $MR_MESSAGES
213 mr_equal responses_submitted $MR_MESSAGES
214 mr_equal responses_fetched $MR_MESSAGES
215 mr_equal current_requests 0
216 mr_equal current_responses 0
219 for ((i=1; i<=$NUM_RICS; i++))
221 sim_contains_str ricsim_g1_$i remote_hosts "a1-controller"
222 sim_contains_str ricsim_g2_$i remote_hosts "a1-controller"
229 check_policy_agent_logs
231 #### TEST COMPLETE ####
237 auto_clean_containers