summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@riseup.net>2017-11-19 17:13:38 -0200
committerdrebs <drebs@riseup.net>2017-11-19 19:27:43 -0200
commit70cd9349faad311d645157f1961f63e030998a57 (patch)
tree4dedc96fe55216bfb5365ab5976a19d988a521f6
parent6493d072c189a522aef549313e765c68f004ab09 (diff)
[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.
-rw-r--r--tests/server/test_tac.py15
1 files changed, 14 insertions, 1 deletions
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()