blob: e9f19f8c867bff5a7ce0c3b1a6996e7075133404 [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
23EXCLUDED_IMAGES="SDNC_ONAP"
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##########################
35# Path to callback receiver
36CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
37# Number of RICs per interface type (OSC and STD)
38NUM_RICS=30
39# Number of policy instances per RIC
40NUM_INSTANCES=5
41
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020042DAYS=3
43
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020044clean_containers
45
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020046# use http or https for all apis
47HTTPX=https
48
49if [ $HTTPX == "http" ]; then
50 use_agent_rest_http
51 use_sdnc_http
52 use_simulator_http
53else
54 use_agent_rest_https
55 use_sdnc_https
56 use_simulator_https
57fi
58
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020059start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
60
61start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
62
63start_mr
64
65start_cr
66
67start_consul_cbs
68
69prepare_consul_config SDNC ".consul_config.json"
70consul_config_app ".consul_config.json"
71
72start_sdnc
73
74start_control_panel
75
76start_policy_agent
77
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020078
79api_get_status 200
80
81echo "Print the interface for group 1 simulators, shall be OSC"
82for ((i=1; i<=$NUM_RICS; i++))
83do
84 sim_print ricsim_g1_$i interface
85done
86
87echo "Print the interface for group 2 simulators, shall be STD"
88for ((i=1; i<=$NUM_RICS; i++))
89do
90 sim_print ricsim_g2_$i interface
91done
92
93echo "Load policy type in group 1 simulators"
94for ((i=1; i<=$NUM_RICS; i++))
95do
96 sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
97done
98
99echo "Check the number of instances in group 1 simulators, shall be 0"
100for ((i=1; i<=$NUM_RICS; i++))
101do
102 sim_equal ricsim_g1_$i num_instances 0
103done
104
105echo "Check the number of instances in group 2 simulators, shall be 0"
106for ((i=1; i<=$NUM_RICS; i++))
107do
108 sim_equal ricsim_g2_$i num_instances 0
109done
110
111echo "Wait for the agent to refresh types from the simulator"
112api_equal json:policy_types 2 120
113
114echo "Check the number of types in the agent for each ric is 1"
115for ((i=1; i<=$NUM_RICS; i++))
116do
117 api_equal json:policy_types?ric=ricsim_g1_$i 1 120
118done
119
120echo "Register a service"
121api_put_service 201 "serv1" 0 "$CR_PATH/1"
122
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200123TEST_DURATION=$((24*3600*$DAYS))
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200124TEST_START=$SECONDS
125
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200126AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200127
128MR_MESSAGES=0
129
130while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
131
132 echo ""
133 echo "#########################################################################################################"
134 echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
135 echo "#########################################################################################################"
136 echo ""
137
138 for interface in $AGENT_INTERFACES ; do
139
140 echo "############################################"
141 echo "## Testing using agent interface: $interface ##"
142 echo "############################################"
143
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200144 if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
145 if [ $HTTPX == "http" ]; then
146 use_agent_rest_http
147 else
148 use_agent_rest_https
149 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200150 else
151 use_agent_dmaap
152 fi
153
154 echo "Create $NUM_INSTANCES instances in each OSC RIC"
155 INSTANCE_ID=200000
156 INSTANCES=0
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200157 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
159 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200160 for ((i=1; i<=$NUM_RICS; i++))
161 do
162 if [ $interface == "DMAAP-BATCH" ]; then
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200163 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
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200166 fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200167 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200168 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
169 fi
170 sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
171 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
172 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
173 done
174
175 api_equal json:policy_ids $INSTANCES
176
177 echo "Create $NUM_INSTANCES instances in each STD RIC"
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200178 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
180 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200181 for ((i=1; i<=$NUM_RICS; i++))
182 do
183 if [ $interface == "DMAAP-BATCH" ]; then
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200184 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
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200187 fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200188 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200189 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
190 fi
191 sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
192 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
193 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
194 done
195
196 api_equal json:policy_ids $INSTANCES
197
198
199 echo "Delete all instances in each OSC RIC"
200
201 INSTANCE_ID=200000
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200202 if [ $interface == "REST_PARALLEL" ]; then
203 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
204 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200205 for ((i=1; i<=$NUM_RICS; i++))
206 do
207 if [ $interface == "DMAAP-BATCH" ]; then
208 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200209 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200210 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
211 fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200212 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200213 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
214 fi
215 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
216 sim_equal ricsim_g1_$i num_instances 0
217 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
218 done
219
220 api_equal json:policy_ids $INSTANCES
221
222 echo "Delete all instances in each STD RIC"
223
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200224 if [ $interface == "REST_PARALLEL" ]; then
225 api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
226 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200227 for ((i=1; i<=$NUM_RICS; i++))
228 do
229 if [ $interface == "DMAAP-BATCH" ]; then
230 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200231 elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200232 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
233 fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200234 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200235 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
236 fi
237 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
238 sim_equal ricsim_g2_$i num_instances 0
239 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
240 done
241
242 api_equal json:policy_ids 0
243
244 cr_equal received_callbacks 0
245
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
252
253
254 for ((i=1; i<=$NUM_RICS; i++))
255 do
256 sim_contains_str ricsim_g1_$i remote_hosts "a1-controller"
257 sim_contains_str ricsim_g2_$i remote_hosts "a1-controller"
258 done
259
260 done
261
262done
263
264check_policy_agent_logs
265
266#### TEST COMPLETE ####
267
268store_logs END
269
270print_result
271
272auto_clean_containers