Merge "Add "delay" value determination for health monitor"
This commit is contained in:
commit
8adc8731d1
@ -146,6 +146,17 @@ def _validate_connection_limit(data, min_value=lb_const.MIN_CONNECT_VALUE):
|
||||
|
||||
validators.validators['type:connection_limit'] = _validate_connection_limit
|
||||
|
||||
|
||||
def _validate_db_limit(data, max_value=db_const.DB_INTEGER_MAX_VALUE):
|
||||
if int(data) > max_value:
|
||||
msg = (_("'%(data)s' is not a valid value, "
|
||||
"because it is more than %(max_value)s") %
|
||||
{'data': data, 'max_value': max_value})
|
||||
LOG.debug(msg)
|
||||
return msg
|
||||
|
||||
validators.validators['type:db_out_of_bounds'] = _validate_db_limit
|
||||
|
||||
RESOURCE_ATTRIBUTE_MAP = {
|
||||
'loadbalancers': {
|
||||
'id': {'allow_post': False, 'allow_put': False,
|
||||
@ -318,7 +329,10 @@ RESOURCE_ATTRIBUTE_MAP = {
|
||||
'type:values': lb_const.SUPPORTED_HEALTH_MONITOR_TYPES},
|
||||
'is_visible': True},
|
||||
'delay': {'allow_post': True, 'allow_put': True,
|
||||
'validate': {'type:non_negative': None},
|
||||
'validate': {
|
||||
'type:db_out_of_bounds':
|
||||
db_const.DB_INTEGER_MAX_VALUE,
|
||||
'type:non_negative': None},
|
||||
'convert_to': converters.convert_to_int,
|
||||
'is_visible': True},
|
||||
'timeout': {'allow_post': True, 'allow_put': True,
|
||||
|
@ -629,6 +629,26 @@ class TestLoadBalancerExtensionV2TestCase(base.ExtensionTestCase):
|
||||
self.assertIn('healthmonitor', res)
|
||||
self.assertEqual(return_value, res['healthmonitor'])
|
||||
|
||||
def test_health_monitor_create_with_db_limit_more_than_max_value(self):
|
||||
project_id = _uuid()
|
||||
data = {'healthmonitor': {'type': 'HTTP',
|
||||
'delay': 3000000000000,
|
||||
'timeout': 1,
|
||||
'max_retries': 3,
|
||||
'http_method': 'GET',
|
||||
'url_path': '/path',
|
||||
'expected_codes': '200-300',
|
||||
'admin_state_up': True,
|
||||
'tenant_id': project_id,
|
||||
'project_id': project_id,
|
||||
'pool_id': _uuid(),
|
||||
'name': 'monitor1'}}
|
||||
res = self.api.post(_get_path('lbaas/healthmonitors', fmt=self.fmt),
|
||||
self.serialize(data),
|
||||
content_type='application/%s' % self.fmt,
|
||||
expect_errors=True)
|
||||
self.assertEqual(exc.HTTPBadRequest.code, res.status_int)
|
||||
|
||||
def test_health_monitor_create_with_timeout_negative(self):
|
||||
project_id = _uuid()
|
||||
data = {'healthmonitor': {'type': 'HTTP',
|
||||
@ -691,6 +711,16 @@ class TestLoadBalancerExtensionV2TestCase(base.ExtensionTestCase):
|
||||
self.assertIn('healthmonitor', res)
|
||||
self.assertEqual(return_value, res['healthmonitor'])
|
||||
|
||||
def test_health_monitor_update_with_db_limit_more_than_max_value(self):
|
||||
health_monitor_id = _uuid()
|
||||
update_data = {'healthmonitor': {'delay': 3000000000000}}
|
||||
res = self.api.put(_get_path('lbaas/healthmonitors',
|
||||
id=health_monitor_id,
|
||||
fmt=self.fmt),
|
||||
self.serialize(update_data),
|
||||
expect_errors=True)
|
||||
self.assertEqual(exc.HTTPBadRequest.code, res.status_int)
|
||||
|
||||
def test_health_monitor_get(self):
|
||||
health_monitor_id = _uuid()
|
||||
return_value = {'type': 'HTTP',
|
||||
|
Loading…
Reference in New Issue
Block a user