]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix torpid coordinator unit tests
authorTom Barron <tpb@dyncloud.net>
Thu, 21 Jan 2016 18:17:59 +0000 (13:17 -0500)
committerTom Barron <tpb@dyncloud.net>
Fri, 22 Jan 2016 11:21:48 +0000 (06:21 -0500)
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

index 7d31e51917d26383def510142431d26def5fc55c..04b7ed10ead62ea8ec950b41f299c97ebd1d9208 100644 (file)
@@ -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