From e2faa7c523ed220abfafbabb710d0ec11a21883f Mon Sep 17 00:00:00 2001 From: Tom Barron Date: Thu, 21 Jan 2016 13:17:59 -0500 Subject: [PATCH] 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 --- cinder/tests/unit/test_coordination.py | 1 + 1 file changed, 1 insertion(+) 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 -- 2.45.2