From: Tom Barron Date: Thu, 21 Jan 2016 18:17:59 +0000 (-0500) Subject: Fix torpid coordinator unit tests X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=e2faa7c523ed220abfafbabb710d0ec11a21883f;p=openstack-build%2Fcinder-build.git Fix torpid coordinator unit tests The test_coordination.py unit module tests a _reconnect() method which does a randomly seeded exponential retry backoff. This retry/backoff mechanism introduces needless delay in unit test runs. This commit mocks out random.uniform, improving run time by about a factor of nine, as documented in the accompanying bug. Closes-Bug: #1536750 Change-Id: I83fafba17be99cbe972dfb60fe87dac6dc3756cf --- diff --git a/cinder/tests/unit/test_coordination.py b/cinder/tests/unit/test_coordination.py index 7d31e5191..04b7ed10e 100644 --- a/cinder/tests/unit/test_coordination.py +++ b/cinder/tests/unit/test_coordination.py @@ -46,6 +46,7 @@ class MockToozLock(tooz.locking.Lock): @mock.patch('eventlet.tpool.execute', lambda f: f()) @mock.patch.object(coordination.Coordinator, 'heartbeat') @mock.patch('tooz.coordination.get_coordinator') +@mock.patch('random.uniform', lambda _a, _b: 0) class CoordinatorTestCase(test.TestCase): def test_coordinator_start(self, get_coordinator, heartbeat): crd = get_coordinator.return_value