aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-testrunner-components
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2020-08-24 16:10:53 +0200
committerJon Marius Venstad <venstad@gmail.com>2020-08-24 16:10:53 +0200
commit163b975b6d6899c434fe8502123a872aaaf4d12f (patch)
treed58f25a37412b0f98a21c4a0644186830d030a8f /vespa-testrunner-components
parent8580fba57538e23e5d0e4192f9d18f14a8d9cd7a (diff)
Treat no test jar like no staging/system tests: failure
Diffstat (limited to 'vespa-testrunner-components')
-rw-r--r--vespa-testrunner-components/src/main/java/com/yahoo/vespa/hosted/testrunner/TestRunner.java9
-rw-r--r--vespa-testrunner-components/src/test/java/com/yahoo/vespa/hosted/testrunner/TestRunnerTest.java20
2 files changed, 23 insertions, 6 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 4308b0bba4c..5593b48aaa9 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
@@ -178,7 +178,7 @@ public class TestRunner implements LegacyTestRunner {
exception.printStackTrace(file);
}
catch (IOException ignored) { }
- status = Status.ERROR;
+ status = exception instanceof NoTestsException ? Status.FAILURE : Status.ERROR;
return;
}
status = success ? Status.SUCCESS : Status.FAILURE;
@@ -187,7 +187,7 @@ public class TestRunner implements LegacyTestRunner {
private void writeTestApplicationPom(TestProfile testProfile) throws IOException {
List<Path> files = listFiles(artifactsPath);
Path testJar = files.stream().filter(file -> file.toString().endsWith("tests.jar")).findFirst()
- .orElseThrow(() -> new IllegalStateException("No file ending with 'tests.jar' found under '" + artifactsPath + "'!"));
+ .orElseThrow(() -> new NoTestsException("No file ending with 'tests.jar' found under '" + artifactsPath + "'!"));
String pomXml = PomXmlGenerator.generatePomXml(testProfile, files, testJar);
testPath.toFile().mkdirs();
Files.write(testPath.resolve("pom.xml"), pomXml.getBytes());
@@ -204,4 +204,9 @@ public class TestRunner implements LegacyTestRunner {
}
}
+
+ static class NoTestsException extends RuntimeException {
+ private NoTestsException(String message) { super(message); }
+ }
+
}
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 b2c7a77240b..8e6b1b45e2a 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
@@ -15,7 +15,6 @@ import java.util.Iterator;
import java.util.logging.LogRecord;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
@@ -62,7 +61,8 @@ public class TestRunnerTest {
}
@Test
- public void errorLeadsToError() throws InterruptedException {
+ public void noTestJarIsAFailure() throws InterruptedException, IOException {
+ 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]);
@@ -73,8 +73,20 @@ public class TestRunnerTest {
log.next();
LogRecord record = log.next();
assertEquals("Failed to execute maven command: This is a command that doesn't exist, for sure!", record.getMessage());
- assertNotNull(record.getThrown());
- assertEquals(TestRunner.Status.ERROR, runner.getStatus());
+ assertTrue(record.getThrown() instanceof TestRunner.NoTestsException);
+ assertEquals(TestRunner.Status.FAILURE, runner.getStatus());
+ }
+
+ @Test
+ 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]);
+ while (runner.getStatus() == TestRunner.Status.RUNNING) {
+ Thread.sleep(10);
+ }
+ assertEquals(1, runner.getLog(-1).size());
+ assertEquals(TestRunner.Status.FAILURE, runner.getStatus());
}
@Test