Skip to content

Commit

Permalink
Diagnostics for `QuietDownCommandTest.quietDownShouldSuccessWithBlock…
Browse files Browse the repository at this point in the history
…PlusNonExpiredTimeoutAndRunningExecutor` (#8534)
  • Loading branch information
jglick committed Oct 21, 2023
1 parent eeabeee commit 53fa102
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/src/test/java/hudson/cli/QuietDownCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.fail;

import hudson.XmlFile;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.Queue;
Expand All @@ -45,13 +46,15 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import jenkins.model.Jenkins;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.BuildWatcher;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.LoggerRule;

/**
* @author pjanouse
Expand All @@ -69,6 +72,9 @@ public class QuietDownCommandTest {
@Rule
public final JenkinsRule j = new JenkinsRule();

@Rule
public final LoggerRule logging = new LoggerRule();

@Before
public void setUp() {
command = new CLICommandInvoker(j, "quiet-down");
Expand Down Expand Up @@ -343,8 +349,7 @@ public void quietDownShouldSuccessWithBlockPlusNonExpiredTimeoutAndRunningExecut
final OneShotEvent finish = new OneShotEvent();
final FreeStyleBuild build = OnlineNodeCommandTest.startBlockingAndFinishingBuild(project, finish);

boolean timeoutOccurred = false;
final FutureTask exec_task = new FutureTask(() -> {
final FutureTask<Void> exec_task = new FutureTask<>(() -> {
assertJenkinsNotInQuietMode();
beforeCli.signal();
final CLICommandInvoker.Result result = command
Expand All @@ -356,7 +361,7 @@ public void quietDownShouldSuccessWithBlockPlusNonExpiredTimeoutAndRunningExecut
threadPool.submit(exec_task);
beforeCli.block();
assertJenkinsInQuietMode();
final boolean timeout_occured = false;
boolean timeoutOccurred = false;
try {
exec_task.get(TIMEOUT, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
Expand All @@ -370,6 +375,7 @@ public void quietDownShouldSuccessWithBlockPlusNonExpiredTimeoutAndRunningExecut
assertThat(build.isBuilding(), equalTo(false));
j.assertBuildStatusSuccess(build);
assertJenkinsInQuietMode();
logging.record(XmlFile.class, Level.FINEST);
}

//
Expand Down

0 comments on commit 53fa102

Please sign in to comment.