From 0672d55362ebd314e1d552e4765218c2230a4696 Mon Sep 17 00:00:00 2001 From: jonmv Date: Sun, 10 Apr 2022 20:40:12 +0200 Subject: Allow specifying min and max risk, and max idle hours, in deployment spec --- .../config/application/api/DeploymentSpecTest.java | 48 +++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'config-model-api/src/test') 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 5efa49b3656..5073c6b9fb2 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 @@ -26,6 +26,7 @@ import static com.yahoo.config.application.api.Notifications.When.failingCommit; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -125,6 +126,9 @@ public class DeploymentSpecTest { assertEquals(DeploymentSpec.RevisionTarget.latest, spec.requireInstance("default").revisionTarget()); assertEquals(DeploymentSpec.RevisionChange.whenFailing, spec.requireInstance("default").revisionChange()); assertEquals(DeploymentSpec.UpgradeRollout.separate, spec.requireInstance("default").upgradeRollout()); + assertEquals(0, spec.requireInstance("default").minRisk()); + assertEquals(0, spec.requireInstance("default").maxRisk()); + assertEquals(8, spec.requireInstance("default").maxIdleHours()); } @Test @@ -371,7 +375,7 @@ public class DeploymentSpecTest { StringReader r = new StringReader( "" + " " + - " " + + " " + " " + " " + " " + @@ -383,6 +387,48 @@ public class DeploymentSpecTest { assertEquals("latest", spec.requireInstance("custom").revisionTarget().toString()); assertEquals("whenClear", spec.requireInstance("default").revisionChange().toString()); assertEquals("always", spec.requireInstance("custom").revisionChange().toString()); + assertEquals(3, spec.requireInstance("default").minRisk()); + assertEquals(12, spec.requireInstance("default").maxRisk()); + assertEquals(32, spec.requireInstance("default").maxIdleHours()); + } + + @Test + public void productionSpecsWithIllegalRevisionSettings() { + assertEquals("revision-change must be 'when-clear' when max-risk is specified, but got: 'always'", + assertThrows(IllegalArgumentException.class, + () -> DeploymentSpec.fromXml("" + + " " + + " " + + " " + + "")) + .getMessage()); + + assertEquals("revision-target must be 'next' when max-risk is specified, but got: 'latest'", + assertThrows(IllegalArgumentException.class, + () -> DeploymentSpec.fromXml("" + + " " + + " " + + " " + + "")) + .getMessage()); + + assertEquals("maximum risk cannot be less than minimum risk score, but got: '12'", + assertThrows(IllegalArgumentException.class, + () -> DeploymentSpec.fromXml("" + + " " + + " " + + " " + + "")) + .getMessage()); + + assertEquals("maximum risk cannot be less than minimum risk score, but got: '0'", + assertThrows(IllegalArgumentException.class, + () -> DeploymentSpec.fromXml("" + + " " + + " " + + " " + + "")) + .getMessage()); } @Test -- cgit v1.2.3