blob: 81aa95caae6ea0b0d05ad7df8e3503870ea7e5c9 [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
24DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM"
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
27KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM"
28#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
29KUBE_PRESTARTED_IMAGES=""
30
31#Supported test environment profiles
BjornMagnussonXA89b64ab2020-12-16 09:21:01 +010032SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN"
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010033#Supported run modes
34SUPPORTED_RUNMODES="DOCKER KUBE"
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010035
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020036. ../common/testcase_common.sh $@
37. ../common/agent_api_functions.sh
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010038. ../common/consul_cbs_functions.sh
39. ../common/control_panel_api_functions.sh
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010040. ../common/cr_api_functions.sh
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010041. ../common/mr_api_functions.sh
42. ../common/ricsimulator_api_functions.sh
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020043
BjornMagnussonXAad047782020-06-08 15:54:11 +020044generate_uuid
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020045
BjornMagnussonXA496156d2020-08-10 14:16:24 +020046use_cr_http
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020047use_simulator_http
48use_mr_http
49use_agent_rest_http
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020050
51
52#### TEST BEGIN ####
53
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010054clean_environment
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020055
56start_ric_simulators ricsim_g1 1 OSC_2.1.0
BjornMagnussonXA4207b832020-11-03 09:52:49 +010057start_ric_simulators ricsim_g2 1 STD_1.1.3
58if [ "$PMS_VERSION" == "V2" ]; then
59 start_ric_simulators ricsim_g3 1 STD_2.0.0
60fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020061
62start_mr
63
64start_cr
65
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010066if [ $RUNMODE == "DOCKER" ]; then
67 start_consul_cbs
68fi
69
70start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties
71
72start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020073
74prepare_consul_config NOSDNC ".consul_config.json"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020075
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010076if [ $RUNMODE == "KUBE" ]; then
77 agent_load_config ".consul_config.json"
78else
79 consul_config_app ".consul_config.json"
80fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020081
82set_agent_debug
83
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020084mr_equal requests_submitted 0
85
86#Check agent alive
87api_get_status 200
88
89#Print simulator interface version
90sim_print ricsim_g1_1 interface
BjornMagnussonXA4207b832020-11-03 09:52:49 +010091sim_print ricsim_g2_1 interface
92if [ "$PMS_VERSION" == "V2" ]; then
93 sim_print ricsim_g3_1 interface
94fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020095
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010096api_put_service 201 "service1" 15 "$CR_SERVICE_PATH/service1"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020097
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010098api_get_services 200 "service1" "service1" 15 "$CR_SERVICE_PATH/service1"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020099
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100100api_put_service 201 "service2" 120 "$CR_SERVICE_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200101
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100102api_get_services 200 "service2" "service2" 120 "$CR_SERVICE_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200103
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100104api_put_service 200 "service1" 50 "$CR_SERVICE_PATH/service1"
105api_put_service 200 "service2" 180 "$CR_SERVICE_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200106
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100107api_get_services 200 "service1" "service1" 50 "$CR_SERVICE_PATH/service1"
108api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200109
110api_get_service_ids 200 "service1" "service2"
111
112sleep_wait 30 "Waiting for keep alive timeout"
113
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100114api_get_services 200 "service1" "service1" 50 "$CR_SERVICE_PATH/service1"
115api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200116
117sleep_wait 100 "Waiting for keep alive timeout"
118
119api_get_services 404 "service1"
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100120api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_PATH/service2"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200121
122api_delete_services 204 "service2"
123
124api_get_services 404 "service1"
125api_get_services 404 "service2"
126
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100127api_put_service 201 "service3" 60 "$CR_SERVICE_PATH/service3"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200128
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100129api_get_services 200 "service3" "service3" 60 "$CR_SERVICE_PATH/service3"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200130
131sleep_wait 30 "Waiting for keep alive timeout"
132
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100133api_put_service 200 "service3" 60 "$CR_SERVICE_PATH/service3"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200134
135sleep_wait 100 "Waiting for keep alive timeout"
136
137api_get_services 404 "service3"
138
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100139api_put_service 201 "service4" 120 "$CR_SERVICE_PATH/service4"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200140
141sleep_wait 60 "Waiting for keep alive timeout"
142
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100143api_get_services 200 "service4" "service4" 120 "$CR_SERVICE_PATH/service4"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200144
145api_put_services_keepalive 200 "service4"
146
147sleep_wait 90 "Waiting for keep alive timeout"
148
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100149api_get_services 200 "service4" "service4" 120 "$CR_SERVICE_PATH/service4"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200150
151api_delete_services 204 "service4"
152
153api_get_services 404 "service4"
154
155api_get_services 404 "service1"
156api_get_services 404 "service2"
157api_get_services 404 "service3"
158
159api_get_service_ids 200
160
161api_delete_services 404 "service1"
162api_delete_services 404 "service2"
163api_delete_services 404 "service3"
164api_delete_services 404 "service4"
165
166api_put_services_keepalive 404 "service1"
167api_put_services_keepalive 404 "service2"
168api_put_services_keepalive 404 "service3"
169api_put_services_keepalive 404 "service4"
170
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200171# Policy delete after timeout
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100172api_put_service 201 "service10" 600 "$CR_SERVICE_PATH/service10"
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200173
174sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
175
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100176if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100177
178 sim_put_policy_type 201 ricsim_g3_1 STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
179
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100180 api_equal json:rics 3 300
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200181
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100182 #api_equal json:policy_schemas 2 120
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200183
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100184 api_equal json:policy-types 3 120
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200185
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100186 api_equal json:policies 0
187else
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100188 api_equal json:rics 2 300
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200189
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100190 api_equal json:policy_schemas 2 120
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200191
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100192 api_equal json:policy_types 2
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200193
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100194 api_equal json:policies 0
195fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200196
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100197if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100198 notificationurl=$CR_SERVICE_PATH"/test"
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100199else
200 notificationurl=""
201fi
202
203api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
204api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200205
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100206if [ "$PMS_VERSION" == "V2" ]; then
207 api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
208 api_equal json:policies 3
209else
210 api_equal json:policies 2
211fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200212
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100213sim_equal ricsim_g1_1 num_instances 1
214sim_equal ricsim_g2_1 num_instances 1
215
216api_put_policy 201 "service10" ricsim_g1_1 1 5001 true $notificationurl testdata/OSC/pi1_template.json
217api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5101 true $notificationurl testdata/STD/pi1_template.json
218
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100219if [ "$PMS_VERSION" == "V2" ]; then
220 api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5201 true $notificationurl testdata/STD2/pi_qos2_template.json
221 api_equal json:policies 6
222else
223 api_equal json:policies 4
224fi
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100225
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200226sim_equal ricsim_g1_1 num_instances 2
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100227sim_equal ricsim_g2_1 num_instances 2
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100228if [ "$PMS_VERSION" == "V2" ]; then
229 sim_equal ricsim_g3_1 num_instances 2
230fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200231
232sim_post_delete_instances 200 ricsim_g1_1
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100233sim_post_delete_instances 200 ricsim_g2_1
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200234
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100235if [ "$PMS_VERSION" == "V2" ]; then
236 sim_post_delete_instances 200 ricsim_g3_1
237fi
238
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200239#Wait for recreate of non transient policy
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100240if [ "$PMS_VERSION" == "V2" ]; then
241 api_equal json:policies 3 180
242else
243 api_equal json:policies 2 180
244fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200245
246sim_equal ricsim_g1_1 num_instances 1
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100247sim_equal ricsim_g2_1 num_instances 1
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100248if [ "$PMS_VERSION" == "V2" ]; then
249 sim_equal ricsim_g3_1 num_instances 1
250fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200251
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100252api_put_service 200 "service10" 10 "$CR_SERVICE_PATH/service10"
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200253
254#Wait for service expiry
255api_equal json:policies 0 120
256
257sim_equal ricsim_g1_1 num_instances 0
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100258sim_equal ricsim_g2_1 num_instances 0
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100259if [ "$PMS_VERSION" == "V2" ]; then
260 sim_equal ricsim_g3_1 num_instances 0
261fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200262
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200263api_get_service_ids 200
264
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200265mr_equal requests_submitted 0
266
267check_policy_agent_logs
268check_control_panel_logs
269
270#### TEST COMPLETE ####
271
272store_logs END
273
274print_result
275
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100276auto_clean_environment