summaryrefslogtreecommitdiffstats
path: root/vespa-testrunner-components
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2021-11-17 13:58:54 +0100
committerJon Marius Venstad <venstad@gmail.com>2021-11-17 13:58:54 +0100
commitbcd400f728dd80ad4d1100efc67b0a86d6b40360 (patch)
treefa07789297fad1994867e91a4923a315e00f6e83 /vespa-testrunner-components
parent2e228e6836ac35522d517d4218f5e81c23362768 (diff)
Move TestProfile to module where it is used
Diffstat (limited to 'vespa-testrunner-components')
-rw-r--r--vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/PomXmlGenerator.java1
-rw-r--r--vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestProfile.java30
-rw-r--r--vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunner.java15
-rw-r--r--vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunnerHandler.java6
-rw-r--r--vespa-testrunner-components/src/test/java/com/yahoo/vespa/hosted/testrunner/PomXmlGeneratorTest.java1
-rw-r--r--vespa-testrunner-components/src/test/java/com/yahoo/vespa/hosted/testrunner/TestRunnerTest.java18
6 files changed, 55 insertions, 16 deletions
diff --git a/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/PomXmlGenerator.java b/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/PomXmlGenerator.java
index b3c49fc6f2d..ff66b31dfa8 100644
--- a/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/PomXmlGenerator.java
+++ b/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/PomXmlGenerator.java
@@ -2,7 +2,6 @@
package com.yahoo.vespa.hosted.testrunner;
import com.yahoo.vespa.defaults.Defaults;
-import com.yahoo.vespa.testrunner.legacy.TestProfile;
import java.nio.file.Path;
import java.util.List;
diff --git a/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestProfile.java b/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestProfile.java
new file mode 100644
index 00000000000..95a2b2723b8
--- /dev/null
+++ b/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestProfile.java
@@ -0,0 +1,30 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.hosted.testrunner;
+
+/**
+ * @author valerijf
+ * @author jvenstad
+ */
+public enum TestProfile {
+
+ SYSTEM_TEST("system, com.yahoo.vespa.tenant.systemtest.base.SystemTest", true),
+ STAGING_SETUP_TEST("staging-setup", false),
+ STAGING_TEST("staging, com.yahoo.vespa.tenant.systemtest.base.StagingTest", true),
+ PRODUCTION_TEST("production, com.yahoo.vespa.tenant.systemtest.base.ProductionTest", false);
+
+ private final String group;
+ private final boolean failIfNoTests;
+
+ TestProfile(String group, boolean failIfNoTests) {
+ this.group = group;
+ this.failIfNoTests = failIfNoTests;
+ }
+
+ public String group() {
+ return group;
+ }
+
+ public boolean failIfNoTests() {
+ return failIfNoTests;
+ }
+}
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..f31390e9933 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
@@ -4,7 +4,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;
@@ -114,14 +113,14 @@ public class TestRunner implements LegacyTestRunner {
return builder;
}
- public synchronized void test(TestProfile testProfile, byte[] testConfig) {
+ public synchronized void 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();
+ new Thread(() -> runTests(toProfile(suite), testConfig)).start();
}
public Collection<LogRecord> getLog(long after) {
@@ -210,4 +209,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 + "'");
+ }
+ }
+
}
diff --git a/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunnerHandler.java b/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunnerHandler.java
index 621f0964a40..842fc5078c1 100644
--- a/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunnerHandler.java
+++ b/vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunnerHandler.java
@@ -11,7 +11,7 @@ import com.yahoo.io.IOUtils;
import com.yahoo.slime.Cursor;
import com.yahoo.slime.JsonFormat;
import com.yahoo.slime.Slime;
-import com.yahoo.vespa.testrunner.legacy.TestProfile;
+import com.yahoo.vespa.testrunner.legacy.LegacyTestRunner;
import com.yahoo.yolean.Exceptions;
import java.io.ByteArrayOutputStream;
@@ -75,9 +75,9 @@ public class TestRunnerHandler extends LoggingRequestHandler {
final String path = request.getUri().getPath();
if (path.startsWith("/tester/v1/run/")) {
String type = lastElement(path);
- TestProfile testProfile = TestProfile.valueOf(type.toUpperCase() + "_TEST");
+ LegacyTestRunner.Suite suite = LegacyTestRunner.Suite.valueOf(type.toUpperCase() + "_TEST");
byte[] config = IOUtils.readBytes(request.getData(), 1 << 16);
- testRunner.test(testProfile, config);
+ testRunner.test(suite, config);
log.info("Started tests of type " + type + " and status is " + testRunner.getStatus());
return new Response("Successfully started " + type + " tests");
}
diff --git a/vespa-testrunner-components/src/test/java/com/yahoo/vespa/hosted/testrunner/PomXmlGeneratorTest.java b/vespa-testrunner-components/src/test/java/com/yahoo/vespa/hosted/testrunner/PomXmlGeneratorTest.java
index 391e2a0abbf..943583ae42b 100644
--- a/vespa-testrunner-components/src/test/java/com/yahoo/vespa/hosted/testrunner/PomXmlGeneratorTest.java
+++ b/vespa-testrunner-components/src/test/java/com/yahoo/vespa/hosted/testrunner/PomXmlGeneratorTest.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.testrunner;
-import com.yahoo.vespa.testrunner.legacy.TestProfile;
import org.junit.Test;
import java.io.IOException;
diff --git a/vespa-testrunner-components/src/test/java/com/yahoo/vespa/hosted/testrunner/TestRunnerTest.java b/vespa-testrunner-components/src/test/java/com/yahoo/vespa/hosted/testrunner/TestRunnerTest.java
index 4612f5b217a..68fa5427492 100644
--- a/vespa-testrunner-components/src/test/java/com/yahoo/vespa/hosted/testrunner/TestRunnerTest.java
+++ b/vespa-testrunner-components/src/test/java/com/yahoo/vespa/hosted/testrunner/TestRunnerTest.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.testrunner;
-import com.yahoo.vespa.testrunner.legacy.TestProfile;
+import com.yahoo.vespa.testrunner.legacy.LegacyTestRunner;
import org.fusesource.jansi.Ansi;
import org.junit.Before;
import org.junit.Rule;
@@ -14,6 +14,8 @@ import java.nio.file.Path;
import java.util.Iterator;
import java.util.logging.LogRecord;
+import static com.yahoo.vespa.testrunner.legacy.LegacyTestRunner.Suite.STAGING_TEST;
+import static com.yahoo.vespa.testrunner.legacy.LegacyTestRunner.Suite.SYSTEM_TEST;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -48,7 +50,7 @@ public class TestRunnerTest {
public void ansiCodesAreConvertedToHtml() throws InterruptedException {
TestRunner runner = new TestRunner(artifactsPath, testPath, logFile, configFile, settingsFile,
__ -> new ProcessBuilder("echo", Ansi.ansi().fg(Ansi.Color.RED).a("Hello!").reset().toString()));
- runner.test(TestProfile.SYSTEM_TEST, new byte[0]);
+ runner.test(SYSTEM_TEST, new byte[0]);
while (runner.getStatus() == TestRunner.Status.RUNNING) {
Thread.sleep(10);
}
@@ -65,7 +67,7 @@ public class TestRunnerTest {
Files.delete(artifactsPath.resolve("my-tests.jar"));
TestRunner runner = new TestRunner(artifactsPath, testPath, logFile, configFile, settingsFile,
__ -> new ProcessBuilder("This is a command that doesn't exist, for sure!"));
- runner.test(TestProfile.SYSTEM_TEST, new byte[0]);
+ runner.test(SYSTEM_TEST, new byte[0]);
while (runner.getStatus() == TestRunner.Status.RUNNING) {
Thread.sleep(10);
}
@@ -81,7 +83,7 @@ public class TestRunnerTest {
public void errorLeadsToError() throws InterruptedException {
TestRunner runner = new TestRunner(artifactsPath, testPath, logFile, configFile, settingsFile,
__ -> new ProcessBuilder("false"));
- runner.test(TestProfile.SYSTEM_TEST, new byte[0]);
+ runner.test(SYSTEM_TEST, new byte[0]);
while (runner.getStatus() == TestRunner.Status.RUNNING) {
Thread.sleep(10);
}
@@ -93,7 +95,7 @@ public class TestRunnerTest {
public void failureLeadsToFailure() throws InterruptedException {
TestRunner runner = new TestRunner(artifactsPath, testPath, logFile, configFile, settingsFile,
__ -> new ProcessBuilder("false"));
- runner.test(TestProfile.SYSTEM_TEST, new byte[0]);
+ runner.test(SYSTEM_TEST, new byte[0]);
while (runner.getStatus() == TestRunner.Status.RUNNING) {
Thread.sleep(10);
}
@@ -105,7 +107,7 @@ public class TestRunnerTest {
public void filesAreGenerated() throws InterruptedException, IOException {
TestRunner runner = new TestRunner(artifactsPath, testPath, logFile, configFile, settingsFile,
__ -> new ProcessBuilder("echo", "Hello!"));
- runner.test(TestProfile.SYSTEM_TEST, "config".getBytes());
+ runner.test(SYSTEM_TEST, "config".getBytes());
while (runner.getStatus() == TestRunner.Status.RUNNING) {
Thread.sleep(10);
}
@@ -119,7 +121,7 @@ public class TestRunnerTest {
public void runnerCanBeReused() throws InterruptedException, IOException {
TestRunner runner = new TestRunner(artifactsPath, testPath, logFile, configFile, settingsFile,
__ -> new ProcessBuilder("sleep", "0.1"));
- runner.test(TestProfile.SYSTEM_TEST, "config".getBytes());
+ runner.test(SYSTEM_TEST, "config".getBytes());
assertEquals(TestRunner.Status.RUNNING, runner.getStatus());
while (runner.getStatus() == TestRunner.Status.RUNNING) {
@@ -128,7 +130,7 @@ public class TestRunnerTest {
assertEquals(1, runner.getLog(-1).size());
assertEquals(TestRunner.Status.SUCCESS, runner.getStatus());
- runner.test(TestProfile.STAGING_TEST, "newConfig".getBytes());
+ runner.test(STAGING_TEST, "newConfig".getBytes());
while (runner.getStatus() == TestRunner.Status.RUNNING) {
Thread.sleep(10);
}