5db4279f5e9fc4b5656a77a2f9ddcc5ab2e98413
[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 ONAP-KOHN ONAP-LONDON  ORAN-CHERRY ORAN-D-RELEASE ORAN-E-RELEASE ORAN-F-RELEASE ORAN-G-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 A1PMS_RETRY_CODES=423
100 start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
101
102 __CONFIG_HEADER="NOHEADER"
103 if [ $RUNMODE == "KUBE" ]; then
104    __CONFIG_HEADER="HEADER"
105 else
106    if [[ "$A1PMS_FEATURE_LEVEL" == *"NOCONSUL"* ]]; then
107    __CONFIG_HEADER="HEADER"
108    fi
109 fi
110
111 prepare_consul_config      SDNC  ".consul_config.json" $__CONFIG_HEADER
112
113 if [ $RUNMODE == "KUBE" ]; then
114     a1pms_load_config                       ".consul_config.json"
115 else
116     if [[ "$A1PMS_FEATURE_LEVEL" == *"NOCONSUL"* ]]; then
117         a1pms_api_put_configuration 200 ".consul_config.json"
118     else
119         start_consul_cbs
120         consul_config_app                   ".consul_config.json"
121     fi
122 fi
123
124 start_sdnc
125
126 sleep_wait 120 "Let A1PMS cofiguration take effect"
127
128 a1pms_api_get_status 200
129
130 echo "Print the interface for group 1 simulators, shall be OSC"
131 for ((i=1; i<=$NUM_RICS; i++))
132 do
133    sim_print ricsim_g1_$i interface
134 done
135
136 echo "Print the interface for group 2 simulators, shall be STD"
137 for ((i=1; i<=$NUM_RICS; i++))
138 do
139    sim_print ricsim_g2_$i interface
140 done
141
142 if [ "$A1PMS_VERSION" == "V2" ]; then
143    echo "Print the interface for group 2 simulators, shall be STD 2"
144    for ((i=1; i<=$NUM_RICS; i++))
145    do
146       sim_print ricsim_g3_$i interface
147    done
148 fi
149
150 echo "Load policy type in group 1 simulators"
151 for ((i=1; i<=$NUM_RICS; i++))
152 do
153    sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
154 done
155
156 if [ "$A1PMS_VERSION" == "V2" ]; then
157    echo "Load policy type in group 3 simulators"
158    for ((i=1; i<=$NUM_RICS; i++))
159    do
160       sim_put_policy_type 201 ricsim_g3_$i STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
161    done
162 fi
163
164 echo "Check the number of instances in  group 1 simulators, shall be 0"
165 for ((i=1; i<=$NUM_RICS; i++))
166 do
167    sim_equal ricsim_g1_$i num_instances 0
168 done
169
170 echo "Check the number of instances in  group 2 simulators, shall be 0"
171 for ((i=1; i<=$NUM_RICS; i++))
172 do
173    sim_equal ricsim_g2_$i num_instances 0
174 done
175
176 if [ "$A1PMS_VERSION" == "V2" ]; then
177    echo "Check the number of instances in group 3 simulators, shall be 0"
178    for ((i=1; i<=$NUM_RICS; i++))
179    do
180       sim_equal ricsim_g3_$i num_instances 0
181    done
182 fi
183
184 echo "Wait for the a1pms to refresh types from the simulator"
185 if [ "$A1PMS_VERSION" == "V2" ]; then
186    a1pms_equal json:policy-types 3 300
187 else
188    a1pms_equal json:policy_types 2 300
189 fi
190
191 echo "Check the number of types in the a1pms for each ric is 1"
192 for ((i=1; i<=$NUM_RICS; i++))
193 do
194    if [ "$A1PMS_VERSION" == "V2" ]; then
195       a1pms_equal json:policy-types?ric_id=ricsim_g1_$i 1 120
196       a1pms_equal json:policy-types?ric_id=ricsim_g3_$i 1 120
197    else
198       a1pms_equal json:policy_types?ric=ricsim_g1_$i 1 120
199    fi
200 done
201
202 echo "Register a service"
203 a1pms_api_put_service 201 "serv1" 0 "$CR_SERVICE_APP_PATH_0/1"
204
205 TEST_DURATION=$((24*3600*$DAYS))
206 TEST_START=$SECONDS
207
208 A1PMS_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
209
210 MR_MESSAGES=0
211
212 if [ "$A1PMS_VERSION" == "V2" ]; then
213       notificationurl=$CR_SERVICE_APP_PATH_0"/test"
214 else
215       notificationurl=""
216 fi
217
218 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
219
220     echo ""
221     echo "#########################################################################################################"
222     echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
223     echo "#########################################################################################################"
224     echo ""
225
226    for interface in $A1PMS_INTERFACES ; do
227
228       echo "############################################"
229       echo "## Testing using a1pms interface: $interface ##"
230       echo "############################################"
231
232       if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
233          if [ $HTTPX == "HTTP" ]; then
234             use_a1pms_rest_http
235          else
236             use_a1pms_rest_https
237          fi
238       else
239          if [ $HTTPX == "HTTPS" ]; then
240                echo "Using secure ports towards dmaap"
241                use_a1pms_dmaap_https
242          else
243                echo "Using non-secure ports towards dmaap"
244                use_a1pms_dmaap_http
245          fi
246       fi
247
248       echo "Create $NUM_INSTANCES instances in each OSC RIC"
249       INSTANCE_ID=200000
250       INSTANCES=0
251       if [ $interface == "REST_PARALLEL" ]; then
252          a1pms_api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES 3
253       fi
254       for ((i=1; i<=$NUM_RICS; i++))
255       do
256          if [ $interface == "DMAAP-BATCH" ]; then
257             a1pms_api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
258          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
259             a1pms_api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
260          fi
261          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
262             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
263          fi
264          sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
265          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
266          INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
267       done
268
269       if [ "$A1PMS_VERSION" == "V2" ]; then
270          a1pms_equal json:policy-instances $INSTANCES
271       else
272          a1pms_equal json:policy_ids $INSTANCES
273       fi
274
275       echo "Create $NUM_INSTANCES instances in each STD RIC"
276       if [ $interface == "REST_PARALLEL" ]; then
277          a1pms_api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES 3
278       fi
279       for ((i=1; i<=$NUM_RICS; i++))
280       do
281          if [ $interface == "DMAAP-BATCH" ]; then
282             a1pms_api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
283          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
284             a1pms_api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
285          fi
286          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
287             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
288          fi
289          sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
290          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
291          INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
292       done
293
294       if [ "$A1PMS_VERSION" == "V2" ]; then
295          a1pms_equal json:policy-instances $INSTANCES
296       else
297          a1pms_equal json:policy_ids $INSTANCES
298       fi
299
300       if [ "$A1PMS_VERSION" == "V2" ]; then
301          echo "Create $NUM_INSTANCES instances in each STD 2 RIC"
302          if [ $interface == "REST_PARALLEL" ]; then
303             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
304          fi
305          for ((i=1; i<=$NUM_RICS; i++))
306          do
307             if [ $interface == "DMAAP-BATCH" ]; then
308                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
309             elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
310                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
311             fi
312             if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
313                MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
314             fi
315             sim_equal ricsim_g3_$i num_instances $NUM_INSTANCES
316             INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
317             INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
318          done
319
320          if [ "$A1PMS_VERSION" == "V2" ]; then
321             a1pms_equal json:policy-instances $INSTANCES
322          else
323             a1pms_equal json:policy_ids $INSTANCES
324          fi
325       fi
326
327
328       echo "Delete all instances in each OSC RIC"
329
330       INSTANCE_ID=200000
331       if [ $interface == "REST_PARALLEL" ]; then
332          a1pms_api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
333       fi
334       for ((i=1; i<=$NUM_RICS; i++))
335       do
336          if [ $interface == "DMAAP-BATCH" ]; then
337             a1pms_api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
338          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
339             a1pms_api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
340          fi
341          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
342             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
343          fi
344          INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
345          sim_equal ricsim_g1_$i num_instances 0
346          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
347       done
348
349       if [ "$A1PMS_VERSION" == "V2" ]; then
350          a1pms_equal json:policy-instances $INSTANCES
351       else
352          a1pms_equal json:policy_ids $INSTANCES
353       fi
354
355       echo "Delete all instances in each STD RIC"
356
357       if [ $interface == "REST_PARALLEL" ]; then
358          a1pms_api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
359       fi
360       for ((i=1; i<=$NUM_RICS; i++))
361       do
362          if [ $interface == "DMAAP-BATCH" ]; then
363             a1pms_api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
364          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
365             a1pms_api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
366          fi
367          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
368             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
369          fi
370          INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
371          sim_equal ricsim_g2_$i num_instances 0
372          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
373       done
374
375       if [ "$A1PMS_VERSION" == "V2" ]; then
376          a1pms_equal json:policy-instances $INSTANCES
377       else
378          a1pms_equal json:policy_ids $INSTANCES
379       fi
380
381       if [ "$A1PMS_VERSION" == "V2" ]; then
382          echo "Delete all instances in each STD 2 RIC"
383
384          if [ $interface == "REST_PARALLEL" ]; then
385             a1pms_api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
386          fi
387          for ((i=1; i<=$NUM_RICS; i++))
388          do
389             if [ $interface == "DMAAP-BATCH" ]; then
390                a1pms_api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
391             elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
392                a1pms_api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
393             fi
394             if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
395                MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
396             fi
397             INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
398             sim_equal ricsim_g3_$i num_instances 0
399             INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
400          done
401
402          if [ "$A1PMS_VERSION" == "V2" ]; then
403             a1pms_equal json:policy-instances $INSTANCES
404          else
405             a1pms_equal json:policy_ids $INSTANCES
406          fi
407       fi
408
409       mr_equal requests_submitted $MR_MESSAGES
410       mr_equal requests_fetched $MR_MESSAGES
411       mr_equal responses_submitted $MR_MESSAGES
412       mr_equal responses_fetched $MR_MESSAGES
413       mr_equal current_requests 0
414       mr_equal current_responses 0
415
416
417       for ((i=1; i<=$NUM_RICS; i++))
418       do
419          sim_contains_str ricsim_g1_$i remote_hosts $SDNC_APP_NAME
420          sim_contains_str ricsim_g2_$i remote_hosts $SDNC_APP_NAME
421
422          if [ "$A1PMS_VERSION" == "V2" ]; then
423             sim_contains_str ricsim_g3_$i remote_hosts $SDNC_APP_NAME
424          fi
425       done
426
427    done
428
429 done
430
431 check_a1pms_logs
432 check_sdnc_logs
433
434 #### TEST COMPLETE ####
435
436 store_logs          END
437
438 print_result
439
440 auto_clean_environment