summaryrefslogtreecommitdiffstats
path: root/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunner.java
diff options
context:
space:
mode:
Diffstat (limited to 'vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunner.java')
-rw-r--r--vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunner.java27
1 files changed, 22 insertions, 5 deletions
diff --git a/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunner.java b/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunner.java
index 0f6e26d256f..06f7d317b0e 100644
--- a/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunner.java
+++ b/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunner.java
@@ -3,8 +3,6 @@ package com.yahoo.vespa.hosted.testrunner;
import com.google.inject.Inject;
import com.yahoo.vespa.defaults.Defaults;
-import com.yahoo.vespa.testrunner.legacy.LegacyTestRunner;
-import com.yahoo.vespa.testrunner.legacy.TestProfile;
import org.fusesource.jansi.AnsiOutputStream;
import org.fusesource.jansi.HtmlAnsiOutputStream;
@@ -23,6 +21,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.SortedMap;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.function.Function;
import java.util.logging.Level;
@@ -38,7 +37,7 @@ import static java.util.logging.Level.SEVERE;
* @author valerijf
* @author jvenstad
*/
-public class TestRunner implements LegacyTestRunner {
+public class TestRunner implements com.yahoo.vespa.testrunner.TestRunner {
private static final Logger logger = Logger.getLogger(TestRunner.class.getName());
private static final Level HTML = new Level("html", 1) { };
@@ -114,24 +113,32 @@ public class TestRunner implements LegacyTestRunner {
return builder;
}
- public synchronized void test(TestProfile testProfile, byte[] testConfig) {
+ @Override
+ public synchronized CompletableFuture<?> test(Suite suite, byte[] testConfig) {
if (status == Status.RUNNING)
throw new IllegalArgumentException("Tests are already running; should not receive this request now.");
log.clear();
status = Status.RUNNING;
- new Thread(() -> runTests(testProfile, testConfig)).start();
+ return CompletableFuture.runAsync(() -> runTests(toProfile(suite), testConfig));
}
+ @Override
public Collection<LogRecord> getLog(long after) {
return log.tailMap(after + 1).values();
}
+ @Override
public synchronized Status getStatus() {
return status;
}
+ @Override
+ public boolean isSupported() {
+ return listFiles(artifactsPath).stream().anyMatch(file -> file.toString().endsWith("tests.jar"));
+ }
+
private void runTests(TestProfile testProfile, byte[] testConfig) {
ProcessBuilder builder = testBuilder.apply(testProfile);
{
@@ -210,4 +217,14 @@ public class TestRunner implements LegacyTestRunner {
private NoTestsException(String message) { super(message); }
}
+ static TestProfile toProfile(Suite suite) {
+ switch (suite) {
+ case SYSTEM_TEST: return TestProfile.SYSTEM_TEST;
+ case STAGING_SETUP_TEST: return TestProfile.STAGING_SETUP_TEST;
+ case STAGING_TEST: return TestProfile.STAGING_TEST;
+ case PRODUCTION_TEST: return TestProfile.PRODUCTION_TEST;
+ default: throw new IllegalArgumentException("Unknown test suite '" + suite + "'");
+ }
+ }
+
}