diff options
author | Morten Tokle <mortent@verizonmedia.com> | 2020-06-22 13:08:22 +0200 |
---|---|---|
committer | Morten Tokle <mortent@verizonmedia.com> | 2020-06-22 13:08:22 +0200 |
commit | b580bf96165691622f19e73d445f346fe29fe74f (patch) | |
tree | c6cefdb26711e83982d47520fc9b67e6de87dbe7 /cloud-tenant-cd | |
parent | e2dace4bc4f72e86a671664cb1b32eea48361cfb (diff) |
Move configuration of test runtime to test invocation
Diffstat (limited to 'cloud-tenant-cd')
5 files changed, 24 insertions, 72 deletions
diff --git a/cloud-tenant-cd/pom.xml b/cloud-tenant-cd/pom.xml index 03730daceb8..c771e2dd1c3 100644 --- a/cloud-tenant-cd/pom.xml +++ b/cloud-tenant-cd/pom.xml @@ -72,19 +72,6 @@ </dependencies> <build> - <pluginManagement> - <plugins> - <plugin> - <!-- TODO: Make config class plugin work with other packageprefix. Below does not work--> - <groupId>com.yahoo.vespa</groupId> - <artifactId>config-class-plugin</artifactId> - <version>${project.version}</version> - <configuration> - <packagePrefix>ai.vespa</packagePrefix> - </configuration> - </plugin> - </plugins> - </pluginManagement> <plugins> <plugin> <groupId>com.yahoo.vespa</groupId> diff --git a/cloud-tenant-cd/src/main/java/ai/vespa/hosted/cd/impl/VespaTestRuntime.java b/cloud-tenant-cd/src/main/java/ai/vespa/hosted/cd/impl/VespaTestRuntime.java index d2367d588f6..3a70a1ed531 100644 --- a/cloud-tenant-cd/src/main/java/ai/vespa/hosted/cd/impl/VespaTestRuntime.java +++ b/cloud-tenant-cd/src/main/java/ai/vespa/hosted/cd/impl/VespaTestRuntime.java @@ -8,26 +8,17 @@ import ai.vespa.hosted.api.TestConfig; import ai.vespa.hosted.cd.Deployment; import ai.vespa.hosted.cd.TestRuntime; import ai.vespa.hosted.cd.impl.http.HttpDeployment; -import com.google.inject.Inject; -import com.yahoo.component.AbstractComponent; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Environment; -import com.yahoo.config.provision.SystemName; import com.yahoo.config.provision.zone.ZoneId; -import com.yahoo.vespa.hosted.cd.impl.CloudTenantCdConfig; -import java.net.URI; import java.nio.file.Files; import java.nio.file.Paths; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; /** * @author mortent */ -public class VespaTestRuntime extends AbstractComponent implements TestRuntime { +public class VespaTestRuntime implements TestRuntime { private final TestConfig config; private final Deployment deploymentToTest; @@ -41,10 +32,8 @@ public class VespaTestRuntime extends AbstractComponent implements TestRuntime { /* * Used when executing tests from using Vespa test framework in container */ - @Inject - public VespaTestRuntime(CloudTenantCdConfig c) { - - this(fromVespaConfig(c)); + public VespaTestRuntime(byte[] config) { + this(fromByteArray(config)); } private VespaTestRuntime(TestConfig config) { this.config = config; @@ -75,6 +64,10 @@ public class VespaTestRuntime extends AbstractComponent implements TestRuntime { } } + private static TestConfig fromByteArray(byte[] config) { + return TestConfig.fromJson(config); + } + private static TestConfig fromController() { ControllerHttpClient controller = new ai.vespa.hosted.auth.ApiAuthenticator().controller(); ApplicationId id = Properties.application(); @@ -83,31 +76,4 @@ public class VespaTestRuntime extends AbstractComponent implements TestRuntime { .orElseGet(() -> controller.defaultZone(environment)); return controller.testConfig(id, zone); } - - private static TestConfig fromVespaConfig(CloudTenantCdConfig config) { - Map<ZoneId, Map<String, URI>> deployments = new HashMap<>(); - Map<ZoneId, List<String>> contentClusters = new HashMap<>(); - for (Map.Entry<String, CloudTenantCdConfig.Zones> entry : config.zones().entrySet()) { - ZoneId zoneId = ZoneId.from(entry.getKey()); - - Map<String, URI> zoneDeployments = entry.getValue().deployments().entrySet().stream() - .collect(Collectors.toMap(Map.Entry::getKey, e -> URI.create(e.getValue()))); - - deployments.put(zoneId, zoneDeployments); - - contentClusters.put(zoneId, entry.getValue().contentClusters()); - } - return new TestConfig( - ApplicationId.fromFullString(config.application()), - ZoneId.from(config.zone()), - SystemName.from(config.systemName()), - config.isCi(), - deployments, - contentClusters); - } - - @Override - public void deconstruct() { - super.deconstruct(); - } } diff --git a/cloud-tenant-cd/src/main/java/ai/vespa/hosted/cd/impl/VespaTestRuntimeProvider.java b/cloud-tenant-cd/src/main/java/ai/vespa/hosted/cd/impl/VespaTestRuntimeProvider.java new file mode 100644 index 00000000000..c27e1d4a0c9 --- /dev/null +++ b/cloud-tenant-cd/src/main/java/ai/vespa/hosted/cd/impl/VespaTestRuntimeProvider.java @@ -0,0 +1,17 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package ai.vespa.hosted.cd.impl; + +import ai.vespa.hosted.cd.internal.TestRuntimeProvider; +import com.yahoo.component.AbstractComponent; + +/** + * @author mortent + */ +public class VespaTestRuntimeProvider extends AbstractComponent implements TestRuntimeProvider { + + @Override + public void initialize(byte[] config) { + VespaTestRuntime vespaTestRuntime = new VespaTestRuntime(config); + updateReference(vespaTestRuntime); + } +} diff --git a/cloud-tenant-cd/src/main/java/com/yahoo/vespa/hosted/cd/impl/package-info.java b/cloud-tenant-cd/src/main/java/com/yahoo/vespa/hosted/cd/impl/package-info.java deleted file mode 100644 index b5d6f0450ec..00000000000 --- a/cloud-tenant-cd/src/main/java/com/yahoo/vespa/hosted/cd/impl/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -/** - * @author mortent - */ -@ExportPackage -package com.yahoo.vespa.hosted.cd.impl; - -import com.yahoo.osgi.annotation.ExportPackage;
\ No newline at end of file diff --git a/cloud-tenant-cd/src/main/resources/configdefinitions/cloud-tenant-cd.def b/cloud-tenant-cd/src/main/resources/configdefinitions/cloud-tenant-cd.def deleted file mode 100644 index bac21f386be..00000000000 --- a/cloud-tenant-cd/src/main/resources/configdefinitions/cloud-tenant-cd.def +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -namespace=vespa.hosted.cd.impl - -application string -zone string -systemName string -isCi bool -zones{}.deployments{} string -zones{}.contentClusters[] string |