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
(cherry picked from commit 3a8f056306)
This commit is contained in:
Roman Goncharov 2021-09-09 18:04:12 +03:00
parent f16f72cca2
commit 4dbca7887e
3 changed files with 23 additions and 12 deletions

View File

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

View File

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

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.