From a850fda322649317786bb9f36eb8af05708f0210 Mon Sep 17 00:00:00 2001 From: Ben Nemec Date: Thu, 30 Aug 2018 22:26:33 +0000 Subject: [PATCH] Stop asserting on Eventlet internals Eventlet has used at least three different clock implementations by default over the past couple of years (time.time, vendored monotonic, and plain monotonic). Since we're forcing use of monotonic anyway, this is all irrelevant to us outside of the fact that once we depend on a new enough version of eventlet we can remove our monkey patching of the hub. Asserting on the particular module that eventlet uses by default is just breaking our unit tests on newer eventlet for no good reason. Change-Id: I0f5135567a16dde4c34cee35baa2054091dce728 Partial-Bug: 1788959 --- oslo_service/__init__.py | 2 ++ oslo_service/tests/test_loopingcall.py | 39 -------------------------- 2 files changed, 2 insertions(+), 39 deletions(-) diff --git a/oslo_service/__init__.py b/oslo_service/__init__.py index 9ed1f4d0..2da3fca7 100644 --- a/oslo_service/__init__.py +++ b/oslo_service/__init__.py @@ -21,6 +21,8 @@ time = eventlet.patcher.original('time') LOG = logging.getLogger(__name__) +# TODO(bnemec): When we have a minimum dependency on a version of eventlet +# that uses monotonic by default, remove this monkey patching. if hasattr(time, 'monotonic'): # Use builtin monotonic clock, Python 3.3+ _monotonic = time.monotonic diff --git a/oslo_service/tests/test_loopingcall.py b/oslo_service/tests/test_loopingcall.py index 67f974fe..54402fea 100644 --- a/oslo_service/tests/test_loopingcall.py +++ b/oslo_service/tests/test_loopingcall.py @@ -53,45 +53,6 @@ class LoopingCallTestCase(test_base.BaseTestCase): self.assertEqual(oslo_service._monotonic, hub.clock) - def test_eventlet_use_hub_override(self): - ns = {} - - def task(): - try: - self._test_eventlet_use_hub_override() - except Exception as exc: - ns['result'] = exc - else: - ns['result'] = 'ok' - - # test overriding the hub of in a new thread to not modify the hub - # of the main thread - thread = threading.Thread(target=task) - thread.start() - thread.join() - self.assertEqual('ok', ns['result']) - - def _test_eventlet_use_hub_override(self): - # Make sure that by default the - # oslo_service.service_hub() kicks in - old_clock = eventlet.hubs.get_hub().clock - self.assertEqual(oslo_service._monotonic, - old_clock) - - # eventlet will use time.monotonic() by default, same clock than - # oslo.service_hub(): - # https://github.com/eventlet/eventlet/pull/303 - if not hasattr(time, 'monotonic'): - # If anyone wants to override it - try: - eventlet.hubs.use_hub('poll') - except Exception: - eventlet.hubs.use_hub('selects') - - # then we get a new clock and the override works fine too! - clock = eventlet.hubs.get_hub().clock - self.assertNotEqual(old_clock, clock) - def test_return_false(self): def _raise_it(): raise loopingcall.LoopingCallDone(False)