Skip to content

Commit 992e0dc

Browse files
authored
Merge pull request #2317 from docker/fix_socket_detach_helper
Fix socket detach helper
2 parents 63cda2e + 62c8bcb commit 992e0dc

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

tests/helpers.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
import os
33
import os.path
44
import random
5+
import re
6+
import socket
57
import tarfile
68
import tempfile
79
import time
8-
import re
9-
import six
10-
import socket
1110

1211
import docker
1312
import paramiko
1413
import pytest
14+
import six
1515

1616

1717
def make_tree(dirs, files):
@@ -119,13 +119,18 @@ def assert_cat_socket_detached_with_keys(sock, inputs):
119119
# If we're using a Unix socket, the sock.send call will fail with a
120120
# BrokenPipeError ; INET sockets will just stop receiving / sending data
121121
# but will not raise an error
122-
if getattr(sock, 'family', -9) == getattr(socket, 'AF_UNIX', -1):
123-
with pytest.raises(socket.error):
124-
sock.sendall(b'make sure the socket is closed\n')
125-
elif isinstance(sock, paramiko.Channel):
122+
if isinstance(sock, paramiko.Channel):
126123
with pytest.raises(OSError):
127124
sock.sendall(b'make sure the socket is closed\n')
128125
else:
126+
if getattr(sock, 'family', -9) == getattr(socket, 'AF_UNIX', -1):
127+
# We do not want to use pytest.raises here because future versions
128+
# of the daemon no longer cause this to raise an error.
129+
try:
130+
sock.sendall(b'make sure the socket is closed\n')
131+
except socket.error:
132+
return
133+
129134
sock.sendall(b"make sure the socket is closed\n")
130135
data = sock.recv(128)
131136
# New in 18.06: error message is broadcast over the socket when reading

tests/integration/api_container_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ def test_attach_no_stream(self):
12511251
output = self.client.attach(container, stream=False, logs=True)
12521252
assert output == 'hello\n'.encode(encoding='ascii')
12531253

1254-
@pytest.mark.timeout(5)
1254+
@pytest.mark.timeout(10)
12551255
@pytest.mark.skipif(os.environ.get('DOCKER_HOST', '').startswith('ssh://'),
12561256
reason='No cancellable streams over SSH')
12571257
def test_attach_stream_and_cancel(self):

0 commit comments

Comments
 (0)