Updating FTC 2001, 10, 1 series tests to support a1pms V3 image
[nonrtric.git] / test / auto-test / FTC110.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
22 TC_ONELINE_DESCR="Testing of service registration timeouts and keepalive"
23
24 #App names to include in the test when running docker, space separated list
25 DOCKER_INCLUDED_IMAGES="CP CR MR A1PMS RICSIM NGW KUBEPROXY"
26
27 #App names to include in the test when running kubernetes, space separated list
28 KUBE_INCLUDED_IMAGES="CP CR MR A1PMS RICSIM KUBEPROXY NGW"
29 #Pre-started app (not started by script) to include in the test when running kubernetes, space separated list
30 KUBE_PRESTARTED_IMAGES=""
31
32 #Ignore image in DOCKER_INCLUDED_IMAGES, KUBE_INCLUDED_IMAGES if
33 #the image is not configured in the supplied env_file
34 #Used for images not applicable to all supported profile
35 CONDITIONALLY_IGNORED_IMAGES="NGW"
36
37 #Supported test environment profiles
38 SUPPORTED_PROFILES="ONAP-KOHN ONAP-LONDON ONAP-MONTREAL  ORAN-G-RELEASE ORAN-H-RELEASE ORAN-I-RELEASE"
39 #Supported run modes
40 SUPPORTED_RUNMODES="DOCKER KUBE"
41
42 . ../common/testcase_common.sh $@
43
44 setup_testenvironment
45
46 #### TEST BEGIN ####
47 VERSIONS_TO_RUN=2
48
49 if [ -n "$A1PMS_V3_FLAG" ] && [ "${A1PMS_V3_FLAG,,}" == "true" ]; then
50   VERSIONS_TO_RUN=3
51 fi
52
53 for version in $(seq 2 $VERSIONS_TO_RUN); do
54
55   echo "#####################################################################"
56   echo "#####################################################################"
57   echo "### Testing a1pms: V${version}"
58   echo "#####################################################################"
59   echo "#####################################################################"
60
61   if [ "$version" == "3" ]; then
62     if [ -n "$A1PMS_V3" ] && [ -n "$A1PMS_API_PREFIX_V3" ] && [ -n "$A1PMS_ALIVE_URL_V3" ]; then
63       export A1PMS_VERSION="$A1PMS_V3"
64       export A1PMS_API_PREFIX="$A1PMS_API_PREFIX_V3"
65       export A1PMS_ALIVE_URL="$A1PMS_API_PREFIX$A1PMS_ALIVE_URL_V3"
66     else
67       echo "One/All parameters not set in env file (<A1PMS_V3>, <A1PMS_API_PREFIX_V3>, <A1PMS_ALIVE_URL_V3>)"
68       break
69     fi
70   fi
71   sim_generate_policy_uuid
72
73   use_cr_http
74   use_simulator_http
75   use_mr_http
76   use_a1pms_rest_http
77
78   clean_environment
79
80   start_kube_proxy
81
82   start_ric_simulators ricsim_g1 1  OSC_2.1.0
83   start_ric_simulators ricsim_g2 1  STD_1.1.3
84   start_ric_simulators ricsim_g3 1  STD_2.0.0
85
86   if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
87       :
88   else
89       start_mr
90   fi
91
92   start_cr 1
93
94   start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
95
96   if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
97       start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
98   fi
99
100   start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
101
102
103   prepare_a1pms_config      NOSDNC  ".a1pms_config.json"
104
105   if [ $RUNMODE == "KUBE" ]; then
106       a1pms_load_config                       ".a1pms_config.json"
107   else
108       a1pms_api_put_configuration 200 ".a1pms_config.json"
109   fi
110
111   set_a1pms_debug
112
113   if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
114       :
115   else
116       mr_equal requests_submitted 0
117   fi
118
119   sleep_wait 120 "Let A1PMS configuration take effect"
120
121   #Check a1pms alive
122   a1pms_api_get_status 200
123
124   #Print simulator interface version
125   sim_print ricsim_g1_1 interface
126   sim_print ricsim_g2_1 interface
127   sim_print ricsim_g3_1 interface
128
129   a1pms_api_put_service 201 "service1" 15 "$CR_SERVICE_APP_PATH_0/service1"
130
131   a1pms_api_get_services 200 "service1" "service1" 15 "$CR_SERVICE_APP_PATH_0/service1"
132
133   a1pms_api_put_service 201 "service2" 120 "$CR_SERVICE_APP_PATH_0/service2"
134
135   a1pms_api_get_services 200 "service2" "service2" 120 "$CR_SERVICE_APP_PATH_0/service2"
136
137   a1pms_api_put_service 200 "service1" 50 "$CR_SERVICE_APP_PATH_0/service1"
138   a1pms_api_put_service 200 "service2" 180 "$CR_SERVICE_APP_PATH_0/service2"
139
140   a1pms_api_get_services 200 "service1" "service1" 50 "$CR_SERVICE_APP_PATH_0/service1"
141   a1pms_api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_APP_PATH_0/service2"
142
143   a1pms_api_get_service_ids 200 "service1" "service2"
144
145   sleep_wait 30 "Waiting for keep alive timeout"
146
147   a1pms_api_get_services 200 "service1" "service1" 50 "$CR_SERVICE_APP_PATH_0/service1"
148   a1pms_api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_APP_PATH_0/service2"
149
150   sleep_wait 100 "Waiting for keep alive timeout"
151
152   a1pms_api_get_services 404 "service1"
153   a1pms_api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_APP_PATH_0/service2"
154
155   a1pms_api_delete_services 204 "service2"
156
157   a1pms_api_get_services 404 "service1"
158   a1pms_api_get_services 404 "service2"
159
160   a1pms_api_put_service 201 "service3" 60 "$CR_SERVICE_APP_PATH_0/service3"
161
162   a1pms_api_get_services 200 "service3" "service3" 60 "$CR_SERVICE_APP_PATH_0/service3"
163
164   sleep_wait 30 "Waiting for keep alive timeout"
165
166   a1pms_api_put_service 200 "service3" 60 "$CR_SERVICE_APP_PATH_0/service3"
167
168   sleep_wait 100 "Waiting for keep alive timeout"
169
170   a1pms_api_get_services 404 "service3"
171
172   a1pms_api_put_service 201 "service4" 120 "$CR_SERVICE_APP_PATH_0/service4"
173
174   sleep_wait 60 "Waiting for keep alive timeout"
175
176   a1pms_api_get_services 200 "service4" "service4" 120 "$CR_SERVICE_APP_PATH_0/service4"
177
178   a1pms_api_put_services_keepalive 200 "service4"
179
180   sleep_wait 90 "Waiting for keep alive timeout"
181
182   a1pms_api_get_services 200 "service4" "service4" 120 "$CR_SERVICE_APP_PATH_0/service4"
183
184   a1pms_api_delete_services 204 "service4"
185
186   a1pms_api_get_services 404 "service4"
187
188   a1pms_api_get_services 404 "service1"
189   a1pms_api_get_services 404 "service2"
190   a1pms_api_get_services 404 "service3"
191
192   a1pms_api_get_service_ids 200
193
194   a1pms_api_delete_services 404 "service1"
195   a1pms_api_delete_services 404 "service2"
196   a1pms_api_delete_services 404 "service3"
197   a1pms_api_delete_services 404 "service4"
198
199   a1pms_api_put_services_keepalive 404 "service1"
200   a1pms_api_put_services_keepalive 404 "service2"
201   a1pms_api_put_services_keepalive 404 "service3"
202   a1pms_api_put_services_keepalive 404 "service4"
203
204   # Policy delete after timeout
205   a1pms_api_put_service 201 "service10" 600 "$CR_SERVICE_APP_PATH_0/service10"
206
207   sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
208
209   sim_put_policy_type 201 ricsim_g3_1 STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
210
211   a1pms_equal json:rics 3 300
212
213   #a1pms_equal json:policy_schemas 2 120
214
215   a1pms_equal json:policies 0
216
217   notificationurl=$CR_SERVICE_APP_PATH_0"/test"
218
219   if [ "$A1PMS_VERSION" == "V3" ]; then
220     a1pms_equal json:policytypes 3 120
221     a1pms_api_post_policy_v3 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
222     a1pms_api_post_policy_v3 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
223
224     a1pms_api_post_policy_v3 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
225
226   else
227     a1pms_equal json:policy-types 3 120
228     a1pms_api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
229     a1pms_api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
230
231     a1pms_api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
232
233   fi
234
235   a1pms_equal json:policies 3
236
237   sim_equal ricsim_g1_1 num_instances 1
238   sim_equal ricsim_g2_1 num_instances 1
239
240   if [ "$A1PMS_VERSION" == "V3" ]; then
241     a1pms_api_post_policy_v3 201 "service10" ricsim_g1_1 1 5001 true $notificationurl testdata/OSC/pi1_template.json
242     a1pms_api_post_policy_v3 201 "service10" ricsim_g2_1 NOTYPE 5101 true $notificationurl testdata/STD/pi1_template.json
243
244     a1pms_api_post_policy_v3 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5201 true $notificationurl testdata/STD2/pi_qos2_template.json
245   else
246     a1pms_api_put_policy 201 "service10" ricsim_g1_1 1 5001 true $notificationurl testdata/OSC/pi1_template.json
247     a1pms_api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5101 true $notificationurl testdata/STD/pi1_template.json
248
249     a1pms_api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5201 true $notificationurl testdata/STD2/pi_qos2_template.json
250   fi
251   a1pms_equal json:policies 6
252
253   sim_equal ricsim_g1_1 num_instances 2
254   sim_equal ricsim_g2_1 num_instances 2
255   sim_equal ricsim_g3_1 num_instances 2
256
257   sim_post_delete_instances 200 ricsim_g1_1
258   sim_post_delete_instances 200 ricsim_g2_1
259
260   sim_post_delete_instances 200 ricsim_g3_1
261
262   #Wait for recreate of non transient policy
263   a1pms_equal json:policies 3 180
264
265   sim_equal ricsim_g1_1 num_instances 1
266   sim_equal ricsim_g2_1 num_instances 1
267   sim_equal ricsim_g3_1 num_instances 1
268
269   a1pms_api_put_service 200 "service10" 10 "$CR_SERVICE_APP_PATH_0/service10"
270
271   #Wait for service expiry
272   a1pms_equal json:policies 0 120
273
274   sim_equal ricsim_g1_1 num_instances 0
275   sim_equal ricsim_g2_1 num_instances 0
276   sim_equal ricsim_g3_1 num_instances 0
277
278   a1pms_api_get_service_ids 200
279
280   if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
281       :
282   else
283       mr_equal requests_submitted 0
284   fi
285
286   check_a1pms_logs
287
288   #### TEST COMPLETE ####
289
290   store_logs          END
291
292   print_result
293
294   auto_clean_environment
295 done