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-6685] CLIEmbedServerTestCase.testStdOutEcho fails intermittently #5877

Merged
merged 1 commit into from
Feb 26, 2024
Merged
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 @@ -32,6 +32,7 @@
import java.nio.file.Files;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.codehaus.plexus.util.FileUtils;
import org.jboss.as.controller.client.ModelControllerClient;
Expand Down Expand Up @@ -215,7 +216,7 @@ private void stdoutTest(String paramVal) throws Exception {
String line = "embed-server --admin-only=false --server-config=standalone-cli.xml " + stdoutParam + JBOSS_HOME;
cli.sendLine(line);
if (expectServerLogging) {
checkLogging("WFLYSRV0025");
checkLogging("WFLYSRV0025", TimeoutUtil.adjust(30000));
} else {
checkNoLogging("WFLYSRV0025");
}
Expand Down Expand Up @@ -249,7 +250,7 @@ private void stdoutTest(String paramVal) throws Exception {

}

private void checkClientSideLogging() throws IOException {
private void checkClientSideLogging() throws IOException, InterruptedException {
String text = "test." + System.nanoTime();
Logger.getLogger(text).error(text);
checkLogging(text);
Expand Down Expand Up @@ -525,7 +526,7 @@ public void testStopServerOnTerminateSession() throws IOException {
* Tests the --help param works.
*/
@Test
public void testHelp() throws IOException {
public void testHelp() throws IOException, InterruptedException {
cli.sendLine("embed-server --help");
checkLogging("embed-server");

Expand Down Expand Up @@ -725,8 +726,19 @@ private String readLogOut() {
return null;
}

private void checkLogging(String line) throws IOException {
private void checkLogging(String line) throws IOException, InterruptedException {
checkLogging(line, 0);
}

private void checkLogging(String line, int timeout) throws IOException, InterruptedException {
String logOutput = readLogOut();
long done = System.currentTimeMillis() + timeout;
while (timeout > 0 && System.currentTimeMillis() < done) {
if (checkLogging(logOutput, line)) {
break;
}
TimeUnit.MILLISECONDS.sleep(500);
}
assertTrue(logOutput, checkLogging(logOutput, line));
}

Expand Down