Updated test env documentation
[nonrtric.git] / test / auto-test / FTC810.sh
1 #!/bin/bash
2
3 #  ============LICENSE_START===============================================
4 #  Copyright (C) 2020-2023 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 and with SDNC using http or https"
21
22 #App names to include in the test when running docker, space separated list
23 DOCKER_INCLUDED_IMAGES="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 #Pre-started 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-JAKARTA ONAP-KOHN ONAP-LONDON  ORAN-F-RELEASE ORAN-G-RELEASE ORAN-H-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 sim_generate_policy_uuid
47
48 #Local vars in test script
49 ##########################
50
51 # Number of RICs per interface type (OSC and STD x 2)
52 NUM_RICS=20
53
54 # Number of policy instances per RIC
55 NUM_INSTANCES=5
56
57 DAYS=3
58
59 clean_environment
60
61 start_kube_proxy
62
63 # use HTTP or HTTPS for all apis
64 HTTPX=HTTPS
65
66 if [ $HTTPX == "HTTP" ]; then
67    use_cr_http
68    use_a1pms_rest_http
69    use_sdnc_http
70    use_simulator_http
71 else
72    use_cr_https
73    use_a1pms_rest_https
74    if [[ "$SDNC_FEATURE_LEVEL" == *"NO_NB_HTTPS"* ]]; then
75       deviation "SDNC does not support NB https"
76       use_sdnc_http
77    else
78       use_sdnc_https
79    fi
80    use_simulator_https
81 fi
82
83 start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
84
85 start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
86
87 start_ric_simulators ricsim_g3 $NUM_RICS  STD_2.0.0
88
89 if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
90     :
91 else
92     start_mr
93 fi
94
95 start_cr 1
96
97 start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
98
99 if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
100    start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
101 fi
102
103 A1PMS_RETRY_CODES=423
104 start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
105
106
107
108 prepare_a1pms_config      SDNC  ".a1pms_config.json"
109
110 if [ $RUNMODE == "KUBE" ]; then
111     a1pms_load_config                       ".a1pms_config.json"
112 else
113     a1pms_api_put_configuration 200 ".a1pms_config.json"
114 fi
115
116 start_sdnc
117 controller_api_wait_for_status_ok 200 ricsim_g1_1
118
119 sleep_wait 120 "Let A1PMS configuration take effect"
120
121 a1pms_api_get_status 200
122
123 echo "Print the interface for group 1 simulators, shall be OSC"
124 for ((i=1; i<=$NUM_RICS; i++))
125 do
126    sim_print ricsim_g1_$i interface
127 done
128
129 echo "Print the interface for group 2 simulators, shall be STD"
130 for ((i=1; i<=$NUM_RICS; i++))
131 do
132    sim_print ricsim_g2_$i interface
133 done
134
135 echo "Print the interface for group 2 simulators, shall be STD 2"
136 for ((i=1; i<=$NUM_RICS; i++))
137 do
138    sim_print ricsim_g3_$i interface
139 done
140
141 echo "Load policy type in group 1 simulators"
142 for ((i=1; i<=$NUM_RICS; i++))
143 do
144    sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
145 done
146
147 echo "Load policy type in group 3 simulators"
148 for ((i=1; i<=$NUM_RICS; i++))
149 do
150    sim_put_policy_type 201 ricsim_g3_$i STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
151 done
152
153 echo "Check the number of instances in  group 1 simulators, shall be 0"
154 for ((i=1; i<=$NUM_RICS; i++))
155 do
156    sim_equal ricsim_g1_$i num_instances 0
157 done
158
159 echo "Check the number of instances in  group 2 simulators, shall be 0"
160 for ((i=1; i<=$NUM_RICS; i++))
161 do
162    sim_equal ricsim_g2_$i num_instances 0
163 done
164
165 echo "Check the number of instances in group 3 simulators, shall be 0"
166 for ((i=1; i<=$NUM_RICS; i++))
167 do
168    sim_equal ricsim_g3_$i num_instances 0
169 done
170
171 echo "Wait for the a1pms to refresh types from the simulator"
172 a1pms_equal json:policy-types 3 300
173
174 echo "Check the number of types in the a1pms for each ric is 1"
175 for ((i=1; i<=$NUM_RICS; i++))
176 do
177    a1pms_equal json:policy-types?ric_id=ricsim_g1_$i 1 120
178    a1pms_equal json:policy-types?ric_id=ricsim_g3_$i 1 120
179 done
180
181 echo "Register a service"
182 a1pms_api_put_service 201 "serv1" 0 "$CR_SERVICE_APP_PATH_0/1"
183
184 TEST_DURATION=$((24*3600*$DAYS))
185
186 TEST_START=$SECONDS
187
188 if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
189     A1PMS_INTERFACES="REST REST_PARALLEL"
190 else
191     A1PMS_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
192 fi
193
194 MR_MESSAGES=0
195
196 notificationurl=$CR_SERVICE_APP_PATH_0"/test"
197
198 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
199
200     echo ""
201     echo "#########################################################################################################"
202     echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
203     echo "#########################################################################################################"
204     echo ""
205
206    for interface in $A1PMS_INTERFACES ; do
207
208       echo "############################################"
209       echo "## Testing using a1pms interface: $interface ##"
210       echo "############################################"
211
212       if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
213          if [ $HTTPX == "HTTP" ]; then
214             use_a1pms_rest_http
215          else
216             use_a1pms_rest_https
217          fi
218       else
219          if [ $HTTPX == "HTTPS" ]; then
220                echo "Using secure ports towards dmaap"
221                use_a1pms_dmaap_https
222          else
223                echo "Using non-secure ports towards dmaap"
224                use_a1pms_dmaap_http
225          fi
226       fi
227
228       echo "Create $NUM_INSTANCES instances in each OSC RIC"
229       INSTANCE_ID=200000
230       INSTANCES=0
231       if [ $interface == "REST_PARALLEL" ]; then
232          a1pms_api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES 3
233       fi
234       for ((i=1; i<=$NUM_RICS; i++))
235       do
236          if [ $interface == "DMAAP-BATCH" ]; then
237             a1pms_api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
238          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
239             a1pms_api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
240          fi
241          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
242             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
243          fi
244          sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
245          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
246          INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
247       done
248
249       a1pms_equal json:policy-instances $INSTANCES
250
251       echo "Create $NUM_INSTANCES instances in each STD RIC"
252       if [ $interface == "REST_PARALLEL" ]; then
253          a1pms_api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES 3
254       fi
255       for ((i=1; i<=$NUM_RICS; i++))
256       do
257          if [ $interface == "DMAAP-BATCH" ]; then
258             a1pms_api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
259          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
260             a1pms_api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
261          fi
262          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
263             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
264          fi
265          sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
266          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
267          INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
268       done
269
270       a1pms_equal json:policy-instances $INSTANCES
271
272       echo "Create $NUM_INSTANCES instances in each STD 2 RIC"
273       if [ $interface == "REST_PARALLEL" ]; then
274          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
275       fi
276       for ((i=1; i<=$NUM_RICS; i++))
277       do
278          if [ $interface == "DMAAP-BATCH" ]; then
279             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
280          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
281             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
282          fi
283          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
284             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
285          fi
286          sim_equal ricsim_g3_$i num_instances $NUM_INSTANCES
287          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
288          INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
289       done
290
291       a1pms_equal json:policy-instances $INSTANCES
292
293       echo "Delete all instances in each OSC RIC"
294
295       INSTANCE_ID=200000
296       if [ $interface == "REST_PARALLEL" ]; then
297          a1pms_api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
298       fi
299       for ((i=1; i<=$NUM_RICS; i++))
300       do
301          if [ $interface == "DMAAP-BATCH" ]; then
302             a1pms_api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
303          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
304             a1pms_api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
305          fi
306          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
307             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
308          fi
309          INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
310          sim_equal ricsim_g1_$i num_instances 0
311          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
312       done
313
314       a1pms_equal json:policy-instances $INSTANCES
315
316       echo "Delete all instances in each STD RIC"
317
318       if [ $interface == "REST_PARALLEL" ]; then
319          a1pms_api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
320       fi
321       for ((i=1; i<=$NUM_RICS; i++))
322       do
323          if [ $interface == "DMAAP-BATCH" ]; then
324             a1pms_api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
325          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
326             a1pms_api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
327          fi
328          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
329             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
330          fi
331          INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
332          sim_equal ricsim_g2_$i num_instances 0
333          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
334       done
335
336       a1pms_equal json:policy-instances $INSTANCES
337
338       echo "Delete all instances in each STD 2 RIC"
339
340       if [ $interface == "REST_PARALLEL" ]; then
341          a1pms_api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
342       fi
343       for ((i=1; i<=$NUM_RICS; i++))
344       do
345          if [ $interface == "DMAAP-BATCH" ]; then
346             a1pms_api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
347          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
348             a1pms_api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
349          fi
350          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
351             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
352          fi
353          INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
354          sim_equal ricsim_g3_$i num_instances 0
355          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
356       done
357
358       a1pms_equal json:policy-instances $INSTANCES
359
360       if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
361          :
362       else
363          mr_equal requests_submitted $MR_MESSAGES
364          mr_equal requests_fetched $MR_MESSAGES
365          mr_equal responses_submitted $MR_MESSAGES
366          mr_equal responses_fetched $MR_MESSAGES
367          mr_equal current_requests 0
368          mr_equal current_responses 0
369       fi
370
371
372       for ((i=1; i<=$NUM_RICS; i++))
373       do
374          sim_contains_str ricsim_g1_$i remote_hosts $SDNC_APP_NAME
375          sim_contains_str ricsim_g2_$i remote_hosts $SDNC_APP_NAME
376
377          sim_contains_str ricsim_g3_$i remote_hosts $SDNC_APP_NAME
378       done
379
380    done
381
382 done
383
384 check_a1pms_logs
385 check_sdnc_logs
386
387 #### TEST COMPLETE ####
388
389 store_logs          END
390
391 print_result
392
393 auto_clean_environment