Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFCORE-6552] Add missing search for WARNING to Windows package avail… #5713

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ if exist "%COMMON_CONF%" (
goto :eof

:setPackageAvailable
"%JAVA%" --add-opens=%~1=ALL-UNNAMED -version >nul 2>&1 && (set PACKAGE_AVAILABLE=true) || (set PACKAGE_AVAILABLE=false)
rem java -version actually writes what we all read in our terminals to stderr, not stdout!
rem So we redirect it to stdout with 2>&1 before piping to findstr
"%JAVA%" --add-opens=%~1=ALL-UNNAMED -version 2>&1 | findstr /i /c:"WARNING" >nul 2>&1 && (set PACKAGE_AVAILABLE=false) || (set PACKAGE_AVAILABLE=true)
goto :eof

:setEnhancedSecurityManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ Function Get-Java-Opts {
}

Function SetPackageAvailable($packageName) {
$PACKAGE_AVAILABLE = $false
& $JAVA "--add-opens=$packageName=ALL-UNNAMED" -version >$null 2>&1
$PACKAGE_AVAILABLE = $true
# java -version actually writes what we all read in our terminals to stderr, not stdout!
# So we redirect it to stdout with 2>&1 before piping to Out-String and Select-String
& $JAVA "--add-opens=$packageName=ALL-UNNAMED" -version 2>&1 | Out-String -Stream | Select-String 'WARNING' -SimpleMatch -Quiet >$null 2>&1
if ($LastExitCode -eq 0){
$PACKAGE_AVAILABLE = $true
$PACKAGE_AVAILABLE = $false
}
return $PACKAGE_AVAILABLE
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ if [ -r "$COMMON_CONF" ]; then
fi

setPackageAvailable() {
# java -version actually writes what we all read in our terminals to stderr, not stdout!
# So we redirect it to stdout with 2>&1 before piping to grep
PACKAGE_STRING=`"$JAVA" --add-opens=$1=ALL-UNNAMED -version 2>&1 | $GREP "WARNING"`
if [ "x$PACKAGE_STRING" = "x" ]; then
PACKAGE_AVAILABLE=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ void testScript(final ScriptProcess script) throws InterruptedException, Timeout

validateProcess(script);

final ModelNode result = outputToModelNode(script);
if (!Operations.isSuccessfulOutcome(result)) {
Assert.fail(result.asString());
}
Assert.assertEquals(ClientConstants.CONTROLLER_PROCESS_STATE_RUNNING, Operations.readResult(result).asString());
}

private static ModelNode outputToModelNode(final ScriptProcess script) throws IOException {
StringBuilder builder = new StringBuilder();
// Read the output lines which should be valid DMR
for (String line : script.getStdout()) {
Expand All @@ -48,10 +56,12 @@ void testScript(final ScriptProcess script) throws InterruptedException, Timeout
}
builder.append(line);
}
final ModelNode result = ModelNode.fromString(builder.toString());
if (!Operations.isSuccessfulOutcome(result)) {
Assert.fail(result.asString());
final String modelNodeInput = builder.toString();
try {
return ModelNode.fromString(modelNodeInput);
} catch (Exception e) {
Assert.fail(String.format("Cannot convert %s into a ModelNode -- %s", modelNodeInput, e));
throw new IllegalStateException("unreachable");
}
Assert.assertEquals(ClientConstants.CONTROLLER_PROCESS_STATE_RUNNING, Operations.readResult(result).asString());
}
}