diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-09-09 13:52:14 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-09-09 13:52:14 +0200 |
commit | 01b61de4db4be59d86298d540aaa948c68185585 (patch) | |
tree | 29508a311bc414d7bd6b243e948fb06651fa6350 /config-application-package/src/test/java/com/yahoo/config/application | |
parent | f78bc7ec2bbab76e5c9bec35d3a7ef3edcff9f40 (diff) |
Allow services.xml variants on application instance name
Diffstat (limited to 'config-application-package/src/test/java/com/yahoo/config/application')
5 files changed, 36 insertions, 15 deletions
diff --git a/config-application-package/src/test/java/com/yahoo/config/application/HostedOverrideProcessorTest.java b/config-application-package/src/test/java/com/yahoo/config/application/HostedOverrideProcessorTest.java index 4c6a3eb3513..d19ea177d9b 100644 --- a/config-application-package/src/test/java/com/yahoo/config/application/HostedOverrideProcessorTest.java +++ b/config-application-package/src/test/java/com/yahoo/config/application/HostedOverrideProcessorTest.java @@ -2,6 +2,7 @@ package com.yahoo.config.application; import com.yahoo.config.provision.Environment; +import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.RegionName; import org.custommonkey.xmlunit.XMLUnit; import org.junit.Test; @@ -33,6 +34,7 @@ public class HostedOverrideProcessorTest { " <nodes deploy:environment='prod' count='3' flavor='v-4-8-100'/>" + " <nodes deploy:environment='prod' deploy:region='us-west' count='4'/>" + " <nodes deploy:environment='prod' deploy:region='us-east-3' flavor='v-8-8-100' count='5'/>" + + " <nodes deploy:instance='myinstance' deploy:environment='prod' deploy:region='us-west' count='1'/>" + " </container>" + "</services>"; @@ -62,6 +64,18 @@ public class HostedOverrideProcessorTest { } @Test + public void testParsingInstance() throws TransformerException { + String expected = + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + + "<services xmlns:deploy=\"vespa\" xmlns:preprocess=\"?\" version=\"1.0\">" + + " <container id=\"foo\" version=\"1.0\">" + + " <nodes count='1' required='true'/>" + + " </container>" + + "</services>"; + assertOverride(InstanceName.from("myinstance"), Environment.from("prod"), RegionName.from("us-west"), expected); + } + + @Test public void testParsingEnvironmentAndRegion2() throws TransformerException { String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + @@ -146,8 +160,12 @@ public class HostedOverrideProcessorTest { } private void assertOverride(Environment environment, RegionName region, String expected) throws TransformerException { + assertOverride(InstanceName.from("default"), environment, region, expected); + } + + private void assertOverride(InstanceName instance, Environment environment, RegionName region, String expected) throws TransformerException { Document inputDoc = Xml.getDocument(new StringReader(input)); - Document newDoc = new OverrideProcessor(environment, region).process(inputDoc); + Document newDoc = new OverrideProcessor(instance, environment, region).process(inputDoc); TestBase.assertDocument(expected, newDoc); } diff --git a/config-application-package/src/test/java/com/yahoo/config/application/MultiOverrideProcessorTest.java b/config-application-package/src/test/java/com/yahoo/config/application/MultiOverrideProcessorTest.java index 7c054ec62ee..b9b8a9dd798 100644 --- a/config-application-package/src/test/java/com/yahoo/config/application/MultiOverrideProcessorTest.java +++ b/config-application-package/src/test/java/com/yahoo/config/application/MultiOverrideProcessorTest.java @@ -2,6 +2,7 @@ package com.yahoo.config.application; import com.yahoo.config.provision.Environment; +import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.RegionName; import org.custommonkey.xmlunit.XMLUnit; import org.junit.Test; @@ -123,13 +124,13 @@ public class MultiOverrideProcessorTest { private void assertOverride(Environment environment, RegionName region, String expected) throws TransformerException { Document inputDoc = Xml.getDocument(new StringReader(input)); - Document newDoc = new OverrideProcessor(environment, region).process(inputDoc); + Document newDoc = new OverrideProcessor(InstanceName.from("default"), environment, region).process(inputDoc); TestBase.assertDocument(expected, newDoc); } private void assertOverrideWithIds(Environment environment, RegionName region, String expected) throws TransformerException { Document inputDoc = Xml.getDocument(new StringReader(inputWithIds)); - Document newDoc = new OverrideProcessor(environment, region).process(inputDoc); + Document newDoc = new OverrideProcessor(InstanceName.from("default"), environment, region).process(inputDoc); TestBase.assertDocument(expected, newDoc); } diff --git a/config-application-package/src/test/java/com/yahoo/config/application/OverrideProcessorTest.java b/config-application-package/src/test/java/com/yahoo/config/application/OverrideProcessorTest.java index 9113ce7f016..05a5357a8ab 100644 --- a/config-application-package/src/test/java/com/yahoo/config/application/OverrideProcessorTest.java +++ b/config-application-package/src/test/java/com/yahoo/config/application/OverrideProcessorTest.java @@ -2,6 +2,7 @@ package com.yahoo.config.application; import com.yahoo.config.provision.Environment; +import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.RegionName; import org.custommonkey.xmlunit.XMLUnit; import org.junit.Test; @@ -331,7 +332,7 @@ public class OverrideProcessorTest { " </admin>" + "</services>"; Document inputDoc = Xml.getDocument(new StringReader(in)); - new OverrideProcessor(Environment.from("prod"), RegionName.from("us-west")).process(inputDoc); + new OverrideProcessor(InstanceName.from("default"), Environment.from("prod"), RegionName.from("us-west")).process(inputDoc); } @Test(expected = IllegalArgumentException.class) @@ -343,12 +344,12 @@ public class OverrideProcessorTest { " </admin>" + "</services>"; Document inputDoc = Xml.getDocument(new StringReader(in)); - new OverrideProcessor(Environment.defaultEnvironment(), RegionName.from("us-west")).process(inputDoc); + new OverrideProcessor(InstanceName.from("default"), Environment.defaultEnvironment(), RegionName.from("us-west")).process(inputDoc); } private void assertOverride(Environment environment, RegionName region, String expected) throws TransformerException { Document inputDoc = Xml.getDocument(new StringReader(OverrideProcessorTest.input)); - Document newDoc = new OverrideProcessor(environment, region).process(inputDoc); + Document newDoc = new OverrideProcessor(InstanceName.from("default"), environment, region).process(inputDoc); TestBase.assertDocument(expected, newDoc); } diff --git a/config-application-package/src/test/java/com/yahoo/config/application/PropertiesProcessorTest.java b/config-application-package/src/test/java/com/yahoo/config/application/PropertiesProcessorTest.java index 038447c7b99..fe9ca4a7951 100644 --- a/config-application-package/src/test/java/com/yahoo/config/application/PropertiesProcessorTest.java +++ b/config-application-package/src/test/java/com/yahoo/config/application/PropertiesProcessorTest.java @@ -26,7 +26,7 @@ public class PropertiesProcessorTest { } @Test - public void testPropertyValues() throws ParserConfigurationException, TransformerException, SAXException, IOException { + public void testPropertyValues() throws TransformerException { String input = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<services xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\" version=\"1.0\">" + " <preprocess:properties>" + @@ -50,7 +50,7 @@ public class PropertiesProcessorTest { } @Test - public void testPropertyApplying() throws IOException, SAXException, XMLStreamException, ParserConfigurationException, TransformerException { + public void testPropertyApplying() throws TransformerException { String input = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<services xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\" version=\"1.0\">" + " <preprocess:properties>" + @@ -104,7 +104,7 @@ public class PropertiesProcessorTest { // TODO: Check that warning is actually logged @Test - public void testWarnIfDuplicatePropertyForSameEnvironment() throws IOException, SAXException, XMLStreamException, ParserConfigurationException, TransformerException { + public void testWarnIfDuplicatePropertyForSameEnvironment() throws TransformerException { String input = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<services xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\" version=\"1.0\">" + " <preprocess:properties>" + diff --git a/config-application-package/src/test/java/com/yahoo/config/application/XmlPreprocessorTest.java b/config-application-package/src/test/java/com/yahoo/config/application/XmlPreprocessorTest.java index eacaa4a881a..549fbdb41ea 100644 --- a/config-application-package/src/test/java/com/yahoo/config/application/XmlPreprocessorTest.java +++ b/config-application-package/src/test/java/com/yahoo/config/application/XmlPreprocessorTest.java @@ -2,6 +2,7 @@ package com.yahoo.config.application; import com.yahoo.config.provision.Environment; +import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.RegionName; import org.junit.Test; import org.w3c.dom.Document; @@ -48,7 +49,7 @@ public class XmlPreprocessorTest { " </nodes>\n" + " </container>\n" + "</services>"; - TestBase.assertDocument(expectedDev, new XmlPreProcessor(appDir, services, Environment.dev, RegionName.from("default")).run()); + TestBase.assertDocument(expectedDev, new XmlPreProcessor(appDir, services, InstanceName.defaultName(), Environment.dev, RegionName.from("default")).run()); String expectedStaging = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + @@ -75,7 +76,7 @@ public class XmlPreprocessorTest { " </container>\n" + "</services>"; // System.out.println(Xml.documentAsString(new XmlPreProcessor(appDir, services, Environment.staging, RegionName.from("default")).run())); - TestBase.assertDocument(expectedStaging, new XmlPreProcessor(appDir, services, Environment.staging, RegionName.from("default")).run()); + TestBase.assertDocument(expectedStaging, new XmlPreProcessor(appDir, services, InstanceName.defaultName(), Environment.staging, RegionName.from("default")).run()); String expectedUsWest = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + @@ -109,7 +110,7 @@ public class XmlPreprocessorTest { " </nodes>\n" + " </container>\n" + "</services>"; - TestBase.assertDocument(expectedUsWest, new XmlPreProcessor(appDir, services, Environment.prod, RegionName.from("us-west")).run()); + TestBase.assertDocument(expectedUsWest, new XmlPreProcessor(appDir, services, InstanceName.defaultName(), Environment.prod, RegionName.from("us-west")).run()); String expectedUsEastAndCentral = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + @@ -143,9 +144,9 @@ public class XmlPreprocessorTest { " </container>\n" + "</services>"; TestBase.assertDocument(expectedUsEastAndCentral, - new XmlPreProcessor(appDir, services, Environment.prod, RegionName.from("us-east")).run()); + new XmlPreProcessor(appDir, services, InstanceName.defaultName(), Environment.prod, RegionName.from("us-east")).run()); TestBase.assertDocument(expectedUsEastAndCentral, - new XmlPreProcessor(appDir, services, Environment.prod, RegionName.from("us-central")).run()); + new XmlPreProcessor(appDir, services, InstanceName.defaultName(), Environment.prod, RegionName.from("us-central")).run()); } @Test @@ -189,7 +190,7 @@ public class XmlPreprocessorTest { " <adminserver hostalias=\"node0\"/>" + " </admin>" + "</services>"; - Document docDev = (new XmlPreProcessor(appDir, new StringReader(input), Environment.prod, RegionName.from("default")).run()); + Document docDev = (new XmlPreProcessor(appDir, new StringReader(input), InstanceName.defaultName(), Environment.prod, RegionName.from("default")).run()); TestBase.assertDocument(expectedProd, docDev); } |