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 . ../common/testcase_common.sh $@
26 . ../common/agent_api_functions.sh
27 . ../common/ricsimulator_api_functions.sh
33 #Local vars in test script
34 ##########################
36 # Number of RICs per interface type (OSC and STD)
38 # Number of policy instances per RIC
45 # use HTTP or HTTPS for all apis
48 if [ $HTTPX == "HTTP" ]; then
49 # Path to callback receiver
50 CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
56 # Path to callback receiver
57 CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
64 start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
66 start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
74 prepare_consul_config SDNC ".consul_config.json"
75 consul_config_app ".consul_config.json"
86 echo "Print the interface for group 1 simulators, shall be OSC"
87 for ((i=1; i<=$NUM_RICS; i++))
89 sim_print ricsim_g1_$i interface
92 echo "Print the interface for group 2 simulators, shall be STD"
93 for ((i=1; i<=$NUM_RICS; i++))
95 sim_print ricsim_g2_$i interface
98 echo "Load policy type in group 1 simulators"
99 for ((i=1; i<=$NUM_RICS; i++))
101 sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
104 echo "Check the number of instances in group 1 simulators, shall be 0"
105 for ((i=1; i<=$NUM_RICS; i++))
107 sim_equal ricsim_g1_$i num_instances 0
110 echo "Check the number of instances in group 2 simulators, shall be 0"
111 for ((i=1; i<=$NUM_RICS; i++))
113 sim_equal ricsim_g2_$i num_instances 0
116 echo "Wait for the agent to refresh types from the simulator"
117 if [ "$PMS_VERSION" == "V2" ]; then
118 api_equal json:policy-types 2 120
120 api_equal json:policy_types 2 120
123 echo "Check the number of types in the agent for each ric is 1"
124 for ((i=1; i<=$NUM_RICS; i++))
126 if [ "$PMS_VERSION" == "V2" ]; then
127 api_equal json:policy-types?ric_id=ricsim_g1_$i 1 120
129 api_equal json:policy_types?ric=ricsim_g1_$i 1 120
133 echo "Register a service"
134 api_put_service 201 "serv1" 0 "$CR_PATH/1"
136 TEST_DURATION=$((24*3600*$DAYS))
139 AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
143 if [ "$PMS_VERSION" == "V2" ]; then
144 notificationurl="http://localhost:80"
149 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
152 echo "#########################################################################################################"
153 echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
154 echo "#########################################################################################################"
157 for interface in $AGENT_INTERFACES ; do
159 echo "############################################"
160 echo "## Testing using agent interface: $interface ##"
161 echo "############################################"
163 if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
164 if [ $HTTPX == "HTTP" ]; then
170 if [ $HTTPX == "HTTPS" ]; then
171 echo "Using secure ports towards dmaap"
172 use_agent_dmaap_https
174 echo "Using non-secure ports towards dmaap"
179 echo "Create $NUM_INSTANCES instances in each OSC RIC"
182 if [ $interface == "REST_PARALLEL" ]; then
183 api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES 3
185 for ((i=1; i<=$NUM_RICS; i++))
187 if [ $interface == "DMAAP-BATCH" ]; then
188 api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
189 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
190 api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
192 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
193 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
195 sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
196 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
197 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
200 if [ "$PMS_VERSION" == "V2" ]; then
201 api_equal json:policy_instances $INSTANCES
203 api_equal json:policy_ids $INSTANCES
206 echo "Create $NUM_INSTANCES instances in each STD RIC"
207 if [ $interface == "REST_PARALLEL" ]; then
208 api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES 3
210 for ((i=1; i<=$NUM_RICS; i++))
212 if [ $interface == "DMAAP-BATCH" ]; then
213 api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
214 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
215 api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
217 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
218 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
220 sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
221 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
222 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
225 if [ "$PMS_VERSION" == "V2" ]; then
226 api_equal json:policy_instances $INSTANCES
228 api_equal json:policy_ids $INSTANCES
232 echo "Delete all instances in each OSC RIC"
235 if [ $interface == "REST_PARALLEL" ]; then
236 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
238 for ((i=1; i<=$NUM_RICS; i++))
240 if [ $interface == "DMAAP-BATCH" ]; then
241 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
242 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
243 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
245 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
246 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
248 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
249 sim_equal ricsim_g1_$i num_instances 0
250 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
253 if [ "$PMS_VERSION" == "V2" ]; then
254 api_equal json:policy_instances $INSTANCES
256 api_equal json:policy_ids $INSTANCES
259 echo "Delete all instances in each STD RIC"
261 if [ $interface == "REST_PARALLEL" ]; then
262 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
264 for ((i=1; i<=$NUM_RICS; i++))
266 if [ $interface == "DMAAP-BATCH" ]; then
267 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
268 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
269 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
271 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
272 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
274 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
275 sim_equal ricsim_g2_$i num_instances 0
276 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
279 if [ "$PMS_VERSION" == "V2" ]; then
280 api_equal json:policy_instances $INSTANCES
282 api_equal json:policy_ids $INSTANCES
285 cr_equal received_callbacks 0
287 mr_equal requests_submitted $MR_MESSAGES
288 mr_equal requests_fetched $MR_MESSAGES
289 mr_equal responses_submitted $MR_MESSAGES
290 mr_equal responses_fetched $MR_MESSAGES
291 mr_equal current_requests 0
292 mr_equal current_responses 0
295 for ((i=1; i<=$NUM_RICS; i++))
297 sim_contains_str ricsim_g1_$i remote_hosts "a1-controller"
298 sim_contains_str ricsim_g2_$i remote_hosts "a1-controller"
305 check_policy_agent_logs
307 #### TEST COMPLETE ####
313 auto_clean_containers