mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 03:36:48 +00:00
test(connection): wait for a released open instead of a fixed 0.1 s
Two tests released a hanging open and slept 0.1 s before expecting its connection; on a slow CI runner the open had not published it yet and the stored timeout error came back. They now wait until the connection is published.
This commit is contained in:
parent
cbc8b22f98
commit
69ac3134a5
1 changed files with 9 additions and 2 deletions
|
|
@ -101,6 +101,13 @@ class BoundedOpenTestCase(unittest.TestCase):
|
|||
except libvirt.libvirtError as err:
|
||||
return err, time.monotonic() - started
|
||||
|
||||
def wait_for_the_open(self, host="h"):
|
||||
"""Wait until the released open has published its connection."""
|
||||
entry = self.manager._search_connection(host, "u", "p", CONN_TCP)
|
||||
deadline = time.monotonic() + 5
|
||||
while entry.connection is None and time.monotonic() < deadline:
|
||||
time.sleep(0.01)
|
||||
|
||||
def test_a_hanging_open_is_given_up_after_the_timeout(self):
|
||||
with self.open_auth(alive_connection()):
|
||||
result, took = self.get()
|
||||
|
|
@ -121,7 +128,7 @@ class BoundedOpenTestCase(unittest.TestCase):
|
|||
with self.open_auth(conn):
|
||||
self.get()
|
||||
self.release.set()
|
||||
time.sleep(0.1)
|
||||
self.wait_for_the_open()
|
||||
result, took = self.get()
|
||||
self.assertIs(result, conn)
|
||||
self.assertEqual(self.calls, 1)
|
||||
|
|
@ -168,7 +175,7 @@ class BoundedOpenTestCase(unittest.TestCase):
|
|||
self.assertIsInstance(result, libvirt.libvirtError)
|
||||
self.assertLess(took, 0.1)
|
||||
self.release.set() # the host answers at last
|
||||
time.sleep(0.1)
|
||||
self.wait_for_the_open()
|
||||
result, _ = self.get()
|
||||
self.assertIs(result, conn)
|
||||
self.assertEqual(self.calls, 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue