blob: e3b96a5e98624cf100c8925d6b887323aa59c4b6 [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
BjornMagnussonXA663566c2021-11-08 10:25:07 +010024DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM NGW KUBEPROXY"
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
BjornMagnussonXAfec823b2021-08-03 14:14:05 +020037SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ONAP-ISTANBUL ORAN-CHERRY ORAN-D-RELEASE ORAN-E-RELEASE"
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
BjornMagnussonXA663566c2021-11-08 10:25:07 +010064start_kube_proxy
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010065
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020066start_ric_simulators ricsim_g1 1 OSC_2.1.0
BjornMagnussonXA4207b832020-11-03 09:52:49 +010067start_ric_simulators ricsim_g2 1 STD_1.1.3
68if [ "$PMS_VERSION" == "V2" ]; then
69 start_ric_simulators ricsim_g3 1 STD_2.0.0
70fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020071
72start_mr
73
74start_cr
75
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010076if [ $RUNMODE == "DOCKER" ]; then
77 start_consul_cbs
78fi
79
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010080start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010081
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010082if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
83 start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
84fi
85
86start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/$POLICY_AGENT_CONFIG_FILE
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020087
88prepare_consul_config NOSDNC ".consul_config.json"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020089
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010090if [ $RUNMODE == "KUBE" ]; then
91 agent_load_config ".consul_config.json"
92else
93 consul_config_app ".consul_config.json"
94fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020095
96set_agent_debug
97
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020098mr_equal requests_submitted 0
99
100#Check agent alive
101api_get_status 200
102
103#Print simulator interface version
104sim_print ricsim_g1_1 interface
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100105sim_print ricsim_g2_1 interface
106if [ "$PMS_VERSION" == "V2" ]; then
107 sim_print ricsim_g3_1 interface
108fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200109
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100110api_put_service 201 "service1" 15 "$CR_SERVICE_APP_PATH/service1"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200111
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100112api_get_services 200 "service1" "service1" 15 "$CR_SERVICE_APP_PATH/service1"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200113
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100114api_put_service 201 "service2" 120 "$CR_SERVICE_APP_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200115
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100116api_get_services 200 "service2" "service2" 120 "$CR_SERVICE_APP_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200117
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100118api_put_service 200 "service1" 50 "$CR_SERVICE_APP_PATH/service1"
119api_put_service 200 "service2" 180 "$CR_SERVICE_APP_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200120
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100121api_get_services 200 "service1" "service1" 50 "$CR_SERVICE_APP_PATH/service1"
122api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_APP_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200123
124api_get_service_ids 200 "service1" "service2"
125
126sleep_wait 30 "Waiting for keep alive timeout"
127
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100128api_get_services 200 "service1" "service1" 50 "$CR_SERVICE_APP_PATH/service1"
129api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_APP_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200130
131sleep_wait 100 "Waiting for keep alive timeout"
132
133api_get_services 404 "service1"
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100134api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_APP_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200135
136api_delete_services 204 "service2"
137
138api_get_services 404 "service1"
139api_get_services 404 "service2"
140
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100141api_put_service 201 "service3" 60 "$CR_SERVICE_APP_PATH/service3"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200142
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100143api_get_services 200 "service3" "service3" 60 "$CR_SERVICE_APP_PATH/service3"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200144
145sleep_wait 30 "Waiting for keep alive timeout"
146
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100147api_put_service 200 "service3" 60 "$CR_SERVICE_APP_PATH/service3"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200148
149sleep_wait 100 "Waiting for keep alive timeout"
150
151api_get_services 404 "service3"
152
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100153api_put_service 201 "service4" 120 "$CR_SERVICE_APP_PATH/service4"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200154
155sleep_wait 60 "Waiting for keep alive timeout"
156
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100157api_get_services 200 "service4" "service4" 120 "$CR_SERVICE_APP_PATH/service4"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200158
159api_put_services_keepalive 200 "service4"
160
161sleep_wait 90 "Waiting for keep alive timeout"
162
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100163api_get_services 200 "service4" "service4" 120 "$CR_SERVICE_APP_PATH/service4"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200164
165api_delete_services 204 "service4"
166
167api_get_services 404 "service4"
168
169api_get_services 404 "service1"
170api_get_services 404 "service2"
171api_get_services 404 "service3"
172
173api_get_service_ids 200
174
175api_delete_services 404 "service1"
176api_delete_services 404 "service2"
177api_delete_services 404 "service3"
178api_delete_services 404 "service4"
179
180api_put_services_keepalive 404 "service1"
181api_put_services_keepalive 404 "service2"
182api_put_services_keepalive 404 "service3"
183api_put_services_keepalive 404 "service4"
184
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200185# Policy delete after timeout
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100186api_put_service 201 "service10" 600 "$CR_SERVICE_APP_PATH/service10"
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200187
188sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
189
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100190if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100191
192 sim_put_policy_type 201 ricsim_g3_1 STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
193
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100194 api_equal json:rics 3 300
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200195
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100196 #api_equal json:policy_schemas 2 120
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200197
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100198 api_equal json:policy-types 3 120
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200199
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100200 api_equal json:policies 0
201else
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100202 api_equal json:rics 2 300
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200203
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100204 api_equal json:policy_schemas 2 120
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200205
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100206 api_equal json:policy_types 2
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200207
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100208 api_equal json:policies 0
209fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200210
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100211if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100212 notificationurl=$CR_SERVICE_APP_PATH"/test"
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100213else
214 notificationurl=""
215fi
216
217api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
218api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200219
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100220if [ "$PMS_VERSION" == "V2" ]; then
221 api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
222 api_equal json:policies 3
223else
224 api_equal json:policies 2
225fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200226
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100227sim_equal ricsim_g1_1 num_instances 1
228sim_equal ricsim_g2_1 num_instances 1
229
230api_put_policy 201 "service10" ricsim_g1_1 1 5001 true $notificationurl testdata/OSC/pi1_template.json
231api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5101 true $notificationurl testdata/STD/pi1_template.json
232
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100233if [ "$PMS_VERSION" == "V2" ]; then
234 api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5201 true $notificationurl testdata/STD2/pi_qos2_template.json
235 api_equal json:policies 6
236else
237 api_equal json:policies 4
238fi
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100239
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200240sim_equal ricsim_g1_1 num_instances 2
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100241sim_equal ricsim_g2_1 num_instances 2
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100242if [ "$PMS_VERSION" == "V2" ]; then
243 sim_equal ricsim_g3_1 num_instances 2
244fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200245
246sim_post_delete_instances 200 ricsim_g1_1
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100247sim_post_delete_instances 200 ricsim_g2_1
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200248
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100249if [ "$PMS_VERSION" == "V2" ]; then
250 sim_post_delete_instances 200 ricsim_g3_1
251fi
252
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200253#Wait for recreate of non transient policy
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100254if [ "$PMS_VERSION" == "V2" ]; then
255 api_equal json:policies 3 180
256else
257 api_equal json:policies 2 180
258fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200259
260sim_equal ricsim_g1_1 num_instances 1
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100261sim_equal ricsim_g2_1 num_instances 1
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100262if [ "$PMS_VERSION" == "V2" ]; then
263 sim_equal ricsim_g3_1 num_instances 1
264fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200265
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100266api_put_service 200 "service10" 10 "$CR_SERVICE_APP_PATH/service10"
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200267
268#Wait for service expiry
269api_equal json:policies 0 120
270
271sim_equal ricsim_g1_1 num_instances 0
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100272sim_equal ricsim_g2_1 num_instances 0
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100273if [ "$PMS_VERSION" == "V2" ]; then
274 sim_equal ricsim_g3_1 num_instances 0
275fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200276
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200277api_get_service_ids 200
278
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200279mr_equal requests_submitted 0
280
281check_policy_agent_logs
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200282
283#### TEST COMPLETE ####
284
285store_logs END
286
287print_result
288
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100289auto_clean_environment