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