blob: f855f6fa15de1435c2acfd7d462777042e11b32b [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
BjornMagnussonXA79e37002021-11-22 13:36:04 +010041. ../common/testcase_common.sh $@
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020042
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010043setup_testenvironment
44
45#### TEST BEGIN ####
46
47generate_policy_uuid
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020048
BjornMagnussonXA496156d2020-08-10 14:16:24 +020049use_cr_http
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020050use_simulator_http
51use_mr_http
52use_agent_rest_http
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020053
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010054clean_environment
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020055
BjornMagnussonXA663566c2021-11-08 10:25:07 +010056start_kube_proxy
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010057
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020058start_ric_simulators ricsim_g1 1 OSC_2.1.0
BjornMagnussonXA4207b832020-11-03 09:52:49 +010059start_ric_simulators ricsim_g2 1 STD_1.1.3
60if [ "$PMS_VERSION" == "V2" ]; then
61 start_ric_simulators ricsim_g3 1 STD_2.0.0
62fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020063
64start_mr
65
BjornMagnussonXA79e37002021-11-22 13:36:04 +010066start_cr 1
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020067
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010068if [ $RUNMODE == "DOCKER" ]; then
69 start_consul_cbs
70fi
71
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010072start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010073
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010074if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
75 start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
76fi
77
78start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/$POLICY_AGENT_CONFIG_FILE
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020079
80prepare_consul_config NOSDNC ".consul_config.json"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020081
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010082if [ $RUNMODE == "KUBE" ]; then
83 agent_load_config ".consul_config.json"
84else
85 consul_config_app ".consul_config.json"
86fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020087
88set_agent_debug
89
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020090mr_equal requests_submitted 0
91
92#Check agent alive
93api_get_status 200
94
95#Print simulator interface version
96sim_print ricsim_g1_1 interface
BjornMagnussonXA4207b832020-11-03 09:52:49 +010097sim_print ricsim_g2_1 interface
98if [ "$PMS_VERSION" == "V2" ]; then
99 sim_print ricsim_g3_1 interface
100fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200101
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100102api_put_service 201 "service1" 15 "$CR_SERVICE_APP_PATH_0/service1"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200103
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100104api_get_services 200 "service1" "service1" 15 "$CR_SERVICE_APP_PATH_0/service1"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200105
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100106api_put_service 201 "service2" 120 "$CR_SERVICE_APP_PATH_0/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200107
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100108api_get_services 200 "service2" "service2" 120 "$CR_SERVICE_APP_PATH_0/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200109
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100110api_put_service 200 "service1" 50 "$CR_SERVICE_APP_PATH_0/service1"
111api_put_service 200 "service2" 180 "$CR_SERVICE_APP_PATH_0/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200112
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100113api_get_services 200 "service1" "service1" 50 "$CR_SERVICE_APP_PATH_0/service1"
114api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_APP_PATH_0/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200115
116api_get_service_ids 200 "service1" "service2"
117
118sleep_wait 30 "Waiting for keep alive timeout"
119
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100120api_get_services 200 "service1" "service1" 50 "$CR_SERVICE_APP_PATH_0/service1"
121api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_APP_PATH_0/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200122
123sleep_wait 100 "Waiting for keep alive timeout"
124
125api_get_services 404 "service1"
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100126api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_APP_PATH_0/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200127
128api_delete_services 204 "service2"
129
130api_get_services 404 "service1"
131api_get_services 404 "service2"
132
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100133api_put_service 201 "service3" 60 "$CR_SERVICE_APP_PATH_0/service3"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200134
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100135api_get_services 200 "service3" "service3" 60 "$CR_SERVICE_APP_PATH_0/service3"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200136
137sleep_wait 30 "Waiting for keep alive timeout"
138
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100139api_put_service 200 "service3" 60 "$CR_SERVICE_APP_PATH_0/service3"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200140
141sleep_wait 100 "Waiting for keep alive timeout"
142
143api_get_services 404 "service3"
144
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100145api_put_service 201 "service4" 120 "$CR_SERVICE_APP_PATH_0/service4"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200146
147sleep_wait 60 "Waiting for keep alive timeout"
148
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100149api_get_services 200 "service4" "service4" 120 "$CR_SERVICE_APP_PATH_0/service4"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200150
151api_put_services_keepalive 200 "service4"
152
153sleep_wait 90 "Waiting for keep alive timeout"
154
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100155api_get_services 200 "service4" "service4" 120 "$CR_SERVICE_APP_PATH_0/service4"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200156
157api_delete_services 204 "service4"
158
159api_get_services 404 "service4"
160
161api_get_services 404 "service1"
162api_get_services 404 "service2"
163api_get_services 404 "service3"
164
165api_get_service_ids 200
166
167api_delete_services 404 "service1"
168api_delete_services 404 "service2"
169api_delete_services 404 "service3"
170api_delete_services 404 "service4"
171
172api_put_services_keepalive 404 "service1"
173api_put_services_keepalive 404 "service2"
174api_put_services_keepalive 404 "service3"
175api_put_services_keepalive 404 "service4"
176
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200177# Policy delete after timeout
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100178api_put_service 201 "service10" 600 "$CR_SERVICE_APP_PATH_0/service10"
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200179
180sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
181
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100182if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100183
184 sim_put_policy_type 201 ricsim_g3_1 STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
185
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100186 api_equal json:rics 3 300
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200187
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100188 #api_equal json:policy_schemas 2 120
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200189
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100190 api_equal json:policy-types 3 120
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200191
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100192 api_equal json:policies 0
193else
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100194 api_equal json:rics 2 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
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100198 api_equal json:policy_types 2
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200199
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100200 api_equal json:policies 0
201fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200202
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100203if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100204 notificationurl=$CR_SERVICE_APP_PATH_0"/test"
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100205else
206 notificationurl=""
207fi
208
209api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
210api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200211
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100212if [ "$PMS_VERSION" == "V2" ]; then
213 api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
214 api_equal json:policies 3
215else
216 api_equal json:policies 2
217fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200218
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100219sim_equal ricsim_g1_1 num_instances 1
220sim_equal ricsim_g2_1 num_instances 1
221
222api_put_policy 201 "service10" ricsim_g1_1 1 5001 true $notificationurl testdata/OSC/pi1_template.json
223api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5101 true $notificationurl testdata/STD/pi1_template.json
224
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100225if [ "$PMS_VERSION" == "V2" ]; then
226 api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5201 true $notificationurl testdata/STD2/pi_qos2_template.json
227 api_equal json:policies 6
228else
229 api_equal json:policies 4
230fi
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100231
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200232sim_equal ricsim_g1_1 num_instances 2
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100233sim_equal ricsim_g2_1 num_instances 2
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100234if [ "$PMS_VERSION" == "V2" ]; then
235 sim_equal ricsim_g3_1 num_instances 2
236fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200237
238sim_post_delete_instances 200 ricsim_g1_1
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100239sim_post_delete_instances 200 ricsim_g2_1
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200240
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100241if [ "$PMS_VERSION" == "V2" ]; then
242 sim_post_delete_instances 200 ricsim_g3_1
243fi
244
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200245#Wait for recreate of non transient policy
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100246if [ "$PMS_VERSION" == "V2" ]; then
247 api_equal json:policies 3 180
248else
249 api_equal json:policies 2 180
250fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200251
252sim_equal ricsim_g1_1 num_instances 1
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100253sim_equal ricsim_g2_1 num_instances 1
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100254if [ "$PMS_VERSION" == "V2" ]; then
255 sim_equal ricsim_g3_1 num_instances 1
256fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200257
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100258api_put_service 200 "service10" 10 "$CR_SERVICE_APP_PATH_0/service10"
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200259
260#Wait for service expiry
261api_equal json:policies 0 120
262
263sim_equal ricsim_g1_1 num_instances 0
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100264sim_equal ricsim_g2_1 num_instances 0
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100265if [ "$PMS_VERSION" == "V2" ]; then
266 sim_equal ricsim_g3_1 num_instances 0
267fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200268
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200269api_get_service_ids 200
270
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200271mr_equal requests_submitted 0
272
273check_policy_agent_logs
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200274
275#### TEST COMPLETE ####
276
277store_logs END
278
279print_result
280
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100281auto_clean_environment