summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2014-07-25 14:29:42 +0300
committerVaadin Code Review <review@vaadin.com>2014-07-28 12:37:09 +0000
commit0182043e6cdb7ced238fe97090cc337941b11779 (patch)
tree8861779b984e31f52305bfd283c78fd52abbfa67 /uitest
parent441371ac98b2a99822ca1639a6823b23be93c229 (diff)
downloadvaadin-framework-0182043e6cdb7ced238fe97090cc337941b11779.tar.gz
vaadin-framework-0182043e6cdb7ced238fe97090cc337941b11779.zip
Reduce TestBench 3 socket timeout (#14298)
Change-Id: I45907c5c22bcea1a403af71ecbf5236e5669ab38
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/tb3/TB3Runner.java37
1 files changed, 36 insertions, 1 deletions
diff --git a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java
index 5b5a6dcf39..4241b9fa6c 100644
--- a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java
+++ b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java
@@ -17,8 +17,10 @@
package com.vaadin.tests.tb3;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
@@ -26,6 +28,8 @@ import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.HttpParams;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runners.BlockJUnit4ClassRunner;
@@ -34,6 +38,8 @@ import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.Statement;
import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.remote.HttpCommandExecutor;
+import org.openqa.selenium.remote.internal.HttpClientFactory;
import com.vaadin.tests.annotations.TestCategory;
import com.vaadin.tests.tb3.AbstractTB3Test.BrowserUtil;
@@ -50,6 +56,13 @@ import com.vaadin.tests.tb3.MultiBrowserTest.Browser;
public class TB3Runner extends BlockJUnit4ClassRunner {
/**
+ * Socket timeout for HTTP connections to the grid hub. The connection is
+ * closed after 15 minutes of inactivity to avoid builds hanging for up to
+ * three hours per connection if the test client crashes/hangs.
+ */
+ private static final int SOCKET_TIMEOUT = 15 * 60 * 1000;
+
+ /**
* This is the total limit of actual JUnit test instances run in parallel
*/
private static final int MAX_CONCURRENT_TESTS;
@@ -67,12 +80,34 @@ public class TB3Runner extends BlockJUnit4ClassRunner {
MAX_CONCURRENT_TESTS = 50;
}
service = Executors.newFixedThreadPool(MAX_CONCURRENT_TESTS);
+
+ // reduce socket timeout to avoid tests hanging for three hours
+ try {
+ Field field = HttpCommandExecutor.class
+ .getDeclaredField("httpClientFactory");
+ assert (Modifier.isStatic(field.getModifiers()));
+ field.setAccessible(true);
+ field.set(null, new HttpClientFactory() {
+ @Override
+ public HttpParams getHttpParams() {
+ HttpParams params = super.getHttpParams();
+ // fifteen minute timeout
+ HttpConnectionParams.setSoTimeout(params, SOCKET_TIMEOUT);
+ return params;
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException(
+ "Changing socket timeout for TestBench failed", e);
+ }
}
protected static boolean localWebDriverIsUsed() {
String useLocalWebDriver = System.getProperty("useLocalWebDriver");
- return useLocalWebDriver != null && useLocalWebDriver.toLowerCase().equals("true");
+ return useLocalWebDriver != null
+ && useLocalWebDriver.toLowerCase().equals("true");
}
public TB3Runner(Class<?> klass) throws InitializationError {