From b610a317d9fd1e1dcad6bc639efb9e22dd4cbf26 Mon Sep 17 00:00:00 2001 From: jonmv Date: Mon, 6 Jun 2022 19:13:18 +0200 Subject: Reimplement JUnit integratino, with unit tests, and structured report --- .../java/ai/vespa/hosted/cd/IntegrationTest.java | 3 --- .../main/java/ai/vespa/hosted/cd/TestRuntime.java | 24 ++++++++++------------ 2 files changed, 11 insertions(+), 16 deletions(-) (limited to 'tenant-cd-api') diff --git a/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/IntegrationTest.java b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/IntegrationTest.java index 6f359a23675..431829543e7 100644 --- a/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/IntegrationTest.java +++ b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/IntegrationTest.java @@ -2,11 +2,8 @@ package ai.vespa.hosted.cd; import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; -import java.lang.annotation.ElementType; import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import static java.lang.annotation.ElementType.ANNOTATION_TYPE; diff --git a/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/TestRuntime.java b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/TestRuntime.java index bcb3c236ca8..1bf0a3081bd 100644 --- a/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/TestRuntime.java +++ b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/TestRuntime.java @@ -3,9 +3,7 @@ package ai.vespa.hosted.cd; import ai.vespa.cloud.Zone; import ai.vespa.hosted.cd.internal.TestRuntimeProvider; -import org.osgi.framework.BundleReference; -import java.util.Optional; import java.util.ServiceLoader; import java.util.logging.Logger; @@ -16,19 +14,19 @@ import java.util.logging.Logger; * @author mortent */ public interface TestRuntime { - static final Logger logger = Logger.getLogger(TestRuntime.class.getName()); + + Logger logger = Logger.getLogger(TestRuntime.class.getName()); + static TestRuntime get() { - var classloader = TestRuntime.class.getClassLoader(); - - if (classloader instanceof BundleReference) { - logger.info("Loading Test runtime from TestRuntimeProvider"); - return Optional.ofNullable(TestRuntimeProvider.getTestRuntime()) - .orElseThrow(() -> new RuntimeException("Component graph not ready, retrying")); - } else { - logger.info("Loading Test runtime from ServiceLoader"); - ServiceLoader serviceLoader = ServiceLoader.load(TestRuntime.class, TestRuntime.class.getClassLoader()); - return serviceLoader.findFirst().orElseThrow(() -> new RuntimeException("No TestRuntime implementation found")); + TestRuntime provided = TestRuntimeProvider.getTestRuntime(); + if (provided != null) { + logger.info("Using test runtime from TestRuntimeProvider"); + return provided; } + logger.info("Using test runtime from ServiceLoader"); + return ServiceLoader.load(TestRuntime.class, TestRuntime.class.getClassLoader()) + .findFirst() + .orElseThrow(() -> new IllegalStateException("No TestRuntime initialized")); } Deployment deploymentToTest(); -- cgit v1.2.3