blob: c9108f819310e066837698f9b3d8be0b71a7054a [file] [log] [blame]
BjornMagnussonXA70e878f2020-05-11 14:11:30 +02001#!/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
21TC_ONELINE_DESCR="Testing of service registration timeouts and keepalive"
22
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010023#App names to include in the test when running docker, space separated list
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010024DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM NGW"
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020025
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010026#App names to include in the test when running kubernetes, space separated list
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010027KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM KUBEPROXY NGW"
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010028#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
29KUBE_PRESTARTED_IMAGES=""
30
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010031#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
34CONDITIONALLY_IGNORED_IMAGES="NGW"
35
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010036#Supported test environment profiles
BjornMagnussonXAe6b019f2021-04-27 15:34:09 +020037SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ONAP-ISTANBUL ORAN-CHERRY ORAN-DAWN"
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010038#Supported run modes
39SUPPORTED_RUNMODES="DOCKER KUBE"
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010040
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020041. ../common/testcase_common.sh $@
42. ../common/agent_api_functions.sh
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010043. ../common/consul_cbs_functions.sh
44. ../common/control_panel_api_functions.sh
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010045. ../common/cr_api_functions.sh
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010046. ../common/mr_api_functions.sh
47. ../common/ricsimulator_api_functions.sh
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010048. ../common/kube_proxy_api_functions.sh
49. ../common/gateway_api_functions.sh
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020050
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010051setup_testenvironment
52
53#### TEST BEGIN ####
54
55generate_policy_uuid
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020056
BjornMagnussonXA496156d2020-08-10 14:16:24 +020057use_cr_http
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020058use_simulator_http
59use_mr_http
60use_agent_rest_http
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020061
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010062clean_environment
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020063
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010064if [ $RUNMODE == "KUBE" ]; then
65 start_kube_proxy
66fi
67
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020068start_ric_simulators ricsim_g1 1 OSC_2.1.0
BjornMagnussonXA4207b832020-11-03 09:52:49 +010069start_ric_simulators ricsim_g2 1 STD_1.1.3
70if [ "$PMS_VERSION" == "V2" ]; then
71 start_ric_simulators ricsim_g3 1 STD_2.0.0
72fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020073
74start_mr
75
76start_cr
77
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010078if [ $RUNMODE == "DOCKER" ]; then
79 start_consul_cbs
80fi
81
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010082start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010083
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010084if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
85 start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
86fi
87
88start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/$POLICY_AGENT_CONFIG_FILE
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020089
90prepare_consul_config NOSDNC ".consul_config.json"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020091
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010092if [ $RUNMODE == "KUBE" ]; then
93 agent_load_config ".consul_config.json"
94else
95 consul_config_app ".consul_config.json"
96fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020097
98set_agent_debug
99
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200100mr_equal requests_submitted 0
101
102#Check agent alive
103api_get_status 200
104
105#Print simulator interface version
106sim_print ricsim_g1_1 interface
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100107sim_print ricsim_g2_1 interface
108if [ "$PMS_VERSION" == "V2" ]; then
109 sim_print ricsim_g3_1 interface
110fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200111
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100112api_put_service 201 "service1" 15 "$CR_SERVICE_PATH/service1"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200113
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100114api_get_services 200 "service1" "service1" 15 "$CR_SERVICE_PATH/service1"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200115
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100116api_put_service 201 "service2" 120 "$CR_SERVICE_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200117
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100118api_get_services 200 "service2" "service2" 120 "$CR_SERVICE_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200119
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100120api_put_service 200 "service1" 50 "$CR_SERVICE_PATH/service1"
121api_put_service 200 "service2" 180 "$CR_SERVICE_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200122
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100123api_get_services 200 "service1" "service1" 50 "$CR_SERVICE_PATH/service1"
124api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200125
126api_get_service_ids 200 "service1" "service2"
127
128sleep_wait 30 "Waiting for keep alive timeout"
129
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100130api_get_services 200 "service1" "service1" 50 "$CR_SERVICE_PATH/service1"
131api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200132
133sleep_wait 100 "Waiting for keep alive timeout"
134
135api_get_services 404 "service1"
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100136api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200137
138api_delete_services 204 "service2"
139
140api_get_services 404 "service1"
141api_get_services 404 "service2"
142
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100143api_put_service 201 "service3" 60 "$CR_SERVICE_PATH/service3"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200144
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100145api_get_services 200 "service3" "service3" 60 "$CR_SERVICE_PATH/service3"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200146
147sleep_wait 30 "Waiting for keep alive timeout"
148
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100149api_put_service 200 "service3" 60 "$CR_SERVICE_PATH/service3"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200150
151sleep_wait 100 "Waiting for keep alive timeout"
152
153api_get_services 404 "service3"
154
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100155api_put_service 201 "service4" 120 "$CR_SERVICE_PATH/service4"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200156
157sleep_wait 60 "Waiting for keep alive timeout"
158
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100159api_get_services 200 "service4" "service4" 120 "$CR_SERVICE_PATH/service4"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200160
161api_put_services_keepalive 200 "service4"
162
163sleep_wait 90 "Waiting for keep alive timeout"
164
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100165api_get_services 200 "service4" "service4" 120 "$CR_SERVICE_PATH/service4"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200166
167api_delete_services 204 "service4"
168
169api_get_services 404 "service4"
170
171api_get_services 404 "service1"
172api_get_services 404 "service2"
173api_get_services 404 "service3"
174
175api_get_service_ids 200
176
177api_delete_services 404 "service1"
178api_delete_services 404 "service2"
179api_delete_services 404 "service3"
180api_delete_services 404 "service4"
181
182api_put_services_keepalive 404 "service1"
183api_put_services_keepalive 404 "service2"
184api_put_services_keepalive 404 "service3"
185api_put_services_keepalive 404 "service4"
186
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200187# Policy delete after timeout
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100188api_put_service 201 "service10" 600 "$CR_SERVICE_PATH/service10"
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200189
190sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
191
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100192if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100193
194 sim_put_policy_type 201 ricsim_g3_1 STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
195
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100196 api_equal json:rics 3 300
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200197
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100198 #api_equal json:policy_schemas 2 120
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200199
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100200 api_equal json:policy-types 3 120
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200201
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100202 api_equal json:policies 0
203else
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100204 api_equal json:rics 2 300
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200205
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100206 api_equal json:policy_schemas 2 120
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200207
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100208 api_equal json:policy_types 2
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200209
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100210 api_equal json:policies 0
211fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200212
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100213if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100214 notificationurl=$CR_SERVICE_PATH"/test"
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100215else
216 notificationurl=""
217fi
218
219api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
220api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200221
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100222if [ "$PMS_VERSION" == "V2" ]; then
223 api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
224 api_equal json:policies 3
225else
226 api_equal json:policies 2
227fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200228
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100229sim_equal ricsim_g1_1 num_instances 1
230sim_equal ricsim_g2_1 num_instances 1
231
232api_put_policy 201 "service10" ricsim_g1_1 1 5001 true $notificationurl testdata/OSC/pi1_template.json
233api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5101 true $notificationurl testdata/STD/pi1_template.json
234
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100235if [ "$PMS_VERSION" == "V2" ]; then
236 api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5201 true $notificationurl testdata/STD2/pi_qos2_template.json
237 api_equal json:policies 6
238else
239 api_equal json:policies 4
240fi
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100241
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200242sim_equal ricsim_g1_1 num_instances 2
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100243sim_equal ricsim_g2_1 num_instances 2
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100244if [ "$PMS_VERSION" == "V2" ]; then
245 sim_equal ricsim_g3_1 num_instances 2
246fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200247
248sim_post_delete_instances 200 ricsim_g1_1
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100249sim_post_delete_instances 200 ricsim_g2_1
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200250
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100251if [ "$PMS_VERSION" == "V2" ]; then
252 sim_post_delete_instances 200 ricsim_g3_1
253fi
254
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200255#Wait for recreate of non transient policy
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100256if [ "$PMS_VERSION" == "V2" ]; then
257 api_equal json:policies 3 180
258else
259 api_equal json:policies 2 180
260fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200261
262sim_equal ricsim_g1_1 num_instances 1
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100263sim_equal ricsim_g2_1 num_instances 1
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100264if [ "$PMS_VERSION" == "V2" ]; then
265 sim_equal ricsim_g3_1 num_instances 1
266fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200267
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100268api_put_service 200 "service10" 10 "$CR_SERVICE_PATH/service10"
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200269
270#Wait for service expiry
271api_equal json:policies 0 120
272
273sim_equal ricsim_g1_1 num_instances 0
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100274sim_equal ricsim_g2_1 num_instances 0
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100275if [ "$PMS_VERSION" == "V2" ]; then
276 sim_equal ricsim_g3_1 num_instances 0
277fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200278
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200279api_get_service_ids 200
280
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200281mr_equal requests_submitted 0
282
283check_policy_agent_logs
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200284
285#### TEST COMPLETE ####
286
287store_logs END
288
289print_result
290
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100291auto_clean_environment