diff --git a/neutron/plugins/bigswitch/servermanager.py b/neutron/plugins/bigswitch/servermanager.py index 2ef0da162f..e482466eda 100644 --- a/neutron/plugins/bigswitch/servermanager.py +++ b/neutron/plugins/bigswitch/servermanager.py @@ -552,7 +552,7 @@ class ServerPool(object): # doesn't match, the backend will return a synchronization error # that will be handled by the rest_call. time.sleep(polling_interval) - self.servers.rest_call('GET', HEALTH_PATH) + self.rest_call('GET', HEALTH_PATH) class HTTPSConnectionWithValidation(httplib.HTTPSConnection): diff --git a/neutron/tests/unit/bigswitch/test_servermanager.py b/neutron/tests/unit/bigswitch/test_servermanager.py index 569a98bf21..f7dc48116d 100644 --- a/neutron/tests/unit/bigswitch/test_servermanager.py +++ b/neutron/tests/unit/bigswitch/test_servermanager.py @@ -14,6 +14,7 @@ # # @author: Kevin Benton, kevin.benton@bigswitch.com # +from contextlib import nested import mock from oslo.config import cfg @@ -21,6 +22,8 @@ from neutron.manager import NeutronManager from neutron.plugins.bigswitch import servermanager from neutron.tests.unit.bigswitch import test_restproxy_plugin as test_rp +SERVERMANAGER = 'neutron.plugins.bigswitch.servermanager' + class ServerManagerTests(test_rp.BigSwitchProxyPluginV2TestCase): @@ -45,3 +48,23 @@ class ServerManagerTests(test_rp.BigSwitchProxyPluginV2TestCase): *('example.org', 443) ) sslgetmock.assert_has_calls([mock.call(('example.org', 443))]) + + def test_consistency_watchdog(self): + pl = NeutronManager.get_plugin() + pl.servers.capabilities = [] + self.watch_p.stop() + with nested( + mock.patch('time.sleep'), + mock.patch( + SERVERMANAGER + '.ServerPool.rest_call', + side_effect=servermanager.RemoteRestError( + reason='Failure to break loop' + ) + ) + ) as (smock, rmock): + # should return immediately without consistency capability + pl.servers._consistency_watchdog() + self.assertFalse(smock.called) + pl.servers.capabilities = ['consistency'] + self.assertRaises(servermanager.RemoteRestError, + pl.servers._consistency_watchdog)