QueueTest.taskEquality was flaky: the original task could run before we got a chance to even try scheduling a second.
@@ -118,10 +118,12 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.logging.Level;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.*;
import org.junit.Ignore;
+import org.jvnet.hudson.test.LoggerRule;
/**
* @author Kohsuke Kawaguchi
@@ -130,6 +132,9 @@ public class QueueTest {
@Rule public JenkinsRule r = new NodeProvisionerRule(-1, 0, 10);
+ @Rule
+ public LoggerRule logging = new LoggerRule().record(Queue.class, Level.FINE);
+
/**
* Checks the persistence of queue.
*/
@@ -520,17 +525,19 @@ public class QueueTest {
@Test public void taskEquality() throws Exception {
AtomicInteger cnt = new AtomicInteger();
- ScheduleResult result = r.jenkins.getQueue().schedule2(new TestTask(cnt), 0);
+ TestTask originalTask = new TestTask(cnt, true);
+ ScheduleResult result = r.jenkins.getQueue().schedule2(originalTask, 0);
assertTrue(result.isCreated());
WaitingItem item = result.getCreateItem();
assertFalse(r.jenkins.getQueue().schedule2(new TestTask(cnt), 0).isCreated());
+ originalTask.isBlocked = false;
item.getFuture().get();
r.waitUntilNoActivity();
assertEquals(1, cnt.get());
}
static class TestTask implements Queue.Task {
private final AtomicInteger cnt;
- private final boolean isBlocked;
+ boolean isBlocked;
TestTask(AtomicInteger cnt) {
this(cnt, false);
