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