Commit f13bd84e authored by Jérome Perrin's avatar Jérome Perrin

software/erp5/test: make TestAccessLog.test_access_log_format more robust

There can be a short delay after the request until the request is logged, so
wait a bit more before inspecting the log.

There can be lines from requests made in previous tests, so make sure to only
read the last line.
parent 32058a62
...@@ -179,8 +179,9 @@ class TestAccessLog(BalancerTestCase, CrontabMixin): ...@@ -179,8 +179,9 @@ class TestAccessLog(BalancerTestCase, CrontabMixin):
urlparse.urljoin(self.default_balancer_url, '/url_path'), urlparse.urljoin(self.default_balancer_url, '/url_path'),
verify=False, verify=False,
) )
time.sleep(.5) # wait a bit more until access is logged
with open(os.path.join(self.computer_partition_root_path, 'var', 'log', 'apache-access.log')) as access_log_file: with open(os.path.join(self.computer_partition_root_path, 'var', 'log', 'apache-access.log')) as access_log_file:
access_line = access_log_file.read() access_line = access_log_file.read().splitlines()[-1]
self.assertIn('/url_path', access_line) self.assertIn('/url_path', access_line)
# last \d is the request time in micro seconds, since this SlowHTTPServer # last \d is the request time in micro seconds, since this SlowHTTPServer
......
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