blob: 50e3f370a30ef665006262f79056ff0557f9b9cb [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
BjornMagnussonXAf38e1e82020-10-11 23:05:02 +020023#App names to include in the test, space separated list
24INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM"
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020025
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010026#SUPPORTED TEST ENV FILE
BjornMagnussonXA89b64ab2020-12-16 09:21:01 +010027SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN"
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010028
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020029. ../common/testcase_common.sh $@
30. ../common/agent_api_functions.sh
31. ../common/ricsimulator_api_functions.sh
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010032. ../common/cr_api_functions.sh
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020033
BjornMagnussonXAad047782020-06-08 15:54:11 +020034generate_uuid
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020035
BjornMagnussonXA496156d2020-08-10 14:16:24 +020036use_cr_http
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020037use_simulator_http
38use_mr_http
39use_agent_rest_http
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020040
41
42#### TEST BEGIN ####
43
44clean_containers
45
46start_ric_simulators ricsim_g1 1 OSC_2.1.0
BjornMagnussonXA4207b832020-11-03 09:52:49 +010047start_ric_simulators ricsim_g2 1 STD_1.1.3
48if [ "$PMS_VERSION" == "V2" ]; then
49 start_ric_simulators ricsim_g3 1 STD_2.0.0
50fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020051
52start_mr
53
54start_cr
55
56start_consul_cbs
57
58prepare_consul_config NOSDNC ".consul_config.json"
59consul_config_app ".consul_config.json"
60
61start_control_panel
62
63start_policy_agent
64
65set_agent_debug
66
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020067mr_equal requests_submitted 0
68
69#Check agent alive
70api_get_status 200
71
72#Print simulator interface version
73sim_print ricsim_g1_1 interface
BjornMagnussonXA4207b832020-11-03 09:52:49 +010074sim_print ricsim_g2_1 interface
75if [ "$PMS_VERSION" == "V2" ]; then
76 sim_print ricsim_g3_1 interface
77fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020078
79api_put_service 201 "service1" 15 "$CR_PATH/service1"
80
81api_get_services 200 "service1" "service1" 15 "$CR_PATH/service1"
82
83api_put_service 201 "service2" 120 "$CR_PATH/service2"
84
85api_get_services 200 "service2" "service2" 120 "$CR_PATH/service2"
86
87api_put_service 200 "service1" 50 "$CR_PATH/service1"
88api_put_service 200 "service2" 180 "$CR_PATH/service2"
89
90api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1"
91api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
92
93api_get_service_ids 200 "service1" "service2"
94
95sleep_wait 30 "Waiting for keep alive timeout"
96
97api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1"
98api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
99
100sleep_wait 100 "Waiting for keep alive timeout"
101
102api_get_services 404 "service1"
103api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
104
105api_delete_services 204 "service2"
106
107api_get_services 404 "service1"
108api_get_services 404 "service2"
109
110api_put_service 201 "service3" 60 "$CR_PATH/service3"
111
112api_get_services 200 "service3" "service3" 60 "$CR_PATH/service3"
113
114sleep_wait 30 "Waiting for keep alive timeout"
115
116api_put_service 200 "service3" 60 "$CR_PATH/service3"
117
118sleep_wait 100 "Waiting for keep alive timeout"
119
120api_get_services 404 "service3"
121
122api_put_service 201 "service4" 120 "$CR_PATH/service4"
123
124sleep_wait 60 "Waiting for keep alive timeout"
125
126api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4"
127
128api_put_services_keepalive 200 "service4"
129
130sleep_wait 90 "Waiting for keep alive timeout"
131
132api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4"
133
134api_delete_services 204 "service4"
135
136api_get_services 404 "service4"
137
138api_get_services 404 "service1"
139api_get_services 404 "service2"
140api_get_services 404 "service3"
141
142api_get_service_ids 200
143
144api_delete_services 404 "service1"
145api_delete_services 404 "service2"
146api_delete_services 404 "service3"
147api_delete_services 404 "service4"
148
149api_put_services_keepalive 404 "service1"
150api_put_services_keepalive 404 "service2"
151api_put_services_keepalive 404 "service3"
152api_put_services_keepalive 404 "service4"
153
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200154# Policy delete after timeout
155api_put_service 201 "service10" 600 "$CR_PATH/service10"
156
157sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
158
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100159if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100160
161 sim_put_policy_type 201 ricsim_g3_1 STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
162
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100163 api_equal json:rics 3 60
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200164
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100165 #api_equal json:policy_schemas 2 120
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200166
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100167 api_equal json:policy-types 3 120
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200168
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100169 api_equal json:policies 0
170else
171 api_equal json:rics 2 60
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200172
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100173 api_equal json:policy_schemas 2 120
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200174
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100175 api_equal json:policy_types 2
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200176
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100177 api_equal json:policies 0
178fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200179
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100180if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100181 notificationurl=$CR_PATH"/test"
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100182else
183 notificationurl=""
184fi
185
186api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
187api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200188
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100189if [ "$PMS_VERSION" == "V2" ]; then
190 api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
191 api_equal json:policies 3
192else
193 api_equal json:policies 2
194fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200195
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100196sim_equal ricsim_g1_1 num_instances 1
197sim_equal ricsim_g2_1 num_instances 1
198
199api_put_policy 201 "service10" ricsim_g1_1 1 5001 true $notificationurl testdata/OSC/pi1_template.json
200api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5101 true $notificationurl testdata/STD/pi1_template.json
201
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100202if [ "$PMS_VERSION" == "V2" ]; then
203 api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5201 true $notificationurl testdata/STD2/pi_qos2_template.json
204 api_equal json:policies 6
205else
206 api_equal json:policies 4
207fi
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100208
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200209sim_equal ricsim_g1_1 num_instances 2
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100210sim_equal ricsim_g2_1 num_instances 2
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100211if [ "$PMS_VERSION" == "V2" ]; then
212 sim_equal ricsim_g3_1 num_instances 2
213fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200214
215sim_post_delete_instances 200 ricsim_g1_1
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100216sim_post_delete_instances 200 ricsim_g2_1
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200217
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100218if [ "$PMS_VERSION" == "V2" ]; then
219 sim_post_delete_instances 200 ricsim_g3_1
220fi
221
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200222#Wait for recreate of non transient policy
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100223if [ "$PMS_VERSION" == "V2" ]; then
224 api_equal json:policies 3 180
225else
226 api_equal json:policies 2 180
227fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200228
229sim_equal ricsim_g1_1 num_instances 1
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100230sim_equal ricsim_g2_1 num_instances 1
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100231if [ "$PMS_VERSION" == "V2" ]; then
232 sim_equal ricsim_g3_1 num_instances 1
233fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200234
235api_put_service 200 "service10" 10 "$CR_PATH/service10"
236
237#Wait for service expiry
238api_equal json:policies 0 120
239
240sim_equal ricsim_g1_1 num_instances 0
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100241sim_equal ricsim_g2_1 num_instances 0
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100242if [ "$PMS_VERSION" == "V2" ]; then
243 sim_equal ricsim_g3_1 num_instances 0
244fi
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200245
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200246api_get_service_ids 200
247
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200248mr_equal requests_submitted 0
249
250check_policy_agent_logs
251check_control_panel_logs
252
253#### TEST COMPLETE ####
254
255store_logs END
256
257print_result
258
259auto_clean_containers