Browse Source

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
Ben Nemec 7 months ago
parent
commit
a850fda322
2 changed files with 2 additions and 39 deletions
  1. 2
    0
      oslo_service/__init__.py
  2. 0
    39
      oslo_service/tests/test_loopingcall.py

+ 2
- 0
oslo_service/__init__.py View File

@@ -21,6 +21,8 @@ time = eventlet.patcher.original('time')
21 21
 
22 22
 LOG = logging.getLogger(__name__)
23 23
 
24
+# TODO(bnemec): When we have a minimum dependency on a version of eventlet
25
+# that uses monotonic by default, remove this monkey patching.
24 26
 if hasattr(time, 'monotonic'):
25 27
     # Use builtin monotonic clock, Python 3.3+
26 28
     _monotonic = time.monotonic

+ 0
- 39
oslo_service/tests/test_loopingcall.py View File

@@ -53,45 +53,6 @@ class LoopingCallTestCase(test_base.BaseTestCase):
53 53
         self.assertEqual(oslo_service._monotonic,
54 54
                          hub.clock)
55 55
 
56
-    def test_eventlet_use_hub_override(self):
57
-        ns = {}
58
-
59
-        def task():
60
-            try:
61
-                self._test_eventlet_use_hub_override()
62
-            except Exception as exc:
63
-                ns['result'] = exc
64
-            else:
65
-                ns['result'] = 'ok'
66
-
67
-        # test overriding the hub of in a new thread to not modify the hub
68
-        # of the main thread
69
-        thread = threading.Thread(target=task)
70
-        thread.start()
71
-        thread.join()
72
-        self.assertEqual('ok', ns['result'])
73
-
74
-    def _test_eventlet_use_hub_override(self):
75
-        # Make sure that by default the
76
-        # oslo_service.service_hub() kicks in
77
-        old_clock = eventlet.hubs.get_hub().clock
78
-        self.assertEqual(oslo_service._monotonic,
79
-                         old_clock)
80
-
81
-        # eventlet will use time.monotonic() by default, same clock than
82
-        # oslo.service_hub():
83
-        # https://github.com/eventlet/eventlet/pull/303
84
-        if not hasattr(time, 'monotonic'):
85
-            # If anyone wants to override it
86
-            try:
87
-                eventlet.hubs.use_hub('poll')
88
-            except Exception:
89
-                eventlet.hubs.use_hub('selects')
90
-
91
-            # then we get a new clock and the override works fine too!
92
-            clock = eventlet.hubs.get_hub().clock
93
-            self.assertNotEqual(old_clock, clock)
94
-
95 56
     def test_return_false(self):
96 57
         def _raise_it():
97 58
             raise loopingcall.LoopingCallDone(False)

Loading…
Cancel
Save