Browse Source

Fix race in test_handler_poll_session_expired

It's possible that we could test the internal request_handlers
data structure after the exception, but BEFORE it has been modified.
Just wait for it to go to zero length.

Change-Id: I364b1f347553a3f6710a516461c4f097d0276794
David Shrewsbury 2 weeks ago
parent
commit
133da674fe
1 changed files with 8 additions and 2 deletions
  1. 8
    2
      nodepool/tests/unit/test_launcher.py

+ 8
- 2
nodepool/tests/unit/test_launcher.py View File

@@ -1760,8 +1760,14 @@ class TestLauncher(tests.DBTestCase):
1760 1760
         # time through poll() should handle removing the request handler.
1761 1761
         # And our mock side effect should ensure it does not re-enter
1762 1762
         # request handling before we check it.
1763
-        self.assertEqual(0, len(
1764
-            pool._pool_threads["fake-provider-main"].request_handlers))
1763
+        for _ in iterate_timeout(10, Exception,
1764
+                                 'request_handlers to reach zero count'):
1765
+            try:
1766
+                self.assertEqual(0, len(
1767
+                    pool._pool_threads["fake-provider-main"].request_handlers))
1768
+                break
1769
+            except AssertionError:
1770
+                pass
1765 1771
 
1766 1772
     def test_exception_causing_decline_of_paused_request(self):
1767 1773
         """

Loading…
Cancel
Save