From 8748f2455e29085f7a78409ae8326c78e990ff1a Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Wed, 30 Aug 2017 14:23:38 +0200 Subject: Read parallel tag from deployment.xml --- .../config/application/api/DeploymentSpecTest.java | 56 ++++++++++++++++++++-- 1 file changed, 52 insertions(+), 4 deletions(-) (limited to 'config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecTest.java') 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 0458e9d4c15..2b503125e33 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 @@ -4,14 +4,15 @@ package com.yahoo.config.application.api; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.fail; import java.io.StringReader; import java.util.Optional; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + /** * @author bratseth */ @@ -233,4 +234,51 @@ public class DeploymentSpecTest { assertEquals("", DeploymentSpec.empty.xmlForm()); } + @Test + public void productionSpecWithParallelDeployments() { + StringReader r = new StringReader( + "\n" + + " \n" + + " us-west-1\n" + + " \n" + + " us-central-1\n" + + " us-east-3\n" + + " \n" + + " \n" + + "" + ); + DeploymentSpec spec = DeploymentSpec.fromXml(r); + DeploymentSpec.ParallelZones parallelZones = ((DeploymentSpec.ParallelZones) spec.steps().get(3)); + assertEquals(2, parallelZones.zones().size()); + assertEquals(RegionName.from("us-central-1"), parallelZones.zones().get(0).region().get()); + assertEquals(RegionName.from("us-east-3"), parallelZones.zones().get(1).region().get()); + } + + @Test + public void productionSpecWithDuplicateRegions() { + StringReader r = new StringReader( + "\n" + + " \n" + + " us-west-1\n" + + " \n" + + " us-west-1\n" + + " us-central-1\n" + + " us-east-3\n" + + " \n" + + " \n" + + " eu-west-1\n" + + " us-central-1\n" + + " \n" + + " \n" + + "" + ); + try { + DeploymentSpec.fromXml(r); + fail("Expected exception"); + } catch (IllegalArgumentException e) { + assertEquals("All declared regions must be unique, but found these duplicated regions: " + + "[us-west-1, us-central-1]", e.getMessage()); + } + } + } -- cgit v1.2.3