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