Commit 35fc8b2e authored by Vincent Pelletier's avatar Vincent Pelletier

test: Make http server's UntilEvent instance usable by tests.

Do not wait forever so test does not block.
Always clear event after it occurred.
Also, ensure itsUntilEvent behaviour is to raise so server actually stops
in _stopServer.
parent 642b59c2
......@@ -201,7 +201,8 @@ class UntilEvent(object):
now = datetime.datetime.utcnow()
while now < deadline:
self._wait_event.set()
assert self._event.wait()
assert self._event.wait(10)
self._event.clear()
if self._action is ON_EVENT_EXPIRE:
now = deadline
else:
......@@ -294,7 +295,7 @@ class CaucaseTest(unittest.TestCase):
"""
Start caucased server
"""
self._server_event.clear()
self._server_until = until = UntilEvent(self._server_event)
self._server = server = threading.Thread(
target=http.main,
kwargs={
......@@ -305,7 +306,7 @@ class CaucaseTest(unittest.TestCase):
#'--threshold', '31',
#'--key-len', '2048',
) + argv,
'until': UntilEvent(self._server_event),
'until': until,
}
)
server.daemon = True
......@@ -327,6 +328,7 @@ class CaucaseTest(unittest.TestCase):
Stop a running caucased server
"""
server = self._server
self._server_until.action = ON_EVENT_RAISE
self._server_event.set()
server.join(2)
if server.is_alive(): # pragma: no cover
......
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