Skip to content

Fix flaky SSH security integration tests on Windows CI (#2764)#2766

Merged
jbonofre merged 1 commit into
apache:karaf-4.4.xfrom
jbonofre:4.4.x-ssh-itest-windows-flaky-fix
Jul 10, 2026
Merged

Fix flaky SSH security integration tests on Windows CI (#2764)#2766
jbonofre merged 1 commit into
apache:karaf-4.4.xfrom
jbonofre:4.4.x-ssh-itest-windows-flaky-fix

Conversation

@jbonofre

@jbonofre jbonofre commented Jul 8, 2026

Copy link
Copy Markdown
Member
  • Fix flaky SSH security itests on Windows by waiting for command completion

The SSH command security integration tests (SshCommandTestBase) wrote a command to the SSH channel and immediately sent "logout" to tear down the session. On slower runners - in particular the Windows CI - the session could be closed while the command output was still in flight, producing truncated output (e.g. a partial command echo "she" instead of "shell:nano") and spurious assertion failures such as "Should contain 'Command not found'".

Introduce a writeCommandAndWait() helper that appends a sentinel "echo " command and blocks until the unique marker appears in the captured output before closing the channel. Because the remote shell reads and executes its input line by line, the marker cannot appear before the command under test has been fully executed and flushed back to the client, providing a deterministic completion signal that also works for the OK case (which has no positive marker of its own). "echo" is a gogo built-in that is not restricted by any command ACL, so it is safe for every test user.

The helper is also used by addUsers()/addViewer() so the JAAS users are fully created before the test logs in as them.

  • Potential fix for pull request finding

* Fix flaky SSH security itests on Windows by waiting for command completion

The SSH command security integration tests (SshCommandTestBase) wrote a
command to the SSH channel and immediately sent "logout" to tear down the
session. On slower runners - in particular the Windows CI - the session
could be closed while the command output was still in flight, producing
truncated output (e.g. a partial command echo "she" instead of
"shell:nano") and spurious assertion failures such as
"Should contain 'Command not found'".

Introduce a writeCommandAndWait() helper that appends a sentinel
"echo <marker>" command and blocks until the unique marker appears in the
captured output before closing the channel. Because the remote shell reads
and executes its input line by line, the marker cannot appear before the
command under test has been fully executed and flushed back to the client,
providing a deterministic completion signal that also works for the OK case
(which has no positive marker of its own). "echo" is a gogo built-in that is
not restricted by any command ACL, so it is safe for every test user.

The helper is also used by addUsers()/addViewer() so the JAAS users are
fully created before the test logs in as them.

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@holgerfriedrich

Copy link
Copy Markdown
Contributor

@jbonofre I think we skip the itests on Windows on the 4.4.x branch since #2537, or do I get this wrong?

@jbonofre

jbonofre commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

@holgerfriedrich #2537 just updated the build contexts (checks) on CI, but it still execute the tests.

@jbonofre jbonofre merged commit 53885f1 into apache:karaf-4.4.x Jul 10, 2026
20 of 24 checks passed
@jbonofre jbonofre deleted the 4.4.x-ssh-itest-windows-flaky-fix branch July 10, 2026 04:40
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.

2 participants