From 70cd9349faad311d645157f1961f63e030998a57 Mon Sep 17 00:00:00 2001 From: drebs Date: Sun, 19 Nov 2017 17:13:38 -0200 Subject: [test] TAC test now checks for server (with retries) After we fixed the server to wait for checks before listening on ports (201ef7a9b979f8c8efaedbe542c631944d8956f4), the TAC test started failing randomly in our CI, probably because sometimes the server takes more than 1 second to startup in the CI setup (docker in a vm). This commit adds a check with retry, and so the test will retry 10 times with an interval of 1 second before failing. --- tests/server/test_tac.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/server/test_tac.py b/tests/server/test_tac.py index 7bb50e35..e2e15f44 100644 --- a/tests/server/test_tac.py +++ b/tests/server/test_tac.py @@ -70,7 +70,20 @@ class TacServerTestCase(unittest.TestCase): t = reactor.spawnProcess(protocol, executable, args, env=env) self.addCleanup(os.kill, t.pid, signal.SIGKILL) self.addCleanup(t.loseConnection) - return self._sleep(1) # it takes a while to start server + d = self._wait_for_server() + return d + + @defer.inlineCallbacks + def _wait_for_server(self, retries=10): + while retries: + retries -= 1 + yield self._sleep(1) + try: + yield self._get('http://localhost:2525') + break + except Exception as e: + if not retries: + raise e def _sleep(self, time): d = defer.Deferred() -- cgit v1.2.3