diff options
author | Martin Polden <mpolden@mpolden.no> | 2017-08-30 14:23:38 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2017-08-30 14:25:48 +0200 |
commit | 8748f2455e29085f7a78409ae8326c78e990ff1a (patch) | |
tree | c042bb6510a910234cea24177f3fde5441c4598c /config-model | |
parent | c1a93692a89586ea6ed51e682cf18f9eafe7d89b (diff) |
Read parallel tag from deployment.xml
Diffstat (limited to 'config-model')
6 files changed, 67 insertions, 5 deletions
diff --git a/config-model/src/main/resources/schema/deployment.rnc b/config-model/src/main/resources/schema/deployment.rnc index 3ce5e002e53..36897643964 100644 --- a/config-model/src/main/resources/schema/deployment.rnc +++ b/config-model/src/main/resources/schema/deployment.rnc @@ -25,7 +25,8 @@ Staging = element staging { Prod = element prod { attribute global-service-id { text }? & Region* & - Delay* + Delay* & + Parallel* } Region = element region { @@ -38,3 +39,7 @@ Delay = element delay { attribute minutes { xsd:long }? & attribute seconds { xsd:long }? } + +Parallel = element parallel { + Region* +} diff --git a/config-model/src/test/cfg/application/invalid_parallel_deployment_xml/deployment.xml b/config-model/src/test/cfg/application/invalid_parallel_deployment_xml/deployment.xml new file mode 100644 index 00000000000..0d3b74b8119 --- /dev/null +++ b/config-model/src/test/cfg/application/invalid_parallel_deployment_xml/deployment.xml @@ -0,0 +1,11 @@ +<deployment version="1.0"> + <test/> + <staging/> + <prod global-service-id="query"> + <parallel> + <region active="true">us-east-3</region> + <delay hours="1"/> + <region active="true">us-west-1</region> + </parallel> + </prod> +</deployment> diff --git a/config-model/src/test/cfg/application/invalid_parallel_deployment_xml/hosts.xml b/config-model/src/test/cfg/application/invalid_parallel_deployment_xml/hosts.xml new file mode 100644 index 00000000000..115efd488d0 --- /dev/null +++ b/config-model/src/test/cfg/application/invalid_parallel_deployment_xml/hosts.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<hosts> + <host name="localhost"> + <alias>node1</alias> + </host> + <host name="schmocalhost"> + <alias>node2</alias> + </host> +</hosts> diff --git a/config-model/src/test/cfg/application/invalid_parallel_deployment_xml/services.xml b/config-model/src/test/cfg/application/invalid_parallel_deployment_xml/services.xml new file mode 100644 index 00000000000..03d8fc012ac --- /dev/null +++ b/config-model/src/test/cfg/application/invalid_parallel_deployment_xml/services.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<services version="1.0"> + + <admin version="2.0"> + <adminserver hostalias="node1"/> + </admin> + + <container version="1.0"> + <nodes> + <node hostalias="node1" /> + </nodes> + <search/> + </container> + +</services> diff --git a/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java b/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java index 1e1b8cd2ac8..3d5c9b1c187 100644 --- a/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java +++ b/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java @@ -196,7 +196,7 @@ public class ApplicationDeployTest { @Test public void testThatModelIsRebuiltWhenSearchDefinitionIsAdded() throws IOException { - File tmpDir = Files.createTempDir(); + File tmpDir = tmpFolder.getRoot(); IOUtils.copyDirectory(new File(TESTDIR, "app1"), tmpDir); FilesApplicationPackage app = createAppPkg(tmpDir.getAbsolutePath()); assertThat(getSearchDefinitions(app).size(), is(5)); @@ -208,25 +208,37 @@ public class ApplicationDeployTest { @Test public void testThatAppWithDeploymentXmlIsValid() throws IOException { - File tmpDir = Files.createTempDir(); + File tmpDir = tmpFolder.getRoot(); IOUtils.copyDirectory(new File(TESTDIR, "app1"), tmpDir); createAppPkg(tmpDir.getAbsolutePath()); } @Test(expected = IllegalArgumentException.class) public void testThatAppWithIllegalDeploymentXmlIsNotValid() throws IOException { - File tmpDir = Files.createTempDir(); + File tmpDir = tmpFolder.getRoot(); IOUtils.copyDirectory(new File(TESTDIR, "app_invalid_deployment_xml"), tmpDir); createAppPkg(tmpDir.getAbsolutePath()); } @Test public void testThatAppWithIllegalEmptyProdRegion() throws IOException { - File tmpDir = Files.createTempDir(); + File tmpDir = tmpFolder.getRoot(); IOUtils.copyDirectory(new File(TESTDIR, "empty_prod_region_in_deployment_xml"), tmpDir); createAppPkg(tmpDir.getAbsolutePath()); } + @Test + public void testThatAppWithInvalidParallelDeploymentFails() throws IOException { + File tmpDir = tmpFolder.getRoot(); + IOUtils.copyDirectory(new File(TESTDIR, "invalid_parallel_deployment_xml"), tmpDir); + try { + createAppPkg(tmpDir.getAbsolutePath()); + fail("Expected exception"); + } catch (IllegalArgumentException e) { + assertThat(e.getMessage(), containsString("element \"delay\" not allowed here")); + } + } + private List<SearchDefinition> getSearchDefinitions(FilesApplicationPackage app) { return new DeployState.Builder().applicationPackage(app).build().getSearchDefinitions(); } diff --git a/config-model/src/test/schema-test-files/deployment.xml b/config-model/src/test/schema-test-files/deployment.xml index 89b52bc44ca..99b1dc1be69 100644 --- a/config-model/src/test/schema-test-files/deployment.xml +++ b/config-model/src/test/schema-test-files/deployment.xml @@ -9,5 +9,13 @@ <region active='true'>us-central-1</region> <delay hours='3' minutes='7' seconds='13'/> <region active='true'>us-east-3</region> + <parallel> + <region active='true'>us-north-1</region> + <region active='true'>us-south-1</region> + </parallel> + <parallel> + <region active='true'>us-north-2</region> + <region active='true'>us-south-2</region> + </parallel> </prod> </deployment> |