Skip to content

Commit

Permalink
[JENKINS-21932] Added tests to reproduce JENKINS-21932, Future#get do…
Browse files Browse the repository at this point in the history
…es not abort even when a task in the queue is canceled.
  • Loading branch information
ikedam committed Mar 15, 2014
1 parent 55eb795 commit 35dfc75
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/src/test/java/hudson/model/QueueTest.java
Expand Up @@ -58,6 +58,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -556,4 +557,31 @@ public String getDisplayName() {
assertFalse("Project " + project2.getDisplayName() + " stuck in pendings",item.task.getName().equals(project2.getName()));
}
}

public void testCancelInQueue() throws Exception
{
DumbSlave slave = createSlave();
assertTrue(slave.toComputer().isOffline());

FreeStyleProject p = createFreeStyleProject();
p.setAssignedNode(slave);

QueueTaskFuture<FreeStyleBuild> f = p.scheduleBuild2(0);
try {
f.get(3, TimeUnit.SECONDS);
fail("Should time out (as the slave is offline).");
} catch (TimeoutException e) {
}

Queue.Item item = Queue.getInstance().getItem(p);
assertNotNull(item);
Queue.getInstance().doCancelItem(item.id);
assertNull(Queue.getInstance().getItem(p));

try {
f.get(10, TimeUnit.SECONDS);
fail("Should not get (as it is cancelled).");
} catch (CancellationException e) {
}
}
}

0 comments on commit 35dfc75

Please sign in to comment.