Commit e72324c6 authored by Vincent Pelletier's avatar Vincent Pelletier

test: Directly raise on timeout in UntilEvent.wait .

parent 67cbbda7
...@@ -189,10 +189,9 @@ class UntilEvent(object): ...@@ -189,10 +189,9 @@ class UntilEvent(object):
timeout (float) timeout (float)
Maximum number of seconds to wait for. Maximum number of seconds to wait for.
""" """
result = self._wait_event.wait(timeout) if not self._wait_event.wait(timeout): # pragma: no cover
if result: raise AssertionError('Timeout reached')
self._wait_event.clear() self._wait_event.clear()
return result
def __call__(self, deadline): def __call__(self, deadline):
""" """
...@@ -1953,7 +1952,7 @@ class CaucaseTest(unittest.TestCase): ...@@ -1953,7 +1952,7 @@ class CaucaseTest(unittest.TestCase):
updater_thread.daemon = True updater_thread.daemon = True
updater_thread.start() updater_thread.start()
try: try:
self.assertTrue(until_updater.wait()) until_updater.wait()
# CSR must have been submitted # CSR must have been submitted
csr_line_list = self._runClient( csr_line_list = self._runClient(
'--user-key', user_key_path, '--user-key', user_key_path,
...@@ -1969,7 +1968,7 @@ class CaucaseTest(unittest.TestCase): ...@@ -1969,7 +1968,7 @@ class CaucaseTest(unittest.TestCase):
until_updater.action = ON_EVENT_EXPIRE until_updater.action = ON_EVENT_EXPIRE
updater_event.set() updater_event.set()
# Wait for it to call "until()" again # Wait for it to call "until()" again
self.assertTrue(until_updater.wait()) until_updater.wait()
# It must have retrieved the certificate now. # It must have retrieved the certificate now.
self.assertTrue(os.path.exists(re_crt_path)) self.assertTrue(os.path.exists(re_crt_path))
finally: finally:
...@@ -1992,14 +1991,14 @@ class CaucaseTest(unittest.TestCase): ...@@ -1992,14 +1991,14 @@ class CaucaseTest(unittest.TestCase):
443 if parsed_url.port == 80 else parsed_url.port + 1, 443 if parsed_url.port == 80 else parsed_url.port + 1,
) )
# Wait for server to sleep, and clear. # Wait for server to sleep, and clear.
self.assertTrue(self._server_until.wait()) self._server_until.wait()
# Pull certificate. # Pull certificate.
before = ssl.get_server_certificate(address) before = ssl.get_server_certificate(address)
# Wake server so it renews certificate. # Wake server so it renews certificate.
self._server_until.action = ON_EVENT_EXPIRE self._server_until.action = ON_EVENT_EXPIRE
self._server_event.set() self._server_event.set()
# Wait for it to be back to sleep. # Wait for it to be back to sleep.
self.assertTrue(self._server_until.wait()) self._server_until.wait()
# Verify renewal happened. # Verify renewal happened.
after = ssl.get_server_certificate(address) after = ssl.get_server_certificate(address)
self.assertNotEqual(before, after) self.assertNotEqual(before, after)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment