jbonofre opened a new pull request, #2764:
URL: https://github.com/apache/karaf/pull/2764
## Problem
The SSH command security integration tests (`ShellCommandSecurityTest`,
`JaasSshCommandSecurityTest`, and the other `SshCommandTestBase` subclasses)
intermittently fail on the Windows CI job with errors like:
```
java.lang.AssertionError: Should contain 'Command not found':
~
view3643776057000_1@root()> she
```
The captured output is truncated to a partial command echo (`she` instead of
`shell:nano`), so the assertion fails. This is a well-known flake on the `test
(windows-latest)` job (it also hits `main` independently of any given PR).
## Root cause
`SshCommandTestBase.assertCommand()` wrote the command to the SSH channel
and then immediately sent `logout` in `closeSshChannel()` to tear down the
session. On slower runners — in particular Windows — the session could be
closed while the command output was still in flight, so only a partial,
truncated output was captured before the channel was read.
## Fix
Introduce a `writeCommandAndWait()` helper that appends a sentinel `echo
<marker>` command after the command under test 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. This provides 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.
## Testing
`ShellCommandSecurityTest` passes locally on Temurin JDK 17 (matching the CI
runtime):
```
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 8.257 s --
in org.apache.karaf.itests.ssh.ShellCommandSecurityTest
BUILD SUCCESS
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]