Commit 40db2229 authored by Łukasz Nowak's avatar Łukasz Nowak

test: Wait for log entry to appear

As the servers can take a bit of time before emitting the log entry, wait a
bit before asserting the status.
parent a67763c1
...@@ -399,10 +399,21 @@ class KedifaIntegrationTest(KedifaCaucaseMixin, unittest.TestCase): ...@@ -399,10 +399,21 @@ class KedifaIntegrationTest(KedifaCaucaseMixin, unittest.TestCase):
'Entry %r not found in log:\n %s' % (entry, ''.join(log_line_list))) 'Entry %r not found in log:\n %s' % (entry, ''.join(log_line_list)))
def assertLastLogEntry(self, entry): def assertLastLogEntry(self, entry):
with open(self.logfile) as fh: tries_left = 5 # try few times, as server can store the log line a bit
last_log_line = fh.readlines()[-1] # later
self.assertTrue( while True:
entry in last_log_line, '%r not found in %r' % (entry, last_log_line)) with open(self.logfile) as fh:
last_log_line = fh.readlines()[-1]
try:
self.assertTrue(
entry in last_log_line, '%r not found in %r' % (entry, last_log_line))
except AssertionError:
if tries_left == 0:
raise
tries_left -= 1
time.sleep(1)
else:
break
def _getter_get(self, url, certificate, destination): def _getter_get(self, url, certificate, destination):
cli.getter( cli.getter(
......
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