From: Kevin Benton Date: Fri, 7 Mar 2014 18:50:16 +0000 (-0800) Subject: BigSwitch: Fix rest call in consistency watchdog X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=caf7ecaef75f4d9eba0d85db8917be5a9118792d;p=openstack-build%2Fneutron-build.git BigSwitch: Fix rest call in consistency watchdog Fixes the rest call in the consistency watchdog in the BigSwitch plugin that was causing it to raise an exception. Closes-Bug: #1289138 Change-Id: Id4dff993426573be6984eb1e8f6ef2aabfff0779 --- diff --git a/neutron/plugins/bigswitch/servermanager.py b/neutron/plugins/bigswitch/servermanager.py index 2ef0da162..e482466ed 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 569a98bf2..f7dc48116 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)