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):
'Entry %r not found in log:\n %s' % (entry, ''.join(log_line_list)))
def assertLastLogEntry(self, entry):
with open(self.logfile) as fh:
last_log_line = fh.readlines()[-1]
self.assertTrue(
entry in last_log_line, '%r not found in %r' % (entry, last_log_line))
tries_left = 5 # try few times, as server can store the log line a bit
# later
while True:
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):
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