mirror of https://github.com/python/cpython.git
bpo-23749: Make start-tls tests more stable on win7 buildbot (GH-5409)
To mitigate the situation when the buildbot is under load and is unable to send/receive data fast enough: * reduce the size of the payload * set a generous timeout for socket ops
This commit is contained in:
parent
07627e9a6a
commit
1e5b25b8c0
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
try:
|
try:
|
||||||
|
@ -171,12 +172,14 @@ def new_loop(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def test_start_tls_client_1(self):
|
def test_start_tls_client_1(self):
|
||||||
HELLO_MSG = b'1' * 1024 * 1024 * 5
|
HELLO_MSG = b'1' * 1024 * 1024
|
||||||
|
|
||||||
server_context = test_utils.simple_server_sslcontext()
|
server_context = test_utils.simple_server_sslcontext()
|
||||||
client_context = test_utils.simple_client_sslcontext()
|
client_context = test_utils.simple_client_sslcontext()
|
||||||
|
|
||||||
def serve(sock):
|
def serve(sock):
|
||||||
|
sock.settimeout(5)
|
||||||
|
|
||||||
data = sock.recv_all(len(HELLO_MSG))
|
data = sock.recv_all(len(HELLO_MSG))
|
||||||
self.assertEqual(len(data), len(HELLO_MSG))
|
self.assertEqual(len(data), len(HELLO_MSG))
|
||||||
|
|
||||||
|
@ -205,6 +208,8 @@ def eof_received(self):
|
||||||
self.on_eof.set_result(True)
|
self.on_eof.set_result(True)
|
||||||
|
|
||||||
async def client(addr):
|
async def client(addr):
|
||||||
|
await asyncio.sleep(0.5, loop=self.loop)
|
||||||
|
|
||||||
on_data = self.loop.create_future()
|
on_data = self.loop.create_future()
|
||||||
on_eof = self.loop.create_future()
|
on_eof = self.loop.create_future()
|
||||||
|
|
||||||
|
@ -225,12 +230,15 @@ async def client(addr):
|
||||||
asyncio.wait_for(client(srv.addr), loop=self.loop, timeout=10))
|
asyncio.wait_for(client(srv.addr), loop=self.loop, timeout=10))
|
||||||
|
|
||||||
def test_start_tls_server_1(self):
|
def test_start_tls_server_1(self):
|
||||||
HELLO_MSG = b'1' * 1024 * 1024 * 5
|
HELLO_MSG = b'1' * 1024 * 1024
|
||||||
|
|
||||||
server_context = test_utils.simple_server_sslcontext()
|
server_context = test_utils.simple_server_sslcontext()
|
||||||
client_context = test_utils.simple_client_sslcontext()
|
client_context = test_utils.simple_client_sslcontext()
|
||||||
|
|
||||||
def client(sock, addr):
|
def client(sock, addr):
|
||||||
|
time.sleep(0.5)
|
||||||
|
sock.settimeout(5)
|
||||||
|
|
||||||
sock.connect(addr)
|
sock.connect(addr)
|
||||||
data = sock.recv_all(len(HELLO_MSG))
|
data = sock.recv_all(len(HELLO_MSG))
|
||||||
self.assertEqual(len(data), len(HELLO_MSG))
|
self.assertEqual(len(data), len(HELLO_MSG))
|
||||||
|
|
Loading…
Reference in New Issue