Github user aledsage commented on the issue:
https://github.com/apache/brooklyn-server/pull/491
I started looking into why `testSshExecScript()` was failing. First quick
comment: you need to enable the feature:
```
@BeforeMethod(alwaysRun=true)
public void setUp() throws Exception {
origAsyncExecEnablement =
BrooklynFeatureEnablement.setEnablement(BrooklynFeatureEnablement.FEATURE_SSH_ASYNC_EXEC,
true);
super.setUp();
}
@AfterMethod(alwaysRun=true)
public void tearDown() throws Exception {
try {
super.tearDown();
} finally {
if (origAsyncExecEnablement != null) {
BrooklynFeatureEnablement.setEnablement(BrooklynFeatureEnablement.FEATURE_SSH_ASYNC_EXEC,
origAsyncExecEnablement);
origAsyncExecEnablement = null;
}
RecordingSshjTool.clear();
}
}
```
But it still fails. It doesn't manage to get the stdout/stderr from the
long polling. If you change the test to also pass in
`SshMachineLocation.NO_STDOUT_LOGGING.getName(), true` then it works.
The problems seems to be the interaction between the `PipedOutputStream`
(added in `ExecWithLoggingHelpers.execWithLogging()`) and the
`CountingOutputStream` (added in `SshjTool.execScriptAsyncAndPoll`'s
`longPoll()`).
I don't have time to investigate further just now, unfortunately. I suggest
we park this for a bit longer.
I'm not sure why we're wrapping it in a `PipedOutputStream` (which allows
us to also receive the bytes and log them, using the `StreamGobbler` to respond
to callbacks about the bytes being received). I'm not sure why we don't just
wrap the `OutputStream` in a much simpler way, in a similar way to how guava
wraps `CountingOutputStream` - where on each byte that is written it can check
if that's the end of a line and log it accordingly.
But we don't want to be making changing like that just now, and certainly
not as part of this PR.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---