Commit 5b977793 authored by Jérome Perrin's avatar Jérome Perrin

Workarounds for python 3.5

On python 3.5, for each request where SSL authentication fail, even
though application seem functional, a traceback is logged in the log
file.
This makes tests asserting the last log line fail because the last line
is not the access log line, it's the last line of the traceback.

On python >= 3.6, such tracebacks are not logged, so we don't try to fix
this issue but just workaround this for python 3.5. We'll drop this
patch once we stop supporting python 3.5
parent 0ffdfacf
......@@ -339,6 +339,35 @@ class KedifaIntegrationTest(KedifaCaucaseMixin, unittest.TestCase):
def assertLastLogEntry(self, entry):
with open(self.logfile) as fh:
last_log_line = fh.readlines()[-1]
if sys.version_info[:2] == (3, 5): # BBB python 3.5 compatibility
# On python3.5, errors like this are logged on SSL client errors:
#
# $timestamp - kedifa - ERROR - Exception while handling the request
# Traceback (most recent call last):
# File "/usr/lib/python3.5/wsgiref/handlers.py", line 138, in run
# self.finish_response()
# File "/usr/lib/python3.5/wsgiref/handlers.py", line 180, in finish_response
# self.write(data)
# File "/usr/lib/python3.5/wsgiref/handlers.py", line 279, in write
# self._write(data)
# File "/usr/lib/python3.5/wsgiref/handlers.py", line 453, in _write
# result = self.stdout.write(data)
# File "/usr/lib/python3.5/socket.py", line 594, in write
# return self._sock.send(b)
# File "/usr/lib/python3.5/ssl.py", line 869, in send
# return self._sslobj.write(data)
# File "/usr/lib/python3.5/ssl.py", line 594, in write
# return self._sslobj.write(data)
# ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1949)
with open(self.logfile) as fh:
line_list = fh.readlines()
before_last_log_line = line_list[-2] if len(line_list) > 2 else ''
if "ssl.SSLEOFError: EOF occurred in violation of protocol" in before_last_log_line:
# and the actual "last" log line is before this traceback.
# BBB drop: all this when we stop supporting 3.5
last_log_line =line_list[-19]
self.assertTrue(
entry in last_log_line, '%r not found in %r' % (entry, last_log_line))
......
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