diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2019-11-29 14:01:02 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2019-11-29 14:01:02 +0100 |
commit | 28d27fa91931502f69104a7ad82a67623d161e86 (patch) | |
tree | 41561a45163158dc7568845727e4569c37c67699 /config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecWithoutInstanceTest.java | |
parent | ec7563da10532b62461166d5cb8f26ad40b5cea6 (diff) |
Read prod test and steps tags, and some refactoring
Diffstat (limited to 'config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecWithoutInstanceTest.java')
-rw-r--r-- | config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecWithoutInstanceTest.java | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecWithoutInstanceTest.java b/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecWithoutInstanceTest.java index 0d1556bc666..13ec7bf1a8b 100644 --- a/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecWithoutInstanceTest.java +++ b/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecWithoutInstanceTest.java @@ -7,6 +7,7 @@ import com.yahoo.config.provision.RegionName; import org.junit.Test; import java.io.StringReader; +import java.time.Duration; import java.time.Instant; import java.time.ZoneId; import java.util.Collections; @@ -156,6 +157,76 @@ public class DeploymentSpecWithoutInstanceTest { } @Test + public void productionTests() { + StringReader r = new StringReader( + "<deployment version='1.0'>" + + " <test/>" + + " <staging/>" + + " <prod>" + + " <region active='false'>us-east-1</region>" + + " <region active='true'>us-west-1</region>" + + " <delay hours='1' />" + + " <test>us-west-1</test>" + + " <test>us-east-1</test>" + + " </prod>" + + "</deployment>" + ); + + DeploymentSpec spec = DeploymentSpec.fromXml(r); + List<DeploymentSpec.Step> instanceSteps = spec.steps().get(0).steps(); + assertEquals(7, instanceSteps.size()); + assertEquals("test", instanceSteps.get(0).toString()); + assertEquals("staging", instanceSteps.get(1).toString()); + assertEquals("prod.us-east-1", instanceSteps.get(2).toString()); + assertEquals("prod.us-west-1", instanceSteps.get(3).toString()); + assertEquals("delay PT1H", instanceSteps.get(4).toString()); + assertEquals("tests for prod.us-west-1", instanceSteps.get(5).toString()); + assertEquals("tests for prod.us-east-1", instanceSteps.get(6).toString()); + } + + @Test(expected = IllegalArgumentException.class) + public void duplicateProductionTests() { + StringReader r = new StringReader( + "<deployment version='1.0'>" + + " <prod>" + + " <region active='true'>us-east1</region>" + + " <test>us-east1</test>" + + " <test>us-east1</test>" + + " </prod>" + + "</deployment>" + ); + DeploymentSpec.fromXml(r); + } + + @Test(expected = IllegalArgumentException.class) + public void productionTestBeforeDeployment() { + StringReader r = new StringReader( + "<deployment version='1.0'>" + + " <prod>" + + " <test>us-east1</test>" + + " <region active='true'>us-east1</region>" + + " </prod>" + + "</deployment>" + ); + DeploymentSpec.fromXml(r); + } + + @Test(expected = IllegalArgumentException.class) + public void productionTestInParallelWithDeployment() { + StringReader r = new StringReader( + "<deployment version='1.0'>" + + " <prod>" + + " <parallel>" + + " <region active='true'>us-east1</region>" + + " <test>us-east1</test>" + + " </parallel>" + + " </prod>" + + "</deployment>" + ); + DeploymentSpec.fromXml(r); + } + + @Test public void productionSpecWithGlobalServiceId() { StringReader r = new StringReader( "<deployment version='1.0'>" + @@ -278,6 +349,75 @@ public class DeploymentSpecWithoutInstanceTest { } @Test + public void testNestedParallelAndSteps() { + StringReader r = new StringReader( + "<deployment athenz-domain='domain' athenz-service='service'>" + + " <prod>" + + " <parallel>" + + " <region active='true'>us-west-1</region>" + + " <steps>" + + " <region active='true'>us-east-3</region>" + + " <delay hours='2' />" + + " <region active='true'>eu-west-1</region>" + + " <delay hours='2' />" + + " </steps>" + + " <steps>" + + " <delay hours='3' />" + + " <region active='true'>aws-us-east-1a</region>" + + " <parallel>" + + " <region active='true' athenz-service='no-service'>ap-northeast-1</region>" + + " <region active='true'>ap-southeast-2</region>" + + " </parallel>" + + " </steps>" + + " <delay hours='3' minutes='30' />" + + " </parallel>" + + " <region active='true'>us-north-7</region>" + + " </prod>" + + "</deployment>" + ); + + DeploymentSpec spec = DeploymentSpec.fromXml(r); + List<DeploymentSpec.Step> steps = spec.steps(); + assertEquals(3, steps.size()); + assertEquals("test", steps.get(0).toString()); + assertEquals("staging", steps.get(1).toString()); + assertEquals("instance 'default'", steps.get(2).toString()); + assertEquals(Duration.ofHours(4), steps.get(2).delay()); + + List<DeploymentSpec.Step> instanceSteps = steps.get(2).steps(); + assertEquals(2, instanceSteps.size()); + assertEquals("4 parallel steps", instanceSteps.get(0).toString()); + assertEquals("prod.us-north-7", instanceSteps.get(1).toString()); + + List<DeploymentSpec.Step> parallelSteps = instanceSteps.get(0).steps(); + assertEquals(4, parallelSteps.size()); + assertEquals("prod.us-west-1", parallelSteps.get(0).toString()); + assertEquals("4 steps", parallelSteps.get(1).toString()); + assertEquals("3 steps", parallelSteps.get(2).toString()); + assertEquals("delay PT3H30M", parallelSteps.get(3).toString()); + + List<DeploymentSpec.Step> firstSerialSteps = parallelSteps.get(1).steps(); + assertEquals(4, firstSerialSteps.size()); + assertEquals("prod.us-east-3", firstSerialSteps.get(0).toString()); + assertEquals("delay PT2H", firstSerialSteps.get(1).toString()); + assertEquals("prod.eu-west-1", firstSerialSteps.get(2).toString()); + assertEquals("delay PT2H", firstSerialSteps.get(3).toString()); + + List<DeploymentSpec.Step> secondSerialSteps = parallelSteps.get(2).steps(); + assertEquals(3, secondSerialSteps.size()); + assertEquals("delay PT3H", secondSerialSteps.get(0).toString()); + assertEquals("prod.aws-us-east-1a", secondSerialSteps.get(1).toString()); + assertEquals("2 parallel steps", secondSerialSteps.get(2).toString()); + + List<DeploymentSpec.Step> innerParallelSteps = secondSerialSteps.get(2).steps(); + assertEquals(2, innerParallelSteps.size()); + assertEquals("prod.ap-northeast-1", innerParallelSteps.get(0).toString()); + assertEquals("no-service", spec.requireInstance("default").athenzService(Environment.prod, RegionName.from("ap-northeast-1")).get().value()); + assertEquals("prod.ap-southeast-2", innerParallelSteps.get(1).toString()); + assertEquals("service", spec.requireInstance("default").athenzService(Environment.prod, RegionName.from("ap-southeast-2")).get().value()); + } + + @Test public void productionSpecWithDuplicateRegions() { StringReader r = new StringReader( "<deployment>\n" + |