From f23458c16ce41489f4982e30975afdc4c41c2296 Mon Sep 17 00:00:00 2001 From: Tom Barron Date: Thu, 21 Jan 2016 11:56:14 -0500 Subject: [PATCH] Fix sluggish rbd unit tests The rbd_test.py module tests methods decorated by utils.retry, which does retries with exponential backoffs, without mocking out time.sleep(). This commit mocks time.sleep(), yielding a 3x speedup, as documented in the accompanying bug. Closes-Bug: #1536717 Change-Id: I414629f09f397e44d3a5be794ef83658a4c1eec0 --- cinder/tests/unit/test_rbd.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cinder/tests/unit/test_rbd.py b/cinder/tests/unit/test_rbd.py index a6583e4c1..bce0cb3c0 100644 --- a/cinder/tests/unit/test_rbd.py +++ b/cinder/tests/unit/test_rbd.py @@ -68,16 +68,18 @@ def common_mocks(f): mocks that can't/don't get unset. """ def _common_inner_inner1(inst, *args, **kwargs): + @mock.patch('time.sleep') @mock.patch('cinder.volume.drivers.rbd.RBDVolumeProxy') @mock.patch('cinder.volume.drivers.rbd.RADOSClient') @mock.patch('cinder.backup.drivers.ceph.rbd') @mock.patch('cinder.backup.drivers.ceph.rados') def _common_inner_inner2(mock_rados, mock_rbd, mock_client, - mock_proxy): + mock_proxy, mock_sleep): inst.mock_rbd = mock_rbd inst.mock_rados = mock_rados inst.mock_client = mock_client inst.mock_proxy = mock_proxy + inst.mock_sleep = mock_sleep inst.mock_rbd.RBD.Error = Exception inst.mock_rados.Error = Exception inst.mock_rbd.ImageBusy = MockImageBusyException -- 2.45.2