diff options
author | jonmv <venstad@gmail.com> | 2022-06-10 13:48:38 +0200 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2022-06-10 13:48:38 +0200 |
commit | 85381f1ba40251e6a9c3773586867f7d2e4b20ec (patch) | |
tree | 71be7a5add58f76a579fdcdd2d3e070c50f51b64 /hosted-api | |
parent | 073c4eec84043026e83803e0138660c184f96d8c (diff) |
Add additional data to test runtime
Diffstat (limited to 'hosted-api')
3 files changed, 32 insertions, 1 deletions
diff --git a/hosted-api/src/main/java/ai/vespa/hosted/api/TestConfig.java b/hosted-api/src/main/java/ai/vespa/hosted/api/TestConfig.java index 937e961c69b..d8bd08773ee 100644 --- a/hosted-api/src/main/java/ai/vespa/hosted/api/TestConfig.java +++ b/hosted-api/src/main/java/ai/vespa/hosted/api/TestConfig.java @@ -10,6 +10,7 @@ import com.yahoo.slime.ObjectTraverser; import com.yahoo.slime.SlimeUtils; import java.net.URI; +import java.time.Instant; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -29,10 +30,14 @@ public class TestConfig { private final ZoneId zone; private final SystemName system; private final boolean isCI; + private final String platform; + private final long revision; + private final Instant deployedAt; private final Map<ZoneId, Map<String, URI>> deployments; private final Map<ZoneId, List<String>> contentClusters; public TestConfig(ApplicationId application, ZoneId zone, SystemName system, boolean isCI, + String platform, long revision, Instant deployedAt, Map<ZoneId, Map<String, URI>> deployments, Map<ZoneId, List<String>> contentClusters) { if ( ! deployments.containsKey(zone)) throw new IllegalArgumentException("Config must contain a deployment for its zone, but only does for " + deployments.keySet()); @@ -40,6 +45,9 @@ public class TestConfig { this.zone = requireNonNull(zone); this.system = requireNonNull(system); this.isCI = isCI; + this.platform = platform; + this.revision = revision; + this.deployedAt = deployedAt; this.deployments = deployments.entrySet().stream() .collect(Collectors.toUnmodifiableMap(entry -> entry.getKey(), entry -> Map.copyOf(entry.getValue()))); @@ -59,10 +67,17 @@ public class TestConfig { if (config.field("localEndpoints").valid()) return TestConfig.fromEndpointsOnly(toClusterMap(config.field("localEndpoints"))); + if (config.field("deployments").valid()) { + + } + ApplicationId application = ApplicationId.fromSerializedForm(config.field("application").asString()); ZoneId zone = ZoneId.from(config.field("zone").asString()); SystemName system = SystemName.from(config.field("system").asString()); boolean isCI = config.field("isCI").asBool(); + String platform = config.field("platform").asString(); + long revision = config.field("revision").asLong(); + Instant deployedAt = Instant.ofEpochMilli(config.field("deployedAt").asLong()); Map<ZoneId, Map<String, URI>> deployments = new HashMap<>(); config.field("zoneEndpoints").traverse((ObjectTraverser) (zoneId, clustersObject) -> { deployments.put(ZoneId.from(zoneId), toClusterMap(clustersObject)); @@ -73,7 +88,7 @@ public class TestConfig { clustersArray.traverse((ArrayTraverser) (__, cluster) -> clusters.add(cluster.asString())); contentClusters.put(ZoneId.from(zoneId), clusters); })); - return new TestConfig(application, zone, system, isCI, deployments, contentClusters); + return new TestConfig(application, zone, system, isCI, platform, revision, deployedAt, deployments, contentClusters); } static Map<String, URI> toClusterMap(Inspector clustersObject) { @@ -91,6 +106,9 @@ public class TestConfig { ZoneId.defaultId(), SystemName.defaultSystem(), false, + "", + 0, + Instant.EPOCH, Map.of(ZoneId.defaultId(), endpoints), Map.of()); } @@ -113,4 +131,10 @@ public class TestConfig { /** Returns an immutable view of content clusters, per zone, of the application to test. */ public Map<ZoneId, List<String>> contentClusters() { return contentClusters; } + public String platformVersion() { return platform; } + + public long applicationVersion() { return revision; } + + public Instant deployedAt() { return deployedAt; } + } diff --git a/hosted-api/src/test/java/ai/vespa/hosted/api/TestConfigTest.java b/hosted-api/src/test/java/ai/vespa/hosted/api/TestConfigTest.java index 2cbc65c6b23..320bce678c3 100644 --- a/hosted-api/src/test/java/ai/vespa/hosted/api/TestConfigTest.java +++ b/hosted-api/src/test/java/ai/vespa/hosted/api/TestConfigTest.java @@ -10,6 +10,7 @@ import java.io.IOException; import java.net.URI; import java.nio.file.Files; import java.nio.file.Paths; +import java.time.Instant; import java.util.List; import java.util.Map; @@ -32,6 +33,9 @@ public class TestConfigTest { assertEquals(SystemName.PublicCd, config.system()); assertTrue(config.isCI()); + assertEquals("1.2.3", config.platformVersion()); + assertEquals(321, config.applicationVersion()); + assertEquals(Instant.ofEpochMilli(1600000000L), config.deployedAt()); assertEquals(Map.of(ZoneId.from("dev", "aws-us-east-1c"), Map.of("default", URI.create("https://dev.endpoint:443/")), ZoneId.from("prod", "aws-us-east-1a"), diff --git a/hosted-api/src/test/resources/test-config.json b/hosted-api/src/test/resources/test-config.json index 07454efdb66..b1a7e2c2563 100644 --- a/hosted-api/src/test/resources/test-config.json +++ b/hosted-api/src/test/resources/test-config.json @@ -3,6 +3,9 @@ "zone": "dev.aws-us-east-1c", "system": "publiccd", "isCI": true, + "platform": "1.2.3", + "revision": 321, + "deployedAt": 1600000000, "zoneEndpoints": { "dev.aws-us-east-1c": { "default": "https://dev.endpoint:443/" |