diff options
author | Artur Signell <artur@vaadin.com> | 2013-09-24 18:19:45 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-09-26 06:15:27 +0000 |
commit | bd0ae0581f265be57374b236cfe1b71043ab69aa (patch) | |
tree | a1db9e95a17db7895e032a3a8721f4f31ee48457 /uitest | |
parent | d3261d77a45a24edcb4e77370e12c8e88c119d35 (diff) | |
download | vaadin-framework-bd0ae0581f265be57374b236cfe1b71043ab69aa.tar.gz vaadin-framework-bd0ae0581f265be57374b236cfe1b71043ab69aa.zip |
Limit the number of tests run concurrently (#12572)
Change-Id: I015e92ccc9be963543032c14dd9d051bcba58e53
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/tb3/ParallelScheduler.java | 13 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/tb3/TB3Runner.java | 16 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java | 17 |
3 files changed, 42 insertions, 4 deletions
diff --git a/uitest/src/com/vaadin/tests/tb3/ParallelScheduler.java b/uitest/src/com/vaadin/tests/tb3/ParallelScheduler.java index f8013169fa..912d7d010e 100644 --- a/uitest/src/com/vaadin/tests/tb3/ParallelScheduler.java +++ b/uitest/src/com/vaadin/tests/tb3/ParallelScheduler.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import java.util.concurrent.Future; import org.junit.runners.model.RunnerScheduler; @@ -33,8 +32,18 @@ import org.junit.runners.model.RunnerScheduler; */ public class ParallelScheduler implements RunnerScheduler { private final List<Future<Object>> fResults = new ArrayList<Future<Object>>(); + private ExecutorService fService; - private final ExecutorService fService = Executors.newCachedThreadPool(); + /** + * Creates a parallel scheduler which will use the given executor service + * when submitting test jobs. + * + * @param service + * The service to use for tests + */ + public ParallelScheduler(ExecutorService service) { + fService = service; + } @Override public void schedule(final Runnable childStatement) { diff --git a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java index 5860ac42c0..b612b17caa 100644 --- a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java +++ b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java @@ -19,6 +19,8 @@ package com.vaadin.tests.tb3; import java.lang.reflect.Method; import java.util.LinkedList; import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import org.junit.Test; import org.junit.runners.BlockJUnit4ClassRunner; @@ -40,9 +42,21 @@ import com.vaadin.tests.tb3.AbstractTB3Test.BrowserUtil; */ public class TB3Runner extends BlockJUnit4ClassRunner { + /** + * This is the total limit of actual JUnit test instances run in parallel + */ + private static final int MAX_CONCURRENT_TESTS = 50; + + /** + * This is static so it is shared by all tests running concurrently on the + * same machine and thus can limit the number of threads in use. + */ + private static final ExecutorService service = Executors + .newFixedThreadPool(MAX_CONCURRENT_TESTS); + public TB3Runner(Class<?> klass) throws InitializationError { super(klass); - setScheduler(new ParallelScheduler()); + setScheduler(new ParallelScheduler(service)); } @Override diff --git a/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java b/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java index dc187000d2..e1c8edfd60 100644 --- a/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java +++ b/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java @@ -28,6 +28,8 @@ import java.util.Collections; import java.util.Comparator; import java.util.Enumeration; import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.jar.JarEntry; import org.junit.runners.Suite; @@ -41,11 +43,24 @@ import org.junit.runners.model.InitializationError; */ public class TB3TestSuite extends Suite { + /** + * This only restricts the number of test suites running concurrently. The + * number of tests to run concurrently are configured in {@link TB3Runner}. + */ + private static final int MAX_CONCURRENT_TEST_SUITES = 20; + + /** + * This is static so it is shared by all test suites running concurrently on + * the same machine and thus can limit the number of threads in use. + */ + private final ExecutorService service = Executors + .newFixedThreadPool(MAX_CONCURRENT_TEST_SUITES); + public TB3TestSuite(Class<?> klass, Class<? extends AbstractTB3Test> baseClass, String basePackage, String[] ignorePackages) throws InitializationError { super(klass, findTests(baseClass, basePackage, ignorePackages)); - setScheduler(new ParallelScheduler()); + setScheduler(new ParallelScheduler(service)); } /** |