Skip to content

fix(itests): disable PTY in SSH test channels to fix garbled output on Windows#2544

Open
jbonofre wants to merge 2 commits intoapache:mainfrom
jbonofre:fix/ssh-test-windows-pty
Open

fix(itests): disable PTY in SSH test channels to fix garbled output on Windows#2544
jbonofre wants to merge 2 commits intoapache:mainfrom
jbonofre:fix/ssh-test-windows-pty

Conversation

@jbonofre
Copy link
Copy Markdown
Member

@jbonofre jbonofre commented Apr 16, 2026

  • SshCommandTestBase.openSshChannel previously allocated a pseudo-terminal (PTY) for the shell channel, even though all tests use it for scripted (non-interactive) command execution.
  • With a PTY allocated, JLine on the server side runs in fully interactive mode and re-renders each character as it is received. On Windows, where I/O flush timing differs from Linux/macOS, this produces garbled output such as conficonfigconfig:property-set in the captured output stream.
  • The prior workaround (setPtyModes(PtyMode.ECHO, 0)) disabled terminal echo but still allocated a PTY, so JLine's display-refresh writes continued to pollute the output.
  • The fix calls channel.setUsePty(false) (available in Apache MINA SSHD PtyCapableChannelSession) so no PTY is requested and JLine runs in dumb/non-interactive mode — the raw command output is then captured cleanly on all platforms.

…ed output on Windows

With a PTY allocated, JLine on the server side runs in interactive mode
and re-renders each character as it is typed, producing garbled output
(e.g. "conficonfigconfig:property-set") on Windows where I/O flush
timing differs from Linux/macOS.  Using setUsePty(false) keeps the
server in dumb/non-interactive mode so the raw command output is captured
cleanly regardless of platform.

Fixes ConfigSshCommandSecurityTest.testConfigCommandSecurityWithoutEditSessionViaSsh
on Windows.
…from hanging

Without PTY allocation, the logout command alone does not reliably trigger
a channel-close on the server side. Closing the PipedOutputStream sends
EOF on stdin so the Karaf shell exits cleanly regardless of PTY mode.
Also replace the infinite waitFor(0) with a 15-second timeout as a safety
net to avoid tests hanging and Surefire killing the JVM fork.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant