blob: d6894b508b3908ae8ecf92a410c14079a2f5c743 [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
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020023#App names to exclude checking pulling images for, space separated list
24EXCLUDED_IMAGES="SDMC SDNC_ONAP"
25
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020026. ../common/testcase_common.sh $@
27. ../common/agent_api_functions.sh
28. ../common/ricsimulator_api_functions.sh
29
BjornMagnussonXAad047782020-06-08 15:54:11 +020030generate_uuid
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020031
32#Local vars in test script
33##########################
34# Path to callback receiver
35CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
BjornMagnussonXA496156d2020-08-10 14:16:24 +020036use_cr_http
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020037
38
39#### TEST BEGIN ####
40
41clean_containers
42
43start_ric_simulators ricsim_g1 1 OSC_2.1.0
44
45start_mr
46
47start_cr
48
49start_consul_cbs
50
51prepare_consul_config NOSDNC ".consul_config.json"
52consul_config_app ".consul_config.json"
53
54start_control_panel
55
56start_policy_agent
57
58set_agent_debug
59
60use_agent_rest_http
61
62#Verify no callbacks or dmaap messages has been sent
63cr_equal received_callbacks 0
64mr_equal requests_submitted 0
65
66#Check agent alive
67api_get_status 200
68
69#Print simulator interface version
70sim_print ricsim_g1_1 interface
71
72api_put_service 201 "service1" 15 "$CR_PATH/service1"
73
74api_get_services 200 "service1" "service1" 15 "$CR_PATH/service1"
75
76api_put_service 201 "service2" 120 "$CR_PATH/service2"
77
78api_get_services 200 "service2" "service2" 120 "$CR_PATH/service2"
79
80api_put_service 200 "service1" 50 "$CR_PATH/service1"
81api_put_service 200 "service2" 180 "$CR_PATH/service2"
82
83api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1"
84api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
85
86api_get_service_ids 200 "service1" "service2"
87
88sleep_wait 30 "Waiting for keep alive timeout"
89
90api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1"
91api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
92
93sleep_wait 100 "Waiting for keep alive timeout"
94
95api_get_services 404 "service1"
96api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
97
98api_delete_services 204 "service2"
99
100api_get_services 404 "service1"
101api_get_services 404 "service2"
102
103api_put_service 201 "service3" 60 "$CR_PATH/service3"
104
105api_get_services 200 "service3" "service3" 60 "$CR_PATH/service3"
106
107sleep_wait 30 "Waiting for keep alive timeout"
108
109api_put_service 200 "service3" 60 "$CR_PATH/service3"
110
111sleep_wait 100 "Waiting for keep alive timeout"
112
113api_get_services 404 "service3"
114
115api_put_service 201 "service4" 120 "$CR_PATH/service4"
116
117sleep_wait 60 "Waiting for keep alive timeout"
118
119api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4"
120
121api_put_services_keepalive 200 "service4"
122
123sleep_wait 90 "Waiting for keep alive timeout"
124
125api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4"
126
127api_delete_services 204 "service4"
128
129api_get_services 404 "service4"
130
131api_get_services 404 "service1"
132api_get_services 404 "service2"
133api_get_services 404 "service3"
134
135api_get_service_ids 200
136
137api_delete_services 404 "service1"
138api_delete_services 404 "service2"
139api_delete_services 404 "service3"
140api_delete_services 404 "service4"
141
142api_put_services_keepalive 404 "service1"
143api_put_services_keepalive 404 "service2"
144api_put_services_keepalive 404 "service3"
145api_put_services_keepalive 404 "service4"
146
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200147# Policy delete after timeout
148api_put_service 201 "service10" 600 "$CR_PATH/service10"
149
150sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
151
152api_equal json:rics 1 60
153
154api_equal json:policy_schemas 1 120
155
156api_equal json:policy_types 1
157
158api_equal json:policies 0
159
160api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json
161
162api_equal json:policies 1
163
164sim_equal ricsim_g1_1 num_instances 1
165
166api_put_policy 201 "service10" ricsim_g1_1 1 5001 true testdata/OSC/pi1_template.json
167
168api_equal json:policies 2
169
170sim_equal ricsim_g1_1 num_instances 2
171
172sim_post_delete_instances 200 ricsim_g1_1
173
174#Wait for recreate of non transient policy
175api_equal json:policies 1 180
176
177sim_equal ricsim_g1_1 num_instances 1
178
179api_put_service 200 "service10" 10 "$CR_PATH/service10"
180
181#Wait for service expiry
182api_equal json:policies 0 120
183
184sim_equal ricsim_g1_1 num_instances 0
185
186
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200187api_get_service_ids 200
188
189deviation "TR18 Agents sends callback with empty body"
190cr_equal received_callbacks 0
191mr_equal requests_submitted 0
192
193check_policy_agent_logs
194check_control_panel_logs
195
196#### TEST COMPLETE ####
197
198store_logs END
199
200print_result
201
202auto_clean_containers