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
This commit is contained in:
parent
c51d20f56c
commit
a850fda322
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue