blob: 2631a163a99b0506ac0a49ca93a151b673dd87c3 [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
20TC_ONELINE_DESCR="Repeatedly create and delete policies in each RICs for 24h. Via agent REST/DMAAP/DMAAP_BATCH and SDNC using http"
21
22. ../common/testcase_common.sh $@
23. ../common/agent_api_functions.sh
24. ../common/ricsimulator_api_functions.sh
25
26#### TEST BEGIN ####
27
28#Local vars in test script
29##########################
30# Path to callback receiver
31CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
32# Number of RICs per interface type (OSC and STD)
33NUM_RICS=30
34# Number of policy instances per RIC
35NUM_INSTANCES=5
36
37clean_containers
38
39start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
40
41start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
42
43start_mr
44
45start_cr
46
47start_consul_cbs
48
49prepare_consul_config SDNC ".consul_config.json"
50consul_config_app ".consul_config.json"
51
52start_sdnc
53
54start_control_panel
55
56start_policy_agent
57
58use_agent_rest_http
59
60api_get_status 200
61
62echo "Print the interface for group 1 simulators, shall be OSC"
63for ((i=1; i<=$NUM_RICS; i++))
64do
65 sim_print ricsim_g1_$i interface
66done
67
68echo "Print the interface for group 2 simulators, shall be STD"
69for ((i=1; i<=$NUM_RICS; i++))
70do
71 sim_print ricsim_g2_$i interface
72done
73
74echo "Load policy type in group 1 simulators"
75for ((i=1; i<=$NUM_RICS; i++))
76do
77 sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
78done
79
80echo "Check the number of instances in group 1 simulators, shall be 0"
81for ((i=1; i<=$NUM_RICS; i++))
82do
83 sim_equal ricsim_g1_$i num_instances 0
84done
85
86echo "Check the number of instances in group 2 simulators, shall be 0"
87for ((i=1; i<=$NUM_RICS; i++))
88do
89 sim_equal ricsim_g2_$i num_instances 0
90done
91
92echo "Wait for the agent to refresh types from the simulator"
93api_equal json:policy_types 2 120
94
95echo "Check the number of types in the agent for each ric is 1"
96for ((i=1; i<=$NUM_RICS; i++))
97do
98 api_equal json:policy_types?ric=ricsim_g1_$i 1 120
99done
100
101echo "Register a service"
102api_put_service 201 "serv1" 0 "$CR_PATH/1"
103
104TEST_DURATION=$((24*3600))
105TEST_START=$SECONDS
106
107AGENT_INTERFACES="REST DMAAP DMAAP-BATCH"
108
109MR_MESSAGES=0
110
111while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
112
113 echo ""
114 echo "#########################################################################################################"
115 echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
116 echo "#########################################################################################################"
117 echo ""
118
119 for interface in $AGENT_INTERFACES ; do
120
121 echo "############################################"
122 echo "## Testing using agent interface: $interface ##"
123 echo "############################################"
124
125 if [ $interface == "REST" ]; then
126 use_agent_rest_http
127 else
128 use_agent_dmaap
129 fi
130
131 echo "Create $NUM_INSTANCES instances in each OSC RIC"
132 INSTANCE_ID=200000
133 INSTANCES=0
134 for ((i=1; i<=$NUM_RICS; i++))
135 do
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
138 else
139 api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID testdata/OSC/pi1_template.json $NUM_INSTANCES
140 fi
141 if [ $interface != "REST" ]; then
142 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
143 fi
144 sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
145 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
146 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
147 done
148
149 api_equal json:policy_ids $INSTANCES
150
151 echo "Create $NUM_INSTANCES instances in each STD RIC"
152 for ((i=1; i<=$NUM_RICS; i++))
153 do
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
156 else
157 api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID testdata/STD/pi1_template.json $NUM_INSTANCES
158 fi
159 if [ $interface != "REST" ]; then
160 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
161 fi
162 sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
163 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
164 INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
165 done
166
167 api_equal json:policy_ids $INSTANCES
168
169
170 echo "Delete all instances in each OSC RIC"
171
172 INSTANCE_ID=200000
173 for ((i=1; i<=$NUM_RICS; i++))
174 do
175 if [ $interface == "DMAAP-BATCH" ]; then
176 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
177 else
178 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
179 fi
180 if [ $interface != "REST" ]; then
181 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
182 fi
183 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
184 sim_equal ricsim_g1_$i num_instances 0
185 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
186 done
187
188 api_equal json:policy_ids $INSTANCES
189
190 echo "Delete all instances in each STD RIC"
191
192 for ((i=1; i<=$NUM_RICS; i++))
193 do
194 if [ $interface == "DMAAP-BATCH" ]; then
195 api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
196 else
197 api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
198 fi
199 if [ $interface != "REST" ]; then
200 MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
201 fi
202 INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
203 sim_equal ricsim_g2_$i num_instances 0
204 INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
205 done
206
207 api_equal json:policy_ids 0
208
209 cr_equal received_callbacks 0
210
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
217
218
219 for ((i=1; i<=$NUM_RICS; i++))
220 do
221 sim_contains_str ricsim_g1_$i remote_hosts "a1-controller"
222 sim_contains_str ricsim_g2_$i remote_hosts "a1-controller"
223 done
224
225 done
226
227done
228
229check_policy_agent_logs
230
231#### TEST COMPLETE ####
232
233store_logs END
234
235print_result
236
237auto_clean_containers