提交 d7b031ae 编写于 作者: O Oliver Gondža

Merge pull request #1006 from mrebasti/jenkins-test-timeout

......@@ -27,6 +27,7 @@ package org.jvnet.hudson.test;
import com.gargoylesoftware.htmlunit.AlertHandler;
import com.gargoylesoftware.htmlunit.html.HtmlImage;
import com.google.inject.Injector;
import hudson.ClassicPluginStrategy;
import hudson.CloseProofOutputStream;
import hudson.DNSMultiCast;
......@@ -183,7 +184,9 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory;
import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest;
import com.gargoylesoftware.htmlunit.xml.XmlPage;
import java.net.HttpURLConnection;
import jenkins.model.JenkinsLocationConfiguration;
/**
......@@ -255,7 +258,7 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
/**
* Number of seconds until the test times out.
*/
public int timeout = 180;
public int timeout = Integer.getInteger("jenkins.test.timeout", 180);
private volatile Timer timeoutTimer;
......@@ -355,8 +358,10 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
timeoutTimer.schedule(new TimerTask() {
@Override
public void run() {
if (timeoutTimer!=null)
if (timeoutTimer!=null) {
LOGGER.warning(String.format("Test timed out (after %d seconds).", timeout));
testThread.interrupt();
}
}
}, TimeUnit.SECONDS.toMillis(timeout));
}
......
......@@ -292,7 +292,7 @@ public class JenkinsRule implements TestRule, MethodRule, RootAction {
/**
* Number of seconds until the test times out.
*/
public int timeout = 90;
public int timeout = Integer.getInteger("jenkins.test.timeout", 180);
private volatile Timer timeoutTimer;
......@@ -355,6 +355,8 @@ public class JenkinsRule implements TestRule, MethodRule, RootAction {
JenkinsLocationConfiguration.get().setUrl(getURL().toString());
for( Descriptor d : jenkins.getExtensionList(Descriptor.class) )
d.load();
setUpTimeout();
}
/**
......@@ -372,7 +374,7 @@ public class JenkinsRule implements TestRule, MethodRule, RootAction {
sites.clear();
sites.add(new UpdateSite("default", updateCenterUrl));
}
protected void setUpTimeout() {
if (timeout<=0) return; // no timeout
......@@ -381,8 +383,10 @@ public class JenkinsRule implements TestRule, MethodRule, RootAction {
timeoutTimer.schedule(new TimerTask() {
@Override
public void run() {
if (timeoutTimer!=null)
if (timeoutTimer!=null) {
LOGGER.warning(String.format("Test timed out (after %d seconds).", timeout));
testThread.interrupt();
}
}
}, TimeUnit.SECONDS.toMillis(timeout));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册