diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2021-11-17 22:14:17 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2021-11-17 22:14:17 +0100 |
commit | c7a040a43aa3f043e387b6a235aeda0c484839ce (patch) | |
tree | e45624b4b3def07f6de8db7cf134a5ee0034df6e /vespa-osgi-testrunner | |
parent | 68df4a951a952ac1db1129d65641c2e869a2f58f (diff) |
Add config def and teest
Diffstat (limited to 'vespa-osgi-testrunner')
3 files changed, 74 insertions, 2 deletions
diff --git a/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/VespaCliTestRunner.java b/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/VespaCliTestRunner.java index d8ff6334382..831ec24ac5f 100644 --- a/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/VespaCliTestRunner.java +++ b/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/VespaCliTestRunner.java @@ -84,7 +84,7 @@ public class VespaCliTestRunner implements TestRunner { log(Level.INFO, line, null); }); - status.set(process.waitFor() == 0 ? SUCCESS : process.exitValue() == 3 ? FAILURE : ERROR); + status.set(process.waitFor() == 0 ? SUCCESS : process.waitFor() == 3 ? FAILURE : ERROR); } catch (Exception e) { if (process != null) @@ -95,7 +95,7 @@ public class VespaCliTestRunner implements TestRunner { } } - private ProcessBuilder testRunProcessBuilder(Suite suite, String endpointsConfig) { + ProcessBuilder testRunProcessBuilder(Suite suite, String endpointsConfig) { Path suitePath = getChildDirectory(artifactsPath, "tests") .flatMap(testsPath -> getChildDirectory(testsPath, toSuiteDirectoryName(suite))) .orElseThrow(() -> new IllegalStateException("No tests found, for suite '" + suite + "'")); diff --git a/vespa-osgi-testrunner/src/main/resources/configdefinitions/vespa-cli-test-runner.def b/vespa-osgi-testrunner/src/main/resources/configdefinitions/vespa-cli-test-runner.def new file mode 100644 index 00000000000..7671096477e --- /dev/null +++ b/vespa-osgi-testrunner/src/main/resources/configdefinitions/vespa-cli-test-runner.def @@ -0,0 +1,5 @@ +# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package=com.yahoo.vespa.testrunner + +artifactsPath path +useAthenzCredentials bool default=false
\ No newline at end of file diff --git a/vespa-osgi-testrunner/src/test/java/com/yahoo/vespa/testrunner/VespaCliTestRunnerTest.java b/vespa-osgi-testrunner/src/test/java/com/yahoo/vespa/testrunner/VespaCliTestRunnerTest.java new file mode 100644 index 00000000000..68d44a386f8 --- /dev/null +++ b/vespa-osgi-testrunner/src/test/java/com/yahoo/vespa/testrunner/VespaCliTestRunnerTest.java @@ -0,0 +1,67 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.testrunner; + +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * @author jonmv + */ +class VespaCliTestRunnerTest { + + @Test + void testEndpointsConfig() throws IOException { + byte[] testConfig = ("{\n" + + " \"application\": \"t:a:i\",\n" + + " \"zone\": \"dev.aws-us-east-1c\",\n" + + " \"system\": \"publiccd\",\n" + + " \"isCI\": true,\n" + + " \"zoneEndpoints\": {\n" + + " \"dev.aws-us-east-1c\": {\n" + + " \"default\": \"https://dev.endpoint:443/\"\n" + + " },\n" + + " \"prod.aws-us-east-1a\": {\n" + + " \"default\": \"https://prod.endpoint:443/\"\n" + + " }\n" + + " },\n" + + " \"clusters\": {\n" + + " \"prod.aws-us-east-1c\": [\n" + + " \"documents\"\n" + + " ]\n" + + " }\n" + + "}\n").getBytes(StandardCharsets.UTF_8); + + assertEquals("{\"endpoints\":[{\"cluster\":\"default\",\"url\":\"https://dev.endpoint:443/\"}]}", + VespaCliTestRunner.toEndpointsConfig(testConfig)); + } + + @Test + void testSuitePathDiscovery() throws IOException { + Path temp = Files.createTempDirectory("vespa-cli-test-runner-test-"); + temp.toFile().deleteOnExit(); + VespaCliTestRunner runner = new VespaCliTestRunner(temp); + assertFalse(runner.isSupported()); + + Path tests = Files.createDirectory(temp.resolve("tests")); + assertTrue(runner.isSupported()); + IllegalStateException expected = assertThrows(IllegalStateException.class, + () -> runner.testRunProcessBuilder(TestRunner.Suite.SYSTEM_TEST, "")); + assertEquals("No tests found, for suite 'SYSTEM_TEST'", expected.getMessage()); + + Path systemTests = Files.createDirectory(tests.resolve("system-test")); + ProcessBuilder builder = runner.testRunProcessBuilder(TestRunner.Suite.SYSTEM_TEST, "config"); + assertEquals(systemTests.toFile(), builder.directory()); + assertEquals(List.of("vespa", "test", "--endpoints", "config"), builder.command()); + } + +} |