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