blob: 460fb8ee0319e77c091f530166cb414aa05834f0 [file] [log] [blame]
BjornMagnussonXA70e878f2020-05-11 14:11:30 +02001#!/bin/bash
2
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
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
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=================================================
18#
19
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020020TC_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"
21
22#App names to exclude checking pulling images for, space separated list
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020023EXCLUDED_IMAGES="ECS"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020024
25. ../common/testcase_common.sh $@
26. ../common/agent_api_functions.sh
27. ../common/ricsimulator_api_functions.sh
28
29#### TEST BEGIN ####
30
BjornMagnussonXAad047782020-06-08 15:54:11 +020031generate_uuid
32
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020033#Local vars in test script
34##########################
BjornMagnussonXA496156d2020-08-10 14:16:24 +020035
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020036# Number of RICs per interface type (OSC and STD)
37NUM_RICS=30
38# Number of policy instances per RIC
39NUM_INSTANCES=5
40
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020041DAYS=3
42
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020043clean_containers
44
BjornMagnussonXA496156d2020-08-10 14:16:24 +020045# use HTTP or HTTPS for all apis
46HTTPX=HTTPS
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020047
BjornMagnussonXA496156d2020-08-10 14:16:24 +020048if [ $HTTPX == "HTTP" ]; then
49 # Path to callback receiver
50 CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
51 use_cr_http
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020052 use_agent_rest_http
53 use_sdnc_http
54 use_simulator_http
55else
BjornMagnussonXA496156d2020-08-10 14:16:24 +020056 # Path to callback receiver
57 CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
58 use_cr_https
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020059 use_agent_rest_https
60 use_sdnc_https
61 use_simulator_https
62fi
63
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020064start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
65
66start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
67
68start_mr
69
70start_cr
71
72start_consul_cbs
73
74prepare_consul_config SDNC ".consul_config.json"
75consul_config_app ".consul_config.json"
76
77start_sdnc
78
79start_control_panel
80
81start_policy_agent
82
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020083
84api_get_status 200
85
86echo "Print the interface for group 1 simulators, shall be OSC"
87for ((i=1; i<=$NUM_RICS; i++))
88do
89 sim_print ricsim_g1_$i interface
90done
91
92echo "Print the interface for group 2 simulators, shall be STD"
93for ((i=1; i<=$NUM_RICS; i++))
94do
95 sim_print ricsim_g2_$i interface
96done
97
98echo "Load policy type in group 1 simulators"
99for ((i=1; i<=$NUM_RICS; i++))
100do
101 sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
102done
103
104echo "Check the number of instances in group 1 simulators, shall be 0"
105for ((i=1; i<=$NUM_RICS; i++))
106do
107 sim_equal ricsim_g1_$i num_instances 0
108done
109
110echo "Check the number of instances in group 2 simulators, shall be 0"
111for ((i=1; i<=$NUM_RICS; i++))
112do
113 sim_equal ricsim_g2_$i num_instances 0
114done
115
116echo "Wait for the agent to refresh types from the simulator"
117api_equal json:policy_types 2 120
118
119echo "Check the number of types in the agent for each ric is 1"
120for ((i=1; i<=$NUM_RICS; i++))
121do
122 api_equal json:policy_types?ric=ricsim_g1_$i 1 120
123done
124
125echo "Register a service"
126api_put_service 201 "serv1" 0 "$CR_PATH/1"
127
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200128TEST_DURATION=$((24*3600*$DAYS))
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200129TEST_START=$SECONDS
130
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200131AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200132
133MR_MESSAGES=0
134
135while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
136
137 echo ""
138 echo "#########################################################################################################"
139 echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
140 echo "#########################################################################################################"
141 echo ""
142
143 for interface in $AGENT_INTERFACES ; do
144
145 echo "############################################"
146 echo "## Testing using agent interface: $interface ##"
147 echo "############################################"
148
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200149 if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200150 if [ $HTTPX == "HTTP" ]; then
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200151 use_agent_rest_http
152 else
153 use_agent_rest_https
154 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200155 else
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200156 if [ $HTTPX == "HTTPS" ]; then
157 echo "Using secure ports towards dmaap"
158 use_agent_dmaap_https
159 else
160 echo "Using non-secure ports towards dmaap"
161 use_agent_dmaap_http
162 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200163 fi
164
165 echo "Create $NUM_INSTANCES instances in each OSC RIC"
166 INSTANCE_ID=200000
167 INSTANCES=0
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200168 if [ $interface == "REST_PARALLEL" ]; then
169 api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES 3
170 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200171 for ((i=1; i<=$NUM_RICS; i++))
172 do
173 if [ $interface == "DMAAP-BATCH" ]; then
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200174 api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES
175 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
176 api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200177 fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200178 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200179 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
180 fi
181 sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
182 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
183 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
184 done
185
186 api_equal json:policy_ids $INSTANCES
187
188 echo "Create $NUM_INSTANCES instances in each STD RIC"
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200189 if [ $interface == "REST_PARALLEL" ]; then
190 api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES 3
191 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200192 for ((i=1; i<=$NUM_RICS; i++))
193 do
194 if [ $interface == "DMAAP-BATCH" ]; then
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200195 api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES
196 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
197 api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200198 fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200199 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200200 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
201 fi
202 sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
203 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
204 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
205 done
206
207 api_equal json:policy_ids $INSTANCES
208
209
210 echo "Delete all instances in each OSC RIC"
211
212 INSTANCE_ID=200000
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200213 if [ $interface == "REST_PARALLEL" ]; then
214 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
215 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200216 for ((i=1; i<=$NUM_RICS; i++))
217 do
218 if [ $interface == "DMAAP-BATCH" ]; then
219 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200220 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200221 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
222 fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200223 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200224 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
225 fi
226 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
227 sim_equal ricsim_g1_$i num_instances 0
228 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
229 done
230
231 api_equal json:policy_ids $INSTANCES
232
233 echo "Delete all instances in each STD RIC"
234
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200235 if [ $interface == "REST_PARALLEL" ]; then
236 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
237 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200238 for ((i=1; i<=$NUM_RICS; i++))
239 do
240 if [ $interface == "DMAAP-BATCH" ]; then
241 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200242 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200243 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
244 fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200245 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200246 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
247 fi
248 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
249 sim_equal ricsim_g2_$i num_instances 0
250 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
251 done
252
253 api_equal json:policy_ids 0
254
255 cr_equal received_callbacks 0
256
257 mr_equal requests_submitted $MR_MESSAGES
258 mr_equal requests_fetched $MR_MESSAGES
259 mr_equal responses_submitted $MR_MESSAGES
260 mr_equal responses_fetched $MR_MESSAGES
261 mr_equal current_requests 0
262 mr_equal current_responses 0
263
264
265 for ((i=1; i<=$NUM_RICS; i++))
266 do
267 sim_contains_str ricsim_g1_$i remote_hosts "a1-controller"
268 sim_contains_str ricsim_g2_$i remote_hosts "a1-controller"
269 done
270
271 done
272
273done
274
275check_policy_agent_logs
276
277#### TEST COMPLETE ####
278
279store_logs END
280
281print_result
282
283auto_clean_containers