Blob Blame History Raw
From 35f5e5c3e735a27c6af552744ae3dbdeab819c6a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= <mitr@redhat.com>
Date: Sat, 7 Oct 2017 07:17:21 +0200
Subject: [PATCH] Mitigate a race in test_HTTPSConnection_SNI_support

On ppc64/ppc64le, test_HTTPSConnection_SNI_support has been failing with
> AssertionError: 'Hostname in TLS extension: "localhost"' not found in 'Setting secondary ctx parameters\nUsing default temp DH parameters\nACCEPT\n'
i.e. the connection-specific data has not been logged by s_server.

Wait before terminating it to allow it to flush its buffers.
---
 tests/test_ssl.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/test_ssl.py b/tests/test_ssl.py
index f8f6faf..5ada160 100644
--- a/tests/test_ssl.py
+++ b/tests/test_ssl.py
@@ -251,6 +251,12 @@ class HttpslibSSLClientTestCase(BaseSSLClientTestCase):
             c.request('GET', '/')
             c.close()
         finally:
+            # (openssl s_server) buffers its log output, and ends the TLS session
+            # with the client (allowing the client to terminate) before flushing
+            # the log; so, the client may get here and terminate the server
+            # before it manages to log the output.
+            # So, give the server hopefully enough time to flush the logs.
+            time.sleep(sleepTime)
             out, err = self.stop_server(pid)
         self.assertIn('Hostname in TLS extension: "%s"' % srv_host, out)
 
-- 
2.14.1