Fix MAX_TIMEOUT value for listener

In the database, timeout_client_data, timeout_member_connect,
timeout_member_data, timeout_tcp_inspect have an integer type with
a maximum size of 2147483647. Now MAX_TIMEOUT in API does not exceed
this value and is equal to 24 days (2073600000 seconds).

Story: 2009193
Task: 43248
Change-Id: I990b6af1ff880b25e54f6c41ae0c966007f3f098
This commit is contained in:
Roman Goncharov 2021-09-09 18:04:12 +03:00
parent 69d975d623
commit 3a8f056306
No known key found for this signature in database
GPG Key ID: 0FB2AEA5EED23384
3 changed files with 23 additions and 12 deletions

View File

@ -232,8 +232,8 @@ DEFAULT_MAX_RETRIES_DOWN = 3
MIN_HM_RETRIES = 1 MIN_HM_RETRIES = 1
MAX_HM_RETRIES = 10 MAX_HM_RETRIES = 10
# 1 year: y d h m ms # 24 days: days d h m ms
MAX_TIMEOUT = 365 * 24 * 60 * 60 * 1000 MAX_TIMEOUT = 24 * 24 * 60 * 60 * 1000
MIN_TIMEOUT = 0 MIN_TIMEOUT = 0
DEFAULT_TIMEOUT_CLIENT_DATA = 50000 DEFAULT_TIMEOUT_CLIENT_DATA = 50000

View File

@ -683,14 +683,18 @@ class TestListener(base.BaseAPITest):
def test_create_with_timeouts_too_high(self): def test_create_with_timeouts_too_high(self):
optionals = { optionals = {
'timeout_client_data': 1, 'timeout_client_data': 1,
'timeout_member_connect': 2, 'timeout_member_connect': 1,
'timeout_member_data': 3, 'timeout_member_data': 1,
'timeout_tcp_inspect': constants.MAX_TIMEOUT + 1, 'timeout_tcp_inspect': 1,
} }
for field in optionals.items():
optionals.update({field[0]: constants.MAX_TIMEOUT + 1})
resp = self.test_create(response_status=400, **optionals).json resp = self.test_create(response_status=400, **optionals).json
optionals.update({field[0]: 1})
fault = resp.get('faultstring') fault = resp.get('faultstring')
self.assertIn( self.assertIn(
'Invalid input for field/attribute timeout_tcp_inspect', fault) 'Invalid input for field/attribute {0}'.format(
field[0]), fault)
self.assertIn( self.assertIn(
'Value should be lower or equal to {0}'.format( 'Value should be lower or equal to {0}'.format(
constants.MAX_TIMEOUT), fault) constants.MAX_TIMEOUT), fault)

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Fixed MAX_TIMEOUT for timeout_client_data, timeout_member_connect,
timeout_member_data, timeout_tcp_inspect API listener. The value was
reduced from 365 days to 24 days, which now does not exceed the value of
the data type in DB.