diff options
Diffstat (limited to 'tenant-cd-api/src/main/java/ai/vespa/hosted/cd/TestRuntime.java')
-rw-r--r-- | tenant-cd-api/src/main/java/ai/vespa/hosted/cd/TestRuntime.java | 19 |
1 files changed, 17 insertions, 2 deletions
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 08cc0467b71..7aebbc7b7e7 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 @@ -2,7 +2,10 @@ 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; /** @@ -13,8 +16,20 @@ import java.util.ServiceLoader; */ public interface TestRuntime { static TestRuntime get() { - ServiceLoader<TestRuntime> serviceLoader = ServiceLoader.load(TestRuntime.class); - return serviceLoader.findFirst().orElseThrow(() -> new RuntimeException("No TestRuntime implementation found")); + var classloader = TestRuntime.class.getClassLoader(); + + System.out.println("classloader.toString() = " + classloader.toString()); + System.out.println("classloader.getClass().toString() = " + classloader.getClass().toString()); + + if (classloader instanceof BundleReference) { + System.out.println("Loading Test runtime from osgi component"); + return Optional.ofNullable(TestRuntimeProvider.getTestRuntime()) + .orElseThrow(() -> new RuntimeException("Component graph not ready, retrying")); + } else { + System.out.println("Loading Test runtime from service loader"); + ServiceLoader<TestRuntime> serviceLoader = ServiceLoader.load(TestRuntime.class, TestRuntime.class.getClassLoader()); + return serviceLoader.findFirst().orElseThrow(() -> new RuntimeException("No TestRuntime implementation found")); + } } Deployment deploymentToTest(); |