From 9d59de7b07d5476ed587df0c361406fb3ce4b368 Mon Sep 17 00:00:00 2001 From: jonmv Date: Tue, 30 May 2023 11:59:25 +0200 Subject: Respect host TTL (and cloud account) for tester deployments --- .../com/yahoo/config/application/api/DeploymentSpec.java | 16 +++++++++++++++- .../application/api/xml/DeploymentSpecXmlReader.java | 2 +- .../yahoo/config/application/api/DeploymentSpecTest.java | 10 ++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) (limited to 'config-model-api') diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java b/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java index 43fdb32f3a2..ec79f9e554a 100644 --- a/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java +++ b/config-model-api/src/main/java/com/yahoo/config/application/api/DeploymentSpec.java @@ -387,6 +387,8 @@ public class DeploymentSpec { return true; } + public Optional hostTTL() { return Optional.empty(); } + } /** A deployment step which is to wait for some time before progressing to the next step */ @@ -495,6 +497,7 @@ public class DeploymentSpec { return environment + (region.map(regionName -> "." + regionName).orElse("")); } + @Override public Optional hostTTL() { return hostTTL; } @@ -505,9 +508,15 @@ public class DeploymentSpec { public static class DeclaredTest extends Step { private final RegionName region; + private final Optional hostTTL; - public DeclaredTest(RegionName region) { + public DeclaredTest(RegionName region, Optional cloudAccount, Optional hostTTL) { this.region = Objects.requireNonNull(region); + this.hostTTL = Objects.requireNonNull(hostTTL); + hostTTL.ifPresent(ttl -> { + if (cloudAccount.isEmpty()) illegal("Host TTL can only be specified with custom cloud accounts"); + if (ttl.isNegative()) illegal("Host TTL cannot be negative"); + }); } @Override @@ -523,6 +532,11 @@ public class DeploymentSpec { return region; } + @Override + public Optional hostTTL() { + return hostTTL; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java b/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java index db00ad4a421..f265ad3bb71 100644 --- a/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java +++ b/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java @@ -277,7 +277,7 @@ public class DeploymentSpecXmlReader { case testTag: if (Stream.iterate(stepTag, Objects::nonNull, Node::getParentNode) .anyMatch(node -> prodTag.equals(node.getNodeName()))) { - return List.of(new DeclaredTest(RegionName.from(XML.getValue(stepTag).trim()))); // A production test + return List.of(new DeclaredTest(RegionName.from(XML.getValue(stepTag).trim()), readCloudAccount(stepTag), readHostTTL(stepTag))); // A production test } case devTag, perfTag, stagingTag: // Intentional fallthrough from test tag. return List.of(new DeclaredZone(Environment.from(stepTag.getTagName()), Optional.empty(), false, athenzService, testerFlavor, readCloudAccount(stepTag), readHostTTL(stepTag))); diff --git a/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecTest.java b/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecTest.java index 9cee6c57591..721c327e5d4 100644 --- a/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecTest.java +++ b/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecTest.java @@ -1806,6 +1806,8 @@ public class DeploymentSpecTest { us-east us-west + us-east + us-west @@ -1833,6 +1835,14 @@ public class DeploymentSpecTest { assertHostTTL(Duration.ofHours(1), spec, "alpha", perf, null); assertHostTTL(Duration.ofMinutes(1), spec, "alpha", prod, "us-east"); assertHostTTL(Duration.ofMinutes(2), spec, "alpha", prod, "us-west"); + assertEquals(Optional.of(Duration.ofMinutes(1)), spec.requireInstance("alpha").steps().stream() + .filter(step -> step.concerns(prod, Optional.of(RegionName.from("us-east"))) && step.isTest()) + .findFirst().orElseThrow() + .hostTTL()); + assertEquals(Optional.of(Duration.ofMinutes(3)), spec.requireInstance("alpha").steps().stream() + .filter(step -> step.concerns(prod, Optional.of(RegionName.from("us-west"))) && step.isTest()) + .findFirst().orElseThrow() + .hostTTL()); assertHostTTL(Duration.ofHours(1), spec, "beta", test, null); assertHostTTL(Duration.ofDays(3), spec, "beta", staging, null); -- cgit v1.2.3