]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
BigSwitch: Fix rest call in consistency watchdog
authorKevin Benton <blak111@gmail.com>
Fri, 7 Mar 2014 18:50:16 +0000 (10:50 -0800)
committerKevin Benton <blak111@gmail.com>
Fri, 7 Mar 2014 18:52:44 +0000 (10:52 -0800)
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

neutron/plugins/bigswitch/servermanager.py
neutron/tests/unit/bigswitch/test_servermanager.py

index 2ef0da162f38ff34bce0b87fc3283129dcc832d7..e482466eda6ca20ad14b35da11af4dbd4ab32864 100644 (file)
@@ -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):
index 569a98bf21650d52a04a0f8770c1d97622021765..f7dc48116d75d69c7db02be1ef3ad89ccc06b76d 100644 (file)
@@ -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)