Commit 61acfd7a authored by Jason Madden's avatar Jason Madden

Tweak socket timeouts for CI.

parent b57e1896
...@@ -376,10 +376,10 @@ class TestCaseMetaClass(type): ...@@ -376,10 +376,10 @@ class TestCaseMetaClass(type):
# Travis is slow and overloaded; Appveyor used to be faster, but # Travis is slow and overloaded; Appveyor used to be faster, but
# as of Dec 2015 it's almost always slower and/or has much worse timer # as of Dec 2015 it's almost always slower and/or has much worse timer
# resolution # resolution
CI_TIMEOUT = 7 CI_TIMEOUT = 10
if PY3 and PYPY: if PY3 and PYPY:
# pypy3 is very slow right now # pypy3 is very slow right now
CI_TIMEOUT = 10 CI_TIMEOUT = 15
LOCAL_TIMEOUT = 1 LOCAL_TIMEOUT = 1
DEFAULT_LOCAL_HOST_ADDR = 'localhost' DEFAULT_LOCAL_HOST_ADDR = 'localhost'
......
...@@ -6,9 +6,10 @@ import greentest ...@@ -6,9 +6,10 @@ import greentest
# XXX also test: send, sendall, recvfrom, recvfrom_into, sendto # XXX also test: send, sendall, recvfrom, recvfrom_into, sendto
def readall(socket, address): def readall(sock, _):
while socket.recv(1024): while sock.recv(1024):
pass pass
sock.close()
class Test(greentest.TestCase): class Test(greentest.TestCase):
...@@ -16,7 +17,7 @@ class Test(greentest.TestCase): ...@@ -16,7 +17,7 @@ class Test(greentest.TestCase):
error_fatal = False error_fatal = False
def setUp(self): def setUp(self):
self.server = server.StreamServer(('127.0.0.1', 0), readall) self.server = server.StreamServer((greentest.DEFAULT_BIND_ADDR, 0), readall)
self.server.start() self.server.start()
def tearDown(self): def tearDown(self):
...@@ -24,7 +25,7 @@ class Test(greentest.TestCase): ...@@ -24,7 +25,7 @@ class Test(greentest.TestCase):
def test_recv_closed(self): def test_recv_closed(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('localhost', self.server.server_port)) sock.connect((greentest.DEFAULT_LOCAL_HOST_ADDR, self.server.server_port))
receiver = gevent.spawn(sock.recv, 25) receiver = gevent.spawn(sock.recv, 25)
try: try:
gevent.sleep(0.001) gevent.sleep(0.001)
...@@ -32,14 +33,14 @@ class Test(greentest.TestCase): ...@@ -32,14 +33,14 @@ class Test(greentest.TestCase):
receiver.join(timeout=0.1) receiver.join(timeout=0.1)
assert receiver.ready(), receiver assert receiver.ready(), receiver
self.assertEqual(receiver.value, None) self.assertEqual(receiver.value, None)
assert isinstance(receiver.exception, socket.error) self.assertIsInstance(receiver.exception, socket.error)
self.assertEqual(receiver.exception.errno, socket.EBADF) self.assertEqual(receiver.exception.errno, socket.EBADF)
finally: finally:
receiver.kill() receiver.kill()
def test_recv_twice(self): def test_recv_twice(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('localhost', self.server.server_port)) sock.connect((greentest.DEFAULT_LOCAL_HOST_ADDR, self.server.server_port))
receiver = gevent.spawn(sock.recv, 25) receiver = gevent.spawn(sock.recv, 25)
try: try:
gevent.sleep(0.001) gevent.sleep(0.001)
...@@ -47,6 +48,7 @@ class Test(greentest.TestCase): ...@@ -47,6 +48,7 @@ class Test(greentest.TestCase):
self.assertRaises(AssertionError, sock.recv, 25) self.assertRaises(AssertionError, sock.recv, 25)
finally: finally:
receiver.kill() receiver.kill()
sock.close()
if __name__ == '__main__': if __name__ == '__main__':
......
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