fe7720d
From 35f5e5c3e735a27c6af552744ae3dbdeab819c6a Mon Sep 17 00:00:00 2001
fe7720d
From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= <mitr@redhat.com>
fe7720d
Date: Sat, 7 Oct 2017 07:17:21 +0200
fe7720d
Subject: [PATCH] Mitigate a race in test_HTTPSConnection_SNI_support
fe7720d
fe7720d
On ppc64/ppc64le, test_HTTPSConnection_SNI_support has been failing with
fe7720d
> AssertionError: 'Hostname in TLS extension: "localhost"' not found in 'Setting secondary ctx parameters\nUsing default temp DH parameters\nACCEPT\n'
fe7720d
i.e. the connection-specific data has not been logged by s_server.
fe7720d
fe7720d
Wait before terminating it to allow it to flush its buffers.
fe7720d
---
fe7720d
 tests/test_ssl.py | 6 ++++++
fe7720d
 1 file changed, 6 insertions(+)
fe7720d
fe7720d
diff --git a/tests/test_ssl.py b/tests/test_ssl.py
fe7720d
index f8f6faf..5ada160 100644
fe7720d
--- a/tests/test_ssl.py
fe7720d
+++ b/tests/test_ssl.py
fe7720d
@@ -251,6 +251,12 @@ class HttpslibSSLClientTestCase(BaseSSLClientTestCase):
fe7720d
             c.request('GET', '/')
fe7720d
             c.close()
fe7720d
         finally:
fe7720d
+            # (openssl s_server) buffers its log output, and ends the TLS session
fe7720d
+            # with the client (allowing the client to terminate) before flushing
fe7720d
+            # the log; so, the client may get here and terminate the server
fe7720d
+            # before it manages to log the output.
fe7720d
+            # So, give the server hopefully enough time to flush the logs.
fe7720d
+            time.sleep(sleepTime)
fe7720d
             out, err = self.stop_server(pid)
fe7720d
         self.assertIn('Hostname in TLS extension: "%s"' % srv_host, out)
fe7720d
 
fe7720d
-- 
fe7720d
2.14.1
fe7720d