Added STD sim 2.0.0 tests
[nonrtric.git] / test / auto-test / FTC810.sh
1 #!/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
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"
21
22 #App names to include in the test, space separated list
23 INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
24
25 #SUPPORTED TEST ENV FILE
26 SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN"
27
28 . ../common/testcase_common.sh  $@
29 . ../common/agent_api_functions.sh
30 . ../common/ricsimulator_api_functions.sh
31 . ../common/cr_api_functions.sh
32
33 #### TEST BEGIN ####
34
35 generate_uuid
36
37 #Local vars in test script
38 ##########################
39
40 # Number of RICs per interface type (OSC and STD)
41 NUM_RICS=30
42 if [ "$PMS_VERSION" == "V2" ]; then
43    NUM_RICS=20 # 3 A1 interfaces test, less sims per interface. total sims will be same
44 fi
45
46 # Number of policy instances per RIC
47 NUM_INSTANCES=5
48
49 DAYS=3
50
51 clean_containers
52
53 # use HTTP or HTTPS for all apis
54 HTTPX=HTTPS
55
56 if [ $HTTPX == "HTTP" ]; then
57    use_cr_http
58    use_agent_rest_http
59    use_sdnc_http
60    use_simulator_http
61 else
62    use_cr_https
63    use_agent_rest_https
64    use_sdnc_https
65    use_simulator_https
66 fi
67
68 start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
69
70 start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
71
72 if [ "$PMS_VERSION" == "V2" ]; then
73    start_ric_simulators ricsim_g3 $NUM_RICS  STD_2.0.0
74 fi
75
76 start_mr
77
78 start_cr
79
80 start_consul_cbs
81
82 prepare_consul_config      SDNC  ".consul_config.json"
83 consul_config_app                  ".consul_config.json"
84
85 start_sdnc
86
87 start_control_panel
88
89 start_policy_agent
90
91
92 api_get_status 200
93
94 echo "Print the interface for group 1 simulators, shall be OSC"
95 for ((i=1; i<=$NUM_RICS; i++))
96 do
97    sim_print ricsim_g1_$i interface
98 done
99
100 echo "Print the interface for group 2 simulators, shall be STD"
101 for ((i=1; i<=$NUM_RICS; i++))
102 do
103    sim_print ricsim_g2_$i interface
104 done
105
106 if [ "$PMS_VERSION" == "V2" ]; then
107    echo "Print the interface for group 2 simulators, shall be STD 2"
108    for ((i=1; i<=$NUM_RICS; i++))
109    do
110       sim_print ricsim_g3_$i interface
111    done
112 fi
113
114 echo "Load policy type in group 1 simulators"
115 for ((i=1; i<=$NUM_RICS; i++))
116 do
117    sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
118 done
119
120 if [ "$PMS_VERSION" == "V2" ]; then
121    echo "Load policy type in group 3 simulators"
122    for ((i=1; i<=$NUM_RICS; i++))
123    do
124       sim_put_policy_type 201 ricsim_g3_$i STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
125    done
126 fi
127
128 echo "Check the number of instances in  group 1 simulators, shall be 0"
129 for ((i=1; i<=$NUM_RICS; i++))
130 do
131    sim_equal ricsim_g1_$i num_instances 0
132 done
133
134 echo "Check the number of instances in  group 2 simulators, shall be 0"
135 for ((i=1; i<=$NUM_RICS; i++))
136 do
137    sim_equal ricsim_g2_$i num_instances 0
138 done
139
140 if [ "$PMS_VERSION" == "V2" ]; then
141    echo "Check the number of instances in group 3 simulators, shall be 0"
142    for ((i=1; i<=$NUM_RICS; i++))
143    do
144       sim_equal ricsim_g3_$i num_instances 0
145    done
146 fi
147
148 echo "Wait for the agent to refresh types from the simulator"
149 if [ "$PMS_VERSION" == "V2" ]; then
150    api_equal json:policy-types 3 120
151 else
152    api_equal json:policy_types 2 120
153 fi
154
155 echo "Check the number of types in the agent for each ric is 1"
156 for ((i=1; i<=$NUM_RICS; i++))
157 do
158    if [ "$PMS_VERSION" == "V2" ]; then
159       api_equal json:policy-types?ric_id=ricsim_g1_$i 1 120
160       api_equal json:policy-types?ric_id=ricsim_g3_$i 1 120
161    else
162       api_equal json:policy_types?ric=ricsim_g1_$i 1 120
163    fi
164 done
165
166 echo "Register a service"
167 api_put_service 201 "serv1" 0 "$CR_PATH/1"
168
169 TEST_DURATION=$((24*3600*$DAYS))
170 TEST_START=$SECONDS
171
172 AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
173
174 MR_MESSAGES=0
175
176 if [ "$PMS_VERSION" == "V2" ]; then
177       notificationurl=$CR_PATH"/test"
178 else
179       notificationurl=""
180 fi
181
182 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
183
184     echo ""
185     echo "#########################################################################################################"
186     echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
187     echo "#########################################################################################################"
188     echo ""
189
190    for interface in $AGENT_INTERFACES ; do
191
192       echo "############################################"
193       echo "## Testing using agent interface: $interface ##"
194       echo "############################################"
195
196       if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
197          if [ $HTTPX == "HTTP" ]; then
198             use_agent_rest_http
199          else
200             use_agent_rest_https
201          fi
202       else
203          if [ $HTTPX == "HTTPS" ]; then
204                echo "Using secure ports towards dmaap"
205                use_agent_dmaap_https
206          else
207                echo "Using non-secure ports towards dmaap"
208                use_agent_dmaap_http
209          fi
210       fi
211
212       echo "Create $NUM_INSTANCES instances in each OSC RIC"
213       INSTANCE_ID=200000
214       INSTANCES=0
215       if [ $interface == "REST_PARALLEL" ]; then
216          api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES 3
217       fi
218       for ((i=1; i<=$NUM_RICS; i++))
219       do
220          if [ $interface == "DMAAP-BATCH" ]; then
221             api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
222          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
223             api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
224          fi
225          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
226             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
227          fi
228          sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
229          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
230          INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
231       done
232
233       if [ "$PMS_VERSION" == "V2" ]; then
234          api_equal json:policy-instances $INSTANCES
235       else
236          api_equal json:policy_ids $INSTANCES
237       fi
238
239       echo "Create $NUM_INSTANCES instances in each STD RIC"
240       if [ $interface == "REST_PARALLEL" ]; then
241          api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES 3
242       fi
243       for ((i=1; i<=$NUM_RICS; i++))
244       do
245          if [ $interface == "DMAAP-BATCH" ]; then
246             api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
247          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
248             api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
249          fi
250          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
251             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
252          fi
253          sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
254          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
255          INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
256       done
257
258       if [ "$PMS_VERSION" == "V2" ]; then
259          api_equal json:policy-instances $INSTANCES
260       else
261          api_equal json:policy_ids $INSTANCES
262       fi
263
264       if [ "$PMS_VERSION" == "V2" ]; then
265          echo "Create $NUM_INSTANCES instances in each STD 2 RIC"
266          if [ $interface == "REST_PARALLEL" ]; then
267             api_put_policy_parallel 201 "serv1" ricsim_g3_ $NUM_RICS STD_QOS2_0.1.0 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json $NUM_INSTANCES 3
268          fi
269          for ((i=1; i<=$NUM_RICS; i++))
270          do
271             if [ $interface == "DMAAP-BATCH" ]; then
272                api_put_policy_batch 201 "serv1" ricsim_g3_$i STD_QOS2_0.1.0 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json $NUM_INSTANCES
273             elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
274                api_put_policy 201 "serv1" ricsim_g3_$i STD_QOS2_0.1.0 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json $NUM_INSTANCES
275             fi
276             if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
277                MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
278             fi
279             sim_equal ricsim_g3_$i num_instances $NUM_INSTANCES
280             INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
281             INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
282          done
283
284          if [ "$PMS_VERSION" == "V2" ]; then
285             api_equal json:policy-instances $INSTANCES
286          else
287             api_equal json:policy_ids $INSTANCES
288          fi
289       fi
290
291
292       echo "Delete all instances in each OSC RIC"
293
294       INSTANCE_ID=200000
295       if [ $interface == "REST_PARALLEL" ]; then
296          api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
297       fi
298       for ((i=1; i<=$NUM_RICS; i++))
299       do
300          if [ $interface == "DMAAP-BATCH" ]; then
301             api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
302          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
303             api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
304          fi
305          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
306             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
307          fi
308          INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
309          sim_equal ricsim_g1_$i num_instances 0
310          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
311       done
312
313       if [ "$PMS_VERSION" == "V2" ]; then
314          api_equal json:policy-instances $INSTANCES
315       else
316          api_equal json:policy_ids $INSTANCES
317       fi
318
319       echo "Delete all instances in each STD RIC"
320
321       if [ $interface == "REST_PARALLEL" ]; then
322          api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
323       fi
324       for ((i=1; i<=$NUM_RICS; i++))
325       do
326          if [ $interface == "DMAAP-BATCH" ]; then
327             api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
328          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
329             api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
330          fi
331          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
332             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
333          fi
334          INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
335          sim_equal ricsim_g2_$i num_instances 0
336          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
337       done
338
339       if [ "$PMS_VERSION" == "V2" ]; then
340          api_equal json:policy-instances $INSTANCES
341       else
342          api_equal json:policy_ids $INSTANCES
343       fi
344
345       if [ "$PMS_VERSION" == "V2" ]; then
346          echo "Delete all instances in each STD 2 RIC"
347
348          if [ $interface == "REST_PARALLEL" ]; then
349             api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
350          fi
351          for ((i=1; i<=$NUM_RICS; i++))
352          do
353             if [ $interface == "DMAAP-BATCH" ]; then
354                api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
355             elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
356                api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
357             fi
358             if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
359                MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
360             fi
361             INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
362             sim_equal ricsim_g3_$i num_instances 0
363             INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
364          done
365
366          if [ "$PMS_VERSION" == "V2" ]; then
367             api_equal json:policy-instances $INSTANCES
368          else
369             api_equal json:policy_ids $INSTANCES
370          fi
371       fi
372
373       mr_equal requests_submitted $MR_MESSAGES
374       mr_equal requests_fetched $MR_MESSAGES
375       mr_equal responses_submitted $MR_MESSAGES
376       mr_equal responses_fetched $MR_MESSAGES
377       mr_equal current_requests 0
378       mr_equal current_responses 0
379
380
381       for ((i=1; i<=$NUM_RICS; i++))
382       do
383          sim_contains_str ricsim_g1_$i remote_hosts "a1-controller"
384          sim_contains_str ricsim_g2_$i remote_hosts "a1-controller"
385
386          if [ "$PMS_VERSION" == "V2" ]; then
387             sim_contains_str ricsim_g3_$i remote_hosts "a1-controller"
388          fi
389       done
390
391    done
392
393 done
394
395 check_policy_agent_logs
396 check_sdnc_logs
397
398 #### TEST COMPLETE ####
399
400 store_logs          END
401
402 print_result
403
404 auto_clean_containers