diff options
Diffstat (limited to 'vespa-osgi-testrunner/src')
-rw-r--r-- | vespa-osgi-testrunner/src/main/java/com/yahoo/vespa/testrunner/JunitHandler.java | 15 |
1 files changed, 14 insertions, 1 deletions
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 5534ea29d13..3db2846da4e 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,15 +1,19 @@ // 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.cd.internal.TestRuntimeProvider; +import com.google.inject.Inject; import com.yahoo.container.handler.metrics.JsonResponse; 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; +import java.io.IOException; import java.util.List; import java.util.concurrent.Executor; import java.util.function.Function; @@ -20,10 +24,13 @@ import java.util.function.Function; public class JunitHandler extends LoggingRequestHandler { private final JunitRunner junitRunner; + private final TestRuntimeProvider testRuntimeProvider; - public JunitHandler(Executor executor, AccessLog accessLog, JunitRunner junitRunner) { + @Inject + public JunitHandler(Executor executor, AccessLog accessLog, JunitRunner junitRunner, TestRuntimeProvider testRuntimeProvider) { super(executor, accessLog); this.junitRunner = junitRunner; + this.testRuntimeProvider = testRuntimeProvider; } @Override @@ -31,6 +38,12 @@ public class JunitHandler extends LoggingRequestHandler { String mode = property("mode", "help", httpRequest, String::valueOf); TestDescriptor.TestCategory category = property("category", TestDescriptor.TestCategory.systemtest, httpRequest, TestDescriptor.TestCategory::valueOf); + try { + testRuntimeProvider.initialize(IOUtils.readBytes(httpRequest.getData(), 1000 * 1000)); + } catch (IOException e) { + return new ErrorResponse(500, "testruntime-initialization", "Exception reading test config"); + } + if ("help".equalsIgnoreCase(mode)) { return new MessageResponse("Accepted modes: \n help \n list \n execute"); } |