提交 a5ffd0c2 编写于 作者: C Christoph Kutzinski

modify latch to use CountDownLatch and wait 30 seconds more for builds as test...

modify latch to use CountDownLatch and wait 30 seconds more for builds as test likes to time-out a lot
上级 eb1e08c5
......@@ -28,6 +28,8 @@ import hudson.Launcher;
import hudson.model.*;
import hudson.slaves.NodeProvisioner.NodeProvisionerInvoker;
import hudson.tasks.Builder;
import hudson.util.TimeUnit2;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.SleepBuilder;
......@@ -35,6 +37,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
......@@ -69,16 +72,17 @@ public class NodeProvisionerTest extends HudsonTestCase {
*/
static class Latch {
/** Initial value */
public final int init;
private int n;
public final CountDownLatch counter;
private final int init;
Latch(int n) {
this.n = init = n;
this.init = n;
this.counter = new CountDownLatch(n);
}
synchronized void block() throws InterruptedException {
if(--n==0) notifyAll(); // wake up everyone else
else wait(60*1000); // if a test takes t oo long, abort.
void block() throws InterruptedException {
this.counter.countDown();
this.counter.await(60, TimeUnit.SECONDS);
}
/**
......@@ -232,7 +236,7 @@ public class NodeProvisionerTest extends HudsonTestCase {
System.out.println("Waiting for a completion");
for (Future<FreeStyleBuild> f : builds) {
try {
assertBuildStatus(Result.SUCCESS, f.get(60, TimeUnit.SECONDS));
assertBuildStatus(Result.SUCCESS, f.get(90, TimeUnit.SECONDS));
} catch (TimeoutException e) {
// time out so that the automated test won't hang forever, even when we have bugs
System.out.println("Build didn't complete in time");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册