Skip to content

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

Open
jbonofre wants to merge 4 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 4 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.

@jbonofre jbonofre force-pushed the fix/ssh-test-windows-pty branch from f30a1ca to b27cb03 Compare April 17, 2026 11:52
With a PTY allocated and the default terminal type, 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.

Use a PTY with terminal type "dumb" and ECHO disabled instead:
- The PTY allocation preserves the normal channel lifecycle so the server
  closes the channel when the shell exits (setUsePty(false) broke this).
- JLine detects "dumb" and runs in non-interactive mode, avoiding the
  character re-rendering that caused the garbled output.

Also send JAAS setup commands as separate newline-terminated lines rather
than semicolon-chained, and close the stdin pipe after logout to send EOF
as a clean shutdown signal.
@jbonofre jbonofre force-pushed the fix/ssh-test-windows-pty branch from b27cb03 to d5017cb Compare April 17, 2026 11:53
…l lifecycle issues

With a "dumb" PTY shell channel, the Karaf shell hangs and does not close
the channel cleanly after processing the JAAS commands, causing the 15 s
waitFor(CLOSED) to time out.  As a result jaas:update is never committed
and the test user does not exist, leading to "No more authentication
methods available" when assertCommand tries to connect as that user.

Fix addUsers/addViewer to use executeCommand (direct OSGi container
execution, already available from KarafTestSupport) instead of an SSH
shell channel.  SSH is only required for the actual security assertions
in assertCommand, not for test setup.  The "dumb" PTY is kept for
assertCommand to suppress JLine's character re-rendering that produced
garbled output on Windows.
The get-wrapper-native-lib antrun goal downloads Tanuki wrapper binaries
from download.tanukisoftware.com, which is intermittently unreachable from
CI runners.  A single failed download aborts the entire build even though
the affected platform binaries (AIX, HP-UX, Solaris, etc.) are not needed
for the CI test environments.

Add ignoreerrors="true" and skipexisting="true" to all <get> tasks so that
download failures are non-fatal and already-fetched archives are not
re-downloaded.  Add failonerror="false" to the dependent gunzip/untar/unzip
and copy tasks so that a missing archive does not cascade into a build
failure.
Use Ant <available> task to set a property when the downloaded archive
exists, then use if="property" on <gunzip> and <untar> tasks (which
do not support failonerror) so extraction is skipped when the download
from tanukisoftware.com fails (e.g. on Ubuntu CI runners).
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