Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,3 +640,12 @@ def test_get_hosts():
("a", 10),
("a", 1),
]


@pytest.mark.testinfra_hosts(*HOSTS)
def test_command_deadlock(host):
# Test for deadlock when exceeding Paramiko transport buffer (2MB)
# https://docs.paramiko.org/en/latest/api/channel.html#paramiko.channel.Channel.recv_exit_status
size = 3 * 1024 * 1024
output = host.check_output(f"python3 -c 'print(\"a\" * {size})'")
assert len(output) == size
2 changes: 1 addition & 1 deletion testinfra/backend/paramiko.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ def _exec_command(self, command: bytes) -> tuple[int, bytes, bytes]:
if self.get_pty:
chan.get_pty()
chan.exec_command(command)
rc = chan.recv_exit_status()
stdout = b"".join(chan.makefile("rb"))
stderr = b"".join(chan.makefile_stderr("rb"))
rc = chan.recv_exit_status()
return rc, stdout, stderr

def run(self, command: str, *args: str, **kwargs: Any) -> base.CommandResult:
Expand Down
Loading