diff options
author | Morten Tokle <mortent@verizonmedia.com> | 2020-07-02 12:57:39 +0200 |
---|---|---|
committer | Morten Tokle <mortent@verizonmedia.com> | 2020-07-02 12:58:35 +0200 |
commit | 4c62cb4cc5d29f4c4b9dc89c2b046c9ea7d8185e (patch) | |
tree | fc83224df58c3fd8fc6890f18854ac79e70cee7d /hosted-api | |
parent | 87372a16c7ec43a5babcf44bb5ff109ac3369b2e (diff) |
Support staging setup tests
Diffstat (limited to 'hosted-api')
-rw-r--r-- | hosted-api/src/main/java/ai/vespa/hosted/api/TestDescriptor.java | 14 | ||||
-rw-r--r-- | hosted-api/src/test/java/ai/vespa/hosted/api/TestDescriptorTest.java | 16 |
2 files changed, 24 insertions, 6 deletions
diff --git a/hosted-api/src/main/java/ai/vespa/hosted/api/TestDescriptor.java b/hosted-api/src/main/java/ai/vespa/hosted/api/TestDescriptor.java index 08cd3932ae7..6074bd73a20 100644 --- a/hosted-api/src/main/java/ai/vespa/hosted/api/TestDescriptor.java +++ b/hosted-api/src/main/java/ai/vespa/hosted/api/TestDescriptor.java @@ -26,6 +26,7 @@ public class TestDescriptor { private static final String JSON_FIELD_CONFIGURED_TESTS = "configuredTests"; private static final String JSON_FIELD_SYSTEM_TESTS = "systemTests"; private static final String JSON_FIELD_STAGING_TESTS = "stagingTests"; + private static final String JSON_FIELD_STAGING_SETUP_TESTS = "stagingSetupTests"; private static final String JSON_FIELD_PRODUCTION_TESTS = "productionTests"; private final Map<TestCategory, List<String>> configuredTestClasses; @@ -43,20 +44,22 @@ public class TestDescriptor { var testRoot = root.field(JSON_FIELD_CONFIGURED_TESTS); var systemTests = getJsonArray(testRoot, JSON_FIELD_SYSTEM_TESTS); var stagingTests = getJsonArray(testRoot, JSON_FIELD_STAGING_TESTS); + var stagingSetupTests = getJsonArray(testRoot, JSON_FIELD_STAGING_SETUP_TESTS); var productionTests = getJsonArray(testRoot, JSON_FIELD_PRODUCTION_TESTS); - return new TestDescriptor(version, toMap(systemTests, stagingTests, productionTests)); + return new TestDescriptor(version, toMap(systemTests, stagingTests, stagingSetupTests, productionTests)); } public static TestDescriptor from( - String version, List<String> systemTests, List<String> stagingTests, List<String> productionTests) { - return new TestDescriptor(version, toMap(systemTests, stagingTests, productionTests)); + String version, List<String> systemTests, List<String> stagingTests, List<String> stagingSetupTests, List<String> productionTests) { + return new TestDescriptor(version, toMap(systemTests, stagingTests, stagingSetupTests, productionTests)); } private static Map<TestCategory, List<String>> toMap( - List<String> systemTests, List<String> stagingTests, List<String> productionTests) { + List<String> systemTests, List<String> stagingTests, List<String> stagingSetupTests, List<String> productionTests) { return Map.of( TestCategory.systemtest, systemTests, TestCategory.stagingtest, stagingTests, + TestCategory.stagingsetuptest, stagingSetupTests, TestCategory.productiontest, productionTests ); } @@ -81,6 +84,7 @@ public class TestDescriptor { addJsonArrayForTests(tests, JSON_FIELD_SYSTEM_TESTS, TestCategory.systemtest); addJsonArrayForTests(tests, JSON_FIELD_STAGING_TESTS, TestCategory.stagingtest); addJsonArrayForTests(tests, JSON_FIELD_PRODUCTION_TESTS, TestCategory.productiontest); + addJsonArrayForTests(tests, JSON_FIELD_STAGING_SETUP_TESTS, TestCategory.stagingsetuptest); ByteArrayOutputStream out = new ByteArrayOutputStream(); uncheck(() -> new JsonFormat(/*compact*/false).encode(out, slime)); return out.toString(); @@ -100,5 +104,5 @@ public class TestDescriptor { '}'; } - public enum TestCategory {systemtest, stagingtest, productiontest} + public enum TestCategory {systemtest, stagingsetuptest, stagingtest, productiontest} } diff --git a/hosted-api/src/test/java/ai/vespa/hosted/api/TestDescriptorTest.java b/hosted-api/src/test/java/ai/vespa/hosted/api/TestDescriptorTest.java index 7e59af9ced8..f45c1219e9d 100644 --- a/hosted-api/src/test/java/ai/vespa/hosted/api/TestDescriptorTest.java +++ b/hosted-api/src/test/java/ai/vespa/hosted/api/TestDescriptorTest.java @@ -33,14 +33,19 @@ public class TestDescriptorTest { var stagingTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.stagingtest); Assertions.assertIterableEquals(Collections.emptyList(), stagingTests); + var stagingSetupTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.stagingtest); + Assertions.assertIterableEquals(Collections.emptyList(), stagingSetupTests); + var productionTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.productiontest); Assertions.assertIterableEquals(Collections.emptyList(), productionTests); } @Test public void parsesDescriptorFile() { + //language=JSON String testDescriptor = "{\n" + - " \"version\": \"1.0\",\n" + + " \"" + + "version\": \"1.0\",\n" + " \"configuredTests\": {\n" + " \"systemTests\": [\n" + " \"ai.vespa.test.SystemTest1\",\n" + @@ -50,6 +55,10 @@ public class TestDescriptorTest { " \"ai.vespa.test.StagingTest1\",\n" + " \"ai.vespa.test.StagingTest2\"\n" + " ],\n" + + " \"stagingSetupTests\": [\n" + + " \"ai.vespa.test.StagingSetupTest1\",\n" + + " \"ai.vespa.test.StagingSetupTest2\"\n" + + " ],\n" + " \"productionTests\": [\n" + " \"ai.vespa.test.ProductionTest1\",\n" + " \"ai.vespa.test.ProductionTest2\"\n" + @@ -65,8 +74,13 @@ public class TestDescriptorTest { var stagingTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.stagingtest); Assertions.assertIterableEquals(List.of("ai.vespa.test.StagingTest1", "ai.vespa.test.StagingTest2"), stagingTests); + var stagingSetupTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.stagingsetuptest); + Assertions.assertIterableEquals(List.of("ai.vespa.test.StagingSetupTest1", "ai.vespa.test.StagingSetupTest2"), stagingSetupTests); + var productionTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.productiontest); Assertions.assertIterableEquals(List.of("ai.vespa.test.ProductionTest1", "ai.vespa.test.ProductionTest2"), productionTests); + + JsonTestHelper.assertJsonEquals(testClassDescriptor.toJson(), testDescriptor); } @Test |