Updating FTC 2001, 10, 1 series tests to support a1pms V3 image
[nonrtric.git] / test / auto-test / FTC10.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="Basic use case, register service, create/update policy, delete policy, de-register service using both STD and OSC interface while mixing REST"
22
23 #App names to include in the test when running docker, space separated list
24 DOCKER_INCLUDED_IMAGES="CP CR MR A1PMS RICSIM NGW KUBEPROXY"
25
26 #App names to include in the test when running kubernetes, space separated list
27 KUBE_INCLUDED_IMAGES=" MR CR A1PMS RICSIM CP 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 VERSIONS_TO_RUN=2
47
48 if [ -n "$A1PMS_V3_FLAG" ] && [ "${A1PMS_V3_FLAG,,}" == "true" ]; then
49   VERSIONS_TO_RUN=3
50 fi
51
52 for version in $(seq 2 $VERSIONS_TO_RUN); do
53
54   echo "#####################################################################"
55   echo "#####################################################################"
56   echo "### Testing a1pms: V${version}"
57   echo "#####################################################################"
58   echo "#####################################################################"
59
60   if [ "$version" == "3" ]; then
61     if [ -n "$A1PMS_V3" ] && [ -n "$A1PMS_API_PREFIX_V3" ] && [ -n "$A1PMS_ALIVE_URL_V3" ]; then
62       export A1PMS_VERSION="$A1PMS_V3"
63       export A1PMS_API_PREFIX="$A1PMS_API_PREFIX_V3"
64       export A1PMS_ALIVE_URL="$A1PMS_API_PREFIX$A1PMS_ALIVE_URL_V3"
65     else
66       echo "One/All parameters not set in env file (<A1PMS_V3>, <A1PMS_API_PREFIX_V3>, <A1PMS_ALIVE_URL_V3>)"
67       break
68     fi
69   fi
70   sim_generate_policy_uuid
71
72   use_simulator_http
73   use_mr_http
74   use_a1pms_rest_http
75
76
77   clean_environment
78
79   start_kube_proxy
80
81   start_ric_simulators  ricsim_g1 3 OSC_2.1.0
82
83   start_ric_simulators  ricsim_g2 5 STD_1.1.3
84
85   start_ric_simulators ricsim_g3 1  STD_2.0.0
86
87   if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
88       :
89   else
90       start_mr
91   fi
92
93   start_cr 1
94
95
96   start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
97
98   if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
99       start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
100   fi
101
102   start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
103
104   set_a1pms_debug
105
106   use_a1pms_rest_http
107
108
109   prepare_a1pms_config      NOSDNC  ".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   sleep_wait 120 "Let A1PMS configuration take effect"
118
119   a1pms_api_get_status 200
120
121   sim_print ricsim_g1_1 interface
122
123   sim_print ricsim_g2_1 interface
124
125   sim_print ricsim_g3_1 interface
126
127   sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
128
129   sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
130   if [ "$A1PMS_VERSION" == "V3" ]; then
131     a1pms_equal json:policytypes 7 300
132   else
133     a1pms_equal json:policy-types 3 300
134   fi
135
136   # Create policies
137
138   notificationurl=$CR_SERVICE_APP_PATH_0"/test"
139
140   use_a1pms_rest_http
141
142   a1pms_api_put_service 201 "service1" 3600 "$CR_SERVICE_APP_PATH_0/1"
143
144   if [ "$A1PMS_VERSION" == "V3" ]; then
145     a1pms_api_post_policy_v3 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
146   else
147     a1pms_api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
148   fi
149
150   sim_equal ricsim_g1_1 num_instances 1
151
152   if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
153       use_a1pms_rest_http
154   else
155       use_a1pms_dmaap_http
156   fi
157
158   if [ "$A1PMS_VERSION" == "V3" ]; then
159     a1pms_api_post_policy_v3 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
160   else
161     a1pms_api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
162   fi
163
164   sim_equal ricsim_g1_1 num_instances 2
165
166
167   use_a1pms_rest_http
168
169   if [ "$A1PMS_VERSION" == "V3" ]; then
170     a1pms_api_post_policy_v3 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
171   else
172     a1pms_api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
173   fi
174
175   sim_equal ricsim_g2_1 num_instances 1
176
177
178   if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
179       use_a1pms_rest_http
180   else
181       use_a1pms_dmaap_http
182   fi
183
184   if [ "$A1PMS_VERSION" == "V3" ]; then
185     a1pms_api_post_policy_v3 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
186   else
187     a1pms_api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
188   fi
189
190   sim_equal ricsim_g2_1 num_instances 2
191
192   use_a1pms_rest_http
193
194   if [ "$A1PMS_VERSION" == "V3" ]; then
195     a1pms_api_post_policy_v3 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
196   else
197     a1pms_api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
198   fi
199
200   sim_equal ricsim_g3_1 num_instances 1
201
202   if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
203       use_a1pms_rest_http
204   else
205       use_a1pms_dmaap_http
206   fi
207
208   if [ "$A1PMS_VERSION" == "V3" ]; then
209     a1pms_api_post_policy_v3 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos_template.json 1
210   else
211     a1pms_api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos_template.json 1
212   fi
213
214   sim_equal ricsim_g3_1 num_instances 2
215
216   if [ "$A1PMS_VERSION" == "V3" ]; then
217     # Check policies
218     a1pms_api_get_policy 200 2000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
219     a1pms_api_get_policy 200 3000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
220     a1pms_api_get_policy 200 2100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
221     a1pms_api_get_policy 200 3100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
222     a1pms_api_get_policy 200 2200 testdata/STD2/pi_qos_template.json "service1" ricsim_g3_1 STD_QOS_0_2_0 true $notificationurl
223     a1pms_api_get_policy 200 3200 testdata/STD2/pi_qos_template.json "service1" ricsim_g3_1 STD_QOS_0_2_0 true $notificationurl
224   fi
225
226   #Update policies
227   use_a1pms_rest_http
228
229   a1pms_api_put_service 200 "service1" 3600 "$CR_SERVICE_APP_PATH_0/1"
230
231   if [ "$A1PMS_VERSION" == "V3" ]; then
232     a1pms_api_put_policy_v3 200 2000 testdata/OSC/pi1_template.json 1
233   else
234     a1pms_api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
235   fi
236
237   sim_equal ricsim_g1_1 num_instances 2
238
239
240   if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
241       use_a1pms_rest_http
242   else
243       use_a1pms_dmaap_http
244   fi
245
246   if [ "$A1PMS_VERSION" == "V3" ]; then
247     a1pms_api_put_policy_v3 200 3000 testdata/OSC/pi1_template.json 1
248   else
249     a1pms_api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
250   fi
251
252   sim_equal ricsim_g1_1 num_instances 2
253
254
255   use_a1pms_rest_http
256
257   if [ "$A1PMS_VERSION" == "V3" ]; then
258     a1pms_api_put_policy_v3 200 2100 testdata/STD/pi1_template.json 1
259   else
260     a1pms_api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
261   fi
262
263   sim_equal ricsim_g2_1 num_instances 2
264
265
266   if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
267       use_a1pms_rest_http
268   else
269       use_a1pms_dmaap_http
270   fi
271
272   if [ "$A1PMS_VERSION" == "V3" ]; then
273     a1pms_api_put_policy_v3 200 3100 testdata/STD/pi1_template.json 1
274   else
275     a1pms_api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
276   fi
277
278   sim_equal ricsim_g2_1 num_instances 2
279
280   use_a1pms_rest_http
281
282   if [ "$A1PMS_VERSION" == "V3" ]; then
283     a1pms_api_put_policy_v3 200 2200 testdata/STD2/pi_qos_template.json 1
284   else
285     a1pms_api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
286   fi
287
288   sim_equal ricsim_g3_1 num_instances 2
289
290
291   if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
292       use_a1pms_rest_http
293   else
294       use_a1pms_dmaap_http
295   fi
296
297   if [ "$A1PMS_VERSION" == "V3" ]; then
298     a1pms_api_put_policy_v3 200 3200 testdata/STD2/pi_qos_template.json 1
299   else
300     a1pms_api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 true $notificationurl testdata/STD2/pi_qos_template.json 1
301   fi
302
303   sim_equal ricsim_g3_1 num_instances 2
304
305   if [ "$A1PMS_VERSION" != "V3" ]; then
306     # Check policies
307     a1pms_api_get_policy 200 2000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
308     a1pms_api_get_policy 200 3000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
309     a1pms_api_get_policy 200 2100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
310     a1pms_api_get_policy 200 3100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
311     a1pms_api_get_policy 200 2200 testdata/STD2/pi_qos_template.json "service1" ricsim_g3_1 STD_QOS_0_2_0 true $notificationurl
312     a1pms_api_get_policy 200 3200 testdata/STD2/pi_qos_template.json "service1" ricsim_g3_1 STD_QOS_0_2_0 true $notificationurl
313   fi
314
315   sim_equal ricsim_g1_1 num_instances 2
316   sim_equal ricsim_g2_1 num_instances 2
317
318   sim_equal ricsim_g3_1 num_instances 2
319
320   # Remove policies
321
322   if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
323       use_a1pms_rest_http
324   else
325       use_a1pms_dmaap_http
326   fi
327   a1pms_api_delete_policy 204 2000
328   use_a1pms_rest_http
329   a1pms_api_delete_policy 204 3000
330   if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
331       use_a1pms_rest_http
332   else
333       use_a1pms_dmaap_http
334   fi
335   a1pms_api_delete_policy 204 2100
336   use_a1pms_rest_http
337   a1pms_api_delete_policy 204 3100
338   if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
339       use_a1pms_rest_http
340   else
341       use_a1pms_dmaap_http
342   fi
343   a1pms_api_delete_policy 204 2200
344   use_a1pms_rest_http
345   a1pms_api_delete_policy 204 3200
346
347   sim_equal ricsim_g1_1 num_instances 0
348   sim_equal ricsim_g2_1 num_instances 0
349
350   sim_equal ricsim_g3_1 num_instances 0
351
352   # Check remote host access to simulator
353
354   sim_contains_str ricsim_g1_1 remote_hosts $A1PMS_APP_NAME
355   sim_contains_str ricsim_g2_1 remote_hosts $A1PMS_APP_NAME
356   sim_contains_str ricsim_g3_1 remote_hosts $A1PMS_APP_NAME
357
358   # Check policy removal
359   use_a1pms_rest_http
360   a1pms_api_get_policy 404 2000
361   a1pms_api_get_policy 404 3000
362   a1pms_api_get_policy 404 2100
363   a1pms_api_get_policy 404 3100
364
365   a1pms_api_get_policy 404 2200
366   a1pms_api_get_policy 404 3200
367
368   # Remove the service
369   if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
370       use_a1pms_rest_http
371   else
372       use_a1pms_dmaap_http
373   fi
374   a1pms_api_delete_services 204 "service1"
375
376   a1pms_api_get_services 404 "service1"
377
378   check_a1pms_logs
379 done
380   #### TEST COMPLETE ####
381
382 store_logs          END
383
384 print_result
385
386 auto_clean_environment