Merge "Pool Manager Throws An Error When No Servers are Defined"

This commit is contained in:
Jenkins 2015-01-19 23:41:48 +00:00 committed by Gerrit Code Review
commit c5ec416b7a
3 changed files with 18 additions and 0 deletions

View File

@ -73,6 +73,11 @@ class NoServersConfigured(ConfigurationError):
error_type = 'no_servers_configured' error_type = 'no_servers_configured'
class NoPoolServersConfigured(ConfigurationError):
error_code = 500
error_type = 'no_pool_servers_configured'
class OverQuota(Base): class OverQuota(Base):
error_code = 413 error_code = 413
error_type = 'over_quota' error_type = 'over_quota'

View File

@ -121,6 +121,9 @@ class Service(service.RPCService):
} }
self.server_backends.append(server_backend) self.server_backends.append(server_backend)
if not self.server_backends:
raise exceptions.NoPoolServersConfigured()
self.enable_recovery_timer = \ self.enable_recovery_timer = \
cfg.CONF['service:pool_manager'].enable_recovery_timer cfg.CONF['service:pool_manager'].enable_recovery_timer
self.enable_sync_timer = \ self.enable_sync_timer = \

View File

@ -67,6 +67,16 @@ class PoolManagerServiceTest(PoolManagerTestCase):
# NOTE: Start is already done by the fixture in start_service() # NOTE: Start is already done by the fixture in start_service()
self.service.stop() self.service.stop()
def test_no_pool_servers_configured(self):
self.service.stop()
self.config(
server_ids=[],
group='backend:fake'
)
with testtools.ExpectedException(exceptions.NoPoolServersConfigured):
self.start_service('pool_manager')
@patch.object(mdns_rpcapi.MdnsAPI, 'poll_for_serial_number') @patch.object(mdns_rpcapi.MdnsAPI, 'poll_for_serial_number')
@patch.object(mdns_rpcapi.MdnsAPI, 'notify_zone_changed') @patch.object(mdns_rpcapi.MdnsAPI, 'notify_zone_changed')
def test_create_domain(self, mock_notify_zone_changed, def test_create_domain(self, mock_notify_zone_changed,