diff options
author | Morten Tokle <mortent@verizonmedia.com> | 2020-06-22 15:02:33 +0200 |
---|---|---|
committer | Morten Tokle <mortent@verizonmedia.com> | 2020-06-22 15:06:26 +0200 |
commit | 44491faa8c6362260a71fa3814adb4e7aeaaf198 (patch) | |
tree | 814a33b7f718f637f1b4bff28c802a28d8a39262 /vespa-osgi-testrunner | |
parent | b580bf96165691622f19e73d445f346fe29fe74f (diff) |
Fix review comments
Diffstat (limited to 'vespa-osgi-testrunner')
4 files changed, 13 insertions, 69 deletions
diff --git a/vespa-osgi-testrunner/pom.xml b/vespa-osgi-testrunner/pom.xml index 31bf6eba18b..5ed9f75c9eb 100644 --- a/vespa-osgi-testrunner/pom.xml +++ b/vespa-osgi-testrunner/pom.xml @@ -18,7 +18,7 @@ <dependency> <groupId>com.yahoo.vespa</groupId> <artifactId>container-dev</artifactId> - <version>7-SNAPSHOT</version> + <version>${project.version}</version> <scope>provided</scope> </dependency> @@ -60,9 +60,15 @@ <dependency> <groupId>com.yahoo.vespa</groupId> <artifactId>tenant-cd-api</artifactId> - <version>7-SNAPSHOT</version> + <version>${project.version}</version> <scope>provided</scope> </dependency> + <dependency> + <groupId>com.yahoo.vespa</groupId> + <artifactId>hosted-api</artifactId> + <version>${project.version}</version> + <scope>compile</scope> + </dependency> </dependencies> <build> diff --git a/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/JunitHandler.java b/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/JunitHandler.java index 3db2846da4e..cb7d5b8df6b 100644 --- a/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/JunitHandler.java +++ b/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/JunitHandler.java @@ -1,6 +1,7 @@ // Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.testrunner; +import ai.vespa.hosted.api.TestDescriptor; import ai.vespa.hosted.cd.internal.TestRuntimeProvider; import com.google.inject.Inject; import com.yahoo.container.handler.metrics.JsonResponse; @@ -8,7 +9,6 @@ import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.container.jdisc.LoggingRequestHandler; import com.yahoo.container.logging.AccessLog; -import com.yahoo.io.IOUtils; import com.yahoo.restapi.ErrorResponse; import com.yahoo.restapi.MessageResponse; import org.osgi.framework.Bundle; @@ -39,7 +39,7 @@ public class JunitHandler extends LoggingRequestHandler { TestDescriptor.TestCategory category = property("category", TestDescriptor.TestCategory.systemtest, httpRequest, TestDescriptor.TestCategory::valueOf); try { - testRuntimeProvider.initialize(IOUtils.readBytes(httpRequest.getData(), 1000 * 1000)); + testRuntimeProvider.initialize(httpRequest.getData().readAllBytes()); } catch (IOException e) { return new ErrorResponse(500, "testruntime-initialization", "Exception reading test config"); } diff --git a/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/JunitRunner.java b/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/JunitRunner.java index 68d3ea4c124..69134f86be0 100644 --- a/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/JunitRunner.java +++ b/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/JunitRunner.java @@ -1,6 +1,7 @@ // Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.testrunner; +import ai.vespa.hosted.api.TestDescriptor; import com.google.inject.Inject; import com.yahoo.component.AbstractComponent; import com.yahoo.exception.ExceptionUtils; @@ -13,7 +14,6 @@ import com.yahoo.yolean.Exceptions; import org.junit.jupiter.engine.JupiterTestEngine; import org.junit.platform.engine.discovery.DiscoverySelectors; import org.junit.platform.launcher.Launcher; -import org.junit.platform.launcher.LauncherConstants; import org.junit.platform.launcher.LauncherDiscoveryRequest; import org.junit.platform.launcher.core.LauncherConfig; import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder; @@ -63,7 +63,7 @@ public class JunitRunner extends AbstractComponent { } public TestDescriptor loadTestDescriptor(Bundle bundle) { - URL resource = bundle.getEntry("META-INF/testClasses.json"); + URL resource = bundle.getEntry(TestDescriptor.DEFAULT_FILENAME); TestDescriptor testDescriptor; try { var jsonDescriptor = IOUtils.readAll(resource.openStream(), Charset.defaultCharset()).trim(); @@ -71,7 +71,7 @@ public class JunitRunner extends AbstractComponent { logger.info( "Test classes in bundle :" + testDescriptor.toString()); return testDescriptor; } catch (IOException e) { - throw new RuntimeException("Could not load META-INF/testClasses.json [" + e.getMessage() + "]"); + throw new RuntimeException("Could not load " + TestDescriptor.DEFAULT_FILENAME + " [" + e.getMessage() + "]"); } } @@ -99,8 +99,6 @@ public class JunitRunner extends AbstractComponent { .selectors( testClasses.stream().map(DiscoverySelectors::selectClass).collect(Collectors.toList()) ) - .configurationParameter(LauncherConstants.CAPTURE_STDERR_PROPERTY_NAME,"true") - .configurationParameter(LauncherConstants.CAPTURE_STDOUT_PROPERTY_NAME,"true") .build(); var launcherConfig = LauncherConfig.builder() diff --git a/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestDescriptor.java b/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestDescriptor.java deleted file mode 100644 index 1c7092de93a..00000000000 --- a/vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/TestDescriptor.java +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.testrunner; - -import com.yahoo.slime.Cursor; -import com.yahoo.slime.Inspector; -import com.yahoo.slime.SlimeStream; -import com.yahoo.slime.SlimeUtils; - -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * @author mortent - */ -public class TestDescriptor { - private final Map<TestCategory, List<String>> configuredTestClasses; - private final String version; - - private TestDescriptor(String version, Map<TestCategory, List<String>> configuredTestClasses) { - this.version = version; - this.configuredTestClasses = configuredTestClasses; - } - - public static TestDescriptor fromJsonString(String testDescriptor) { - var slime = SlimeUtils.jsonToSlime(testDescriptor); - var root = slime.get(); - var version = root.field("version").asString(); - var testRoot = root.field("configuredTests"); - var systemTests = getJsonArray(testRoot, "systemTests"); - var stagingTests = getJsonArray(testRoot, "stagingTests"); - var productionTests = getJsonArray(testRoot, "productionTests"); - return new TestDescriptor(version, Map.of( - TestCategory.systemtest, systemTests, - TestCategory.stagingtest, stagingTests, - TestCategory.productiontest, productionTests - )); - } - - private static List<String> getJsonArray(Cursor cursor, String field) { - return SlimeStream.fromArray(cursor.field(field), Inspector::asString).collect(Collectors.toList()); - } - - public String version() { - return version; - } - - public List<String> getConfiguredTests(TestCategory category) { - return List.copyOf(configuredTestClasses.get(category)); - } - - @Override - public String toString() { - return "TestClassDescriptor{" + - "configuredTestClasses=" + configuredTestClasses + - '}'; - } - - public enum TestCategory {systemtest, stagingtest, productiontest} -} |