Functional Test Updates for I Release
[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 #  Copyright (C) 2023 OpenInfra Foundation Europe. All rights reserved.
6 #  ========================================================================
7 #  Licensed under the Apache License, Version 2.0 (the "License");
8 #  you may not use this file except in compliance with the License.
9 #  You may obtain a copy of the License at
10 #
11 #       http://www.apache.org/licenses/LICENSE-2.0
12 #
13 #  Unless required by applicable law or agreed to in writing, software
14 #  distributed under the License is distributed on an "AS IS" BASIS,
15 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 #  See the License for the specific language governing permissions and
17 #  limitations under the License.
18 #  ============LICENSE_END=================================================
19 #
20
21 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"
22
23 #App names to include in the test when running docker, space separated list
24 DOCKER_INCLUDED_IMAGES="CP CR MR A1PMS RICSIM SDNC NGW KUBEPROXY"
25
26 #App names to include in the test when running kubernetes, space separated list
27 KUBE_INCLUDED_IMAGES="CP CR MR A1PMS RICSIM SDNC KUBEPROXY NGW"
28 #Pre-started app (not started by script) to include in the test when running kubernetes, space separated list
29 KUBE_PRESTARTED_IMAGES=""
30
31 #Ignore image in DOCKER_INCLUDED_IMAGES, KUBE_INCLUDED_IMAGES if
32 #the image is not configured in the supplied env_file
33 #Used for images not applicable to all supported profile
34 CONDITIONALLY_IGNORED_IMAGES="NGW"
35
36 #Supported test environment profiles
37 SUPPORTED_PROFILES="ONAP-KOHN ONAP-LONDON ONAP-MONTREAL  ORAN-G-RELEASE ORAN-H-RELEASE ORAN-I-RELEASE"
38 #Supported run modes
39 SUPPORTED_RUNMODES="DOCKER KUBE"
40
41 . ../common/testcase_common.sh $@
42
43 setup_testenvironment
44
45 #### TEST BEGIN ####
46
47 sim_generate_policy_uuid
48
49 #Local vars in test script
50 ##########################
51
52 # Number of RICs per interface type (OSC and STD x 2)
53 NUM_RICS=20
54
55 # Number of policy instances per RIC
56 NUM_INSTANCES=5
57
58 DAYS=3
59
60 clean_environment
61
62 start_kube_proxy
63
64 # use HTTP or HTTPS for all apis
65 HTTPX=HTTPS
66
67 if [ $HTTPX == "HTTP" ]; then
68    use_cr_http
69    use_a1pms_rest_http
70    use_sdnc_http
71    use_simulator_http
72 else
73    use_cr_https
74    use_a1pms_rest_https
75    if [[ "$SDNC_FEATURE_LEVEL" == *"NO_NB_HTTPS"* ]]; then
76       deviation "SDNC does not support NB https"
77       use_sdnc_http
78    else
79       use_sdnc_https
80    fi
81    use_simulator_https
82 fi
83
84 start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
85
86 start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
87
88 start_ric_simulators ricsim_g3 $NUM_RICS  STD_2.0.0
89
90 if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
91     :
92 else
93     start_mr
94 fi
95
96 start_cr 1
97
98 start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
99
100 if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
101    start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
102 fi
103
104 A1PMS_RETRY_CODES=423
105 start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
106
107
108
109 prepare_a1pms_config      SDNC  ".a1pms_config.json"
110
111 if [ $RUNMODE == "KUBE" ]; then
112     a1pms_load_config                       ".a1pms_config.json"
113 else
114     a1pms_api_put_configuration 200 ".a1pms_config.json"
115 fi
116
117 start_sdnc
118 controller_api_wait_for_status_ok 200 ricsim_g1_1
119
120 sleep_wait 120 "Let A1PMS configuration take effect"
121
122 a1pms_api_get_status 200
123
124 echo "Print the interface for group 1 simulators, shall be OSC"
125 for ((i=1; i<=$NUM_RICS; i++))
126 do
127    sim_print ricsim_g1_$i interface
128 done
129
130 echo "Print the interface for group 2 simulators, shall be STD"
131 for ((i=1; i<=$NUM_RICS; i++))
132 do
133    sim_print ricsim_g2_$i interface
134 done
135
136 echo "Print the interface for group 2 simulators, shall be STD 2"
137 for ((i=1; i<=$NUM_RICS; i++))
138 do
139    sim_print ricsim_g3_$i interface
140 done
141
142 echo "Load policy type in group 1 simulators"
143 for ((i=1; i<=$NUM_RICS; i++))
144 do
145    sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
146 done
147
148 echo "Load policy type in group 3 simulators"
149 for ((i=1; i<=$NUM_RICS; i++))
150 do
151    sim_put_policy_type 201 ricsim_g3_$i STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
152 done
153
154 echo "Check the number of instances in  group 1 simulators, shall be 0"
155 for ((i=1; i<=$NUM_RICS; i++))
156 do
157    sim_equal ricsim_g1_$i num_instances 0
158 done
159
160 echo "Check the number of instances in  group 2 simulators, shall be 0"
161 for ((i=1; i<=$NUM_RICS; i++))
162 do
163    sim_equal ricsim_g2_$i num_instances 0
164 done
165
166 echo "Check the number of instances in group 3 simulators, shall be 0"
167 for ((i=1; i<=$NUM_RICS; i++))
168 do
169    sim_equal ricsim_g3_$i num_instances 0
170 done
171
172 echo "Wait for the a1pms to refresh types from the simulator"
173 a1pms_equal json:policy-types 3 300
174
175 echo "Check the number of types in the a1pms for each ric is 1"
176 for ((i=1; i<=$NUM_RICS; i++))
177 do
178    a1pms_equal json:policy-types?ric_id=ricsim_g1_$i 1 120
179    a1pms_equal json:policy-types?ric_id=ricsim_g3_$i 1 120
180 done
181
182 echo "Register a service"
183 a1pms_api_put_service 201 "serv1" 0 "$CR_SERVICE_APP_PATH_0/1"
184
185 TEST_DURATION=$((24*3600*$DAYS))
186
187 TEST_START=$SECONDS
188
189 if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
190     A1PMS_INTERFACES="REST REST_PARALLEL"
191 else
192     A1PMS_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
193 fi
194
195 MR_MESSAGES=0
196
197 notificationurl=$CR_SERVICE_APP_PATH_0"/test"
198
199 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
200
201     echo ""
202     echo "#########################################################################################################"
203     echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
204     echo "#########################################################################################################"
205     echo ""
206
207    for interface in $A1PMS_INTERFACES ; do
208
209       echo "############################################"
210       echo "## Testing using a1pms interface: $interface ##"
211       echo "############################################"
212
213       if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
214          if [ $HTTPX == "HTTP" ]; then
215             use_a1pms_rest_http
216          else
217             use_a1pms_rest_https
218          fi
219       else
220          if [ $HTTPX == "HTTPS" ]; then
221                echo "Using secure ports towards dmaap"
222                use_a1pms_dmaap_https
223          else
224                echo "Using non-secure ports towards dmaap"
225                use_a1pms_dmaap_http
226          fi
227       fi
228
229       echo "Create $NUM_INSTANCES instances in each OSC RIC"
230       INSTANCE_ID=200000
231       INSTANCES=0
232       if [ $interface == "REST_PARALLEL" ]; then
233          a1pms_api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES 3
234       fi
235       for ((i=1; i<=$NUM_RICS; i++))
236       do
237          if [ $interface == "DMAAP-BATCH" ]; then
238             a1pms_api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
239          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
240             a1pms_api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
241          fi
242          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
243             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
244          fi
245          sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
246          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
247          INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
248       done
249
250       a1pms_equal json:policy-instances $INSTANCES
251
252       echo "Create $NUM_INSTANCES instances in each STD RIC"
253       if [ $interface == "REST_PARALLEL" ]; then
254          a1pms_api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES 3
255       fi
256       for ((i=1; i<=$NUM_RICS; i++))
257       do
258          if [ $interface == "DMAAP-BATCH" ]; then
259             a1pms_api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
260          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
261             a1pms_api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
262          fi
263          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
264             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
265          fi
266          sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
267          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
268          INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
269       done
270
271       a1pms_equal json:policy-instances $INSTANCES
272
273       echo "Create $NUM_INSTANCES instances in each STD 2 RIC"
274       if [ $interface == "REST_PARALLEL" ]; then
275          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
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_g3_$i STD_QOS2_0.1.0 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json $NUM_INSTANCES
281          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
282             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
283          fi
284          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
285             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
286          fi
287          sim_equal ricsim_g3_$i num_instances $NUM_INSTANCES
288          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
289          INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
290       done
291
292       a1pms_equal json:policy-instances $INSTANCES
293
294       echo "Delete all instances in each OSC RIC"
295
296       INSTANCE_ID=200000
297       if [ $interface == "REST_PARALLEL" ]; then
298          a1pms_api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
299       fi
300       for ((i=1; i<=$NUM_RICS; i++))
301       do
302          if [ $interface == "DMAAP-BATCH" ]; then
303             a1pms_api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
304          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
305             a1pms_api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
306          fi
307          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
308             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
309          fi
310          INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
311          sim_equal ricsim_g1_$i num_instances 0
312          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
313       done
314
315       a1pms_equal json:policy-instances $INSTANCES
316
317       echo "Delete all instances in each STD RIC"
318
319       if [ $interface == "REST_PARALLEL" ]; then
320          a1pms_api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
321       fi
322       for ((i=1; i<=$NUM_RICS; i++))
323       do
324          if [ $interface == "DMAAP-BATCH" ]; then
325             a1pms_api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
326          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
327             a1pms_api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
328          fi
329          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
330             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
331          fi
332          INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
333          sim_equal ricsim_g2_$i num_instances 0
334          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
335       done
336
337       a1pms_equal json:policy-instances $INSTANCES
338
339       echo "Delete all instances in each STD 2 RIC"
340
341       if [ $interface == "REST_PARALLEL" ]; then
342          a1pms_api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
343       fi
344       for ((i=1; i<=$NUM_RICS; i++))
345       do
346          if [ $interface == "DMAAP-BATCH" ]; then
347             a1pms_api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
348          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
349             a1pms_api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
350          fi
351          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
352             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
353          fi
354          INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
355          sim_equal ricsim_g3_$i num_instances 0
356          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
357       done
358
359       a1pms_equal json:policy-instances $INSTANCES
360
361       if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
362          :
363       else
364          mr_equal requests_submitted $MR_MESSAGES
365          mr_equal requests_fetched $MR_MESSAGES
366          mr_equal responses_submitted $MR_MESSAGES
367          mr_equal responses_fetched $MR_MESSAGES
368          mr_equal current_requests 0
369          mr_equal current_responses 0
370       fi
371
372
373       for ((i=1; i<=$NUM_RICS; i++))
374       do
375          sim_contains_str ricsim_g1_$i remote_hosts $SDNC_APP_NAME
376          sim_contains_str ricsim_g2_$i remote_hosts $SDNC_APP_NAME
377
378          sim_contains_str ricsim_g3_$i remote_hosts $SDNC_APP_NAME
379       done
380
381    done
382
383 done
384
385 check_a1pms_logs
386 check_sdnc_logs
387
388 #### TEST COMPLETE ####
389
390 store_logs          END
391
392 print_result
393
394 auto_clean_environment