diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2019-06-06 13:48:41 +0200 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2019-06-06 13:48:41 +0200 |
commit | 1a7b9390e693ec6476def658804b8b3cf41a8b53 (patch) | |
tree | 687500ad47ee9edc5eb41fb5f63bf3b29ee3853a /tenant-cd | |
parent | 4607700cc4eb4682800e6d9ba54e84973ddc93e3 (diff) |
Expose system to package, and _the_ deployment to test, in TestConfig
Diffstat (limited to 'tenant-cd')
-rw-r--r-- | tenant-cd/src/main/java/ai/vespa/hosted/cd/Deployment.java | 3 | ||||
-rw-r--r-- | tenant-cd/src/main/java/ai/vespa/hosted/cd/TestConfig.java | 16 |
2 files changed, 16 insertions, 3 deletions
diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Deployment.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/Deployment.java index 495d2374435..277632b74c7 100644 --- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/Deployment.java +++ b/tenant-cd/src/main/java/ai/vespa/hosted/cd/Deployment.java @@ -13,4 +13,7 @@ public interface Deployment { /** Returns an Endpoint in the cluster with the given id. */ Endpoint endpoint(String id); + /** Returns a {@link TestDeployment} representation of this, or throws if this is a production deployment. */ + TestDeployment asTestDeployment(); + } diff --git a/tenant-cd/src/main/java/ai/vespa/hosted/cd/TestConfig.java b/tenant-cd/src/main/java/ai/vespa/hosted/cd/TestConfig.java index 78b3dfdc70d..e362ecc3f5c 100644 --- a/tenant-cd/src/main/java/ai/vespa/hosted/cd/TestConfig.java +++ b/tenant-cd/src/main/java/ai/vespa/hosted/cd/TestConfig.java @@ -1,6 +1,7 @@ package ai.vespa.hosted.cd; import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.SystemName; import com.yahoo.slime.ArrayTraverser; import com.yahoo.slime.Inspector; import com.yahoo.slime.JsonDecoder; @@ -31,11 +32,13 @@ public class TestConfig { private final ApplicationId application; private final ZoneId zone; + private final SystemName system; private final Map<ZoneId, Deployment> deployments; - private TestConfig(ApplicationId application, ZoneId zone, Map<ZoneId, Deployment> deployments) { + private TestConfig(ApplicationId application, ZoneId zone, SystemName system, Map<ZoneId, Deployment> deployments) { this.application = application; this.zone = zone; + this.system = system; this.deployments = Map.copyOf(deployments); } @@ -49,7 +52,13 @@ public class TestConfig { public ZoneId zone() { return zone; } /** Returns an immutable view of all configured endpoints for each zone of the application to test. */ - public Map<ZoneId, Deployment> deployments() { return deployments; } + public Map<ZoneId, Deployment> allDeployments() { return deployments; } + + /** Returns the deployment to test in this test runtime. */ + public Deployment deploymentToTest() { return deployments.get(zone); } + + /** Returns the system this is run against. */ + SystemName system() { return system; } static TestConfig fromFile(Path path) { if (path == null) @@ -59,13 +68,14 @@ public class TestConfig { Inspector config = new JsonDecoder().decode(new Slime(), Files.readAllBytes(path)).get(); ApplicationId application = ApplicationId.fromSerializedForm(config.field("application").asString()); ZoneId zone = ZoneId.from(config.field("zone").asString()); + SystemName system = SystemName.from(config.field("system").asString()); Map<ZoneId, Deployment> endpoints = new HashMap<>(); config.field("endpoints").traverse((ObjectTraverser) (zoneId, endpointArray) -> { List<URI> uris = new ArrayList<>(); endpointArray.traverse((ArrayTraverser) (__, uri) -> uris.add(URI.create(uri.asString()))); endpoints.put(ZoneId.from(zoneId), null); // TODO jvenstad }); - return new TestConfig(application, zone, endpoints); + return new TestConfig(application, zone, system, endpoints); } catch (Exception e) { throw new IllegalArgumentException("Failed reading config from '" + path + "'!", e); |