summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Fried <efried@us.ibm.com>2018-11-07 17:12:57 -0600
committerEric Fried <efried@us.ibm.com>2018-11-07 17:21:43 -0600
commitd9855f0ec49f7a9471d75880ee34420c12158383 (patch)
tree508874838e857566d5060a705ce925d02da2f12d
parentb85d9353fb3b41409f90df91154f87616b4ca61e (diff)
Use SleepFixture in looping call test suite
A recent change [1] created a SleepFixture tailored for consumers of the loopingcall module to be able to avoid incurring real sleeps while testing. This patch makes use of the fixture in a couple of previously-long-running tests in test_loopingcall. NB: We carefully use the fixture only in specific test cases rather than over the entire test class because tests in this module may (now and in the future) be testing things below the mock. ======= BEFORE: ======= ====== Totals ====== Ran: 31 tests in 13.0000 sec. - Passed: 31 - Skipped: 0 - Expected Fail: 0 - Unexpected Success: 0 - Failed: 0 Sum of execute time for each test: 14.4619 sec. ============== Worker Balance ============== - Worker 0 (1 tests) => 0:00:00.306611 - Worker 1 (1 tests) => 0:00:00.036168 - Worker 2 (1 tests) => 0:00:00.029992 - Worker 3 (4 tests) => 0:00:00.007588 - Worker 4 (5 tests) => 0:00:00.019243 - Worker 5 (6 tests) => 0:00:00.017683 - Worker 6 (7 tests) => 0:00:12.036425 - Worker 7 (6 tests) => 0:00:02.019783 Test id Runtime (s) ----------------------------------------------------------------------------------------------- ----------- oslo_service.tests.test_loopingcall.DynamicLoopingCallTestCase.test_repeat 12.019 oslo_service.tests.test_loopingcall.LoopingCallTestCase.test_do_not_stop_on_exception 1.005 oslo_service.tests.test_loopingcall.LoopingCallTestCase.test_repeat 1.004 oslo_service.tests.test_loopingcall.LoopingCallTestCase.test_looping_call_timed_out 0.307 oslo_service.tests.test_loopingcall.RetryDecoratorTest.test_retry_with_expected_exceptions 0.036 oslo_service.tests.test_loopingcall.LoopingCallTestCase.test_interval_adjustment 0.030 oslo_service.tests.test_loopingcall.DynamicLoopingCallTestCase.test_do_not_stop_on_exception 0.007 oslo_service.tests.test_loopingcall.TestBackOffLoopingCall.test_exponential_backoff 0.005 oslo_service.tests.test_loopingcall.DynamicLoopingCallTestCase.test_no_double_start 0.005 oslo_service.tests.test_loopingcall.DynamicLoopingCallTestCase.test_timeout_task_without_return 0.005 _____________________________________________________________________ summary _____________________________________________________________________ ====== AFTER: ====== ====== Totals ====== Ran: 31 tests in 1.0000 sec. - Passed: 31 - Skipped: 0 - Expected Fail: 0 - Unexpected Success: 0 - Failed: 0 Sum of execute time for each test: 0.4553 sec. ============== Worker Balance ============== - Worker 0 (1 tests) => 0:00:00.005381 - Worker 1 (1 tests) => 0:00:00.006639 - Worker 2 (1 tests) => 0:00:00.005145 - Worker 3 (1 tests) => 0:00:00.308991 - Worker 4 (1 tests) => 0:00:00.037721 - Worker 5 (2 tests) => 0:00:00.031293 - Worker 6 (12 tests) => 0:00:00.034781 - Worker 7 (12 tests) => 0:00:00.031908 Test id Runtime (s) -------------------------------------------------------------------------------------------------- ----------- oslo_service.tests.test_loopingcall.LoopingCallTestCase.test_looping_call_timed_out 0.309 oslo_service.tests.test_loopingcall.RetryDecoratorTest.test_retry_with_expected_exceptions 0.038 oslo_service.tests.test_loopingcall.LoopingCallTestCase.test_interval_adjustment 0.028 oslo_service.tests.test_loopingcall.DynamicLoopingCallTestCase.test_initial_delay 0.013 oslo_service.tests.test_loopingcall.LoopingCallTestCase.test_do_not_stop_on_exception 0.007 oslo_service.tests.test_loopingcall.DynamicLoopingCallTestCase.test_do_not_stop_on_exception 0.007 oslo_service.tests.test_loopingcall.DynamicLoopingCallTestCase.test_repeat 0.005 oslo_service.tests.test_loopingcall.TestBackOffLoopingCall.test_exponential_backoff_negative_value 0.005 oslo_service.tests.test_loopingcall.LoopingCallTestCase.test_repeat 0.005 oslo_service.tests.test_loopingcall.RetryDecoratorTest.test_retry_with_max_retries 0.004 _____________________________________________________________________ summary _____________________________________________________________________ [1] I0089c7778957456db66599abffaaad3a5332243c Change-Id: I7035abef8d089c9d4cf664daee0af0fde5a6e19c
Notes
Notes (review): Code-Review+2: Zane Bitter <zbitter@redhat.com> Code-Review+2: Ben Nemec <openstack@nemebean.com> Workflow+1: Ben Nemec <openstack@nemebean.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 05 Dec 2018 02:25:24 +0000 Reviewed-on: https://review.openstack.org/616373 Project: openstack/oslo.service Branch: refs/heads/master
-rw-r--r--oslo_service/tests/test_loopingcall.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/oslo_service/tests/test_loopingcall.py b/oslo_service/tests/test_loopingcall.py
index 35d05a1..bf55a16 100644
--- a/oslo_service/tests/test_loopingcall.py
+++ b/oslo_service/tests/test_loopingcall.py
@@ -18,6 +18,7 @@ import mock
18from oslotest import base as test_base 18from oslotest import base as test_base
19 19
20import oslo_service 20import oslo_service
21from oslo_service import fixture
21from oslo_service import loopingcall 22from oslo_service import loopingcall
22 23
23 24
@@ -72,6 +73,7 @@ class LoopingCallTestCase(test_base.BaseTestCase):
72 raise RuntimeError() 73 raise RuntimeError()
73 74
74 def test_do_not_stop_on_exception(self): 75 def test_do_not_stop_on_exception(self):
76 self.useFixture(fixture.SleepFixture())
75 self.num_runs = 2 77 self.num_runs = 2
76 78
77 timer = loopingcall.FixedIntervalLoopingCall(self._raise_and_then_done) 79 timer = loopingcall.FixedIntervalLoopingCall(self._raise_and_then_done)
@@ -111,6 +113,7 @@ class LoopingCallTestCase(test_base.BaseTestCase):
111 timer.stop() 113 timer.stop()
112 114
113 def test_repeat(self): 115 def test_repeat(self):
116 self.useFixture(fixture.SleepFixture())
114 self.num_runs = 2 117 self.num_runs = 2
115 118
116 timer = loopingcall.FixedIntervalLoopingCall(self._wait_for_zero) 119 timer = loopingcall.FixedIntervalLoopingCall(self._wait_for_zero)
@@ -218,6 +221,7 @@ class DynamicLoopingCallTestCase(test_base.BaseTestCase):
218 raise RuntimeError() 221 raise RuntimeError()
219 222
220 def test_do_not_stop_on_exception(self): 223 def test_do_not_stop_on_exception(self):
224 self.useFixture(fixture.SleepFixture())
221 self.num_runs = 2 225 self.num_runs = 2
222 226
223 timer = loopingcall.DynamicLoopingCall(self._raise_and_then_done) 227 timer = loopingcall.DynamicLoopingCall(self._raise_and_then_done)
@@ -233,6 +237,7 @@ class DynamicLoopingCallTestCase(test_base.BaseTestCase):
233 return sleep_for 237 return sleep_for
234 238
235 def test_repeat(self): 239 def test_repeat(self):
240 self.useFixture(fixture.SleepFixture())
236 self.num_runs = 2 241 self.num_runs = 2
237 242
238 timer = loopingcall.DynamicLoopingCall(self._wait_for_zero) 243 timer = loopingcall.DynamicLoopingCall(self._wait_for_zero)