Skip to content

Commit

Permalink
Always send attach request as streaming
Browse files Browse the repository at this point in the history
Signed-off-by: Joffrey F <[email protected]>
  • Loading branch information
shin- committed Aug 21, 2017
1 parent 3df0653 commit 8919514
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docker/api/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def attach(self, container, stdout=True, stderr=True,
}

u = self._url("/containers/{0}/attach", container)
response = self._post(u, headers=headers, params=params, stream=stream)
response = self._post(u, headers=headers, params=params, stream=True)

return self._read_from_socket(
response, stream, self._check_is_tty(container)
Expand Down
16 changes: 12 additions & 4 deletions tests/integration/api_container_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,20 +1092,28 @@ def test_run_container_reading_socket(self):
command = "printf '{0}'".format(line)
container = self.client.create_container(BUSYBOX, command,
detach=True, tty=False)
ident = container['Id']
self.tmp_containers.append(ident)
self.tmp_containers.append(container)

opts = {"stdout": 1, "stream": 1, "logs": 1}
pty_stdout = self.client.attach_socket(ident, opts)
pty_stdout = self.client.attach_socket(container, opts)
self.addCleanup(pty_stdout.close)

self.client.start(ident)
self.client.start(container)

next_size = next_frame_size(pty_stdout)
self.assertEqual(next_size, len(line))
data = read_exactly(pty_stdout, next_size)
self.assertEqual(data.decode('utf-8'), line)

def test_attach_no_stream(self):
container = self.client.create_container(
BUSYBOX, 'echo hello'
)
self.tmp_containers.append(container)
self.client.start(container)
output = self.client.attach(container, stream=False, logs=True)
assert output == 'hello\n'.encode(encoding='ascii')


class PauseTest(BaseAPIIntegrationTest):
def test_pause_unpause(self):
Expand Down

0 comments on commit 8919514

Please sign in to comment.