aboutsummaryrefslogtreecommitdiffstats
path: root/config-application-package/src/test/java/com/yahoo
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-09-25 15:33:42 -0700
committerJon Bratseth <bratseth@oath.com>2018-09-25 15:33:42 -0700
commit22b480874b1ca6400b8cd2640f678c210da07fa3 (patch)
treeb60704a2560a4499a79d6f5de17bf3233b499fdb /config-application-package/src/test/java/com/yahoo
parent0246064bbfb9657515f516e2fea12d593cd13016 (diff)
Allow multiple regions and environments in a single attribute
Diffstat (limited to 'config-application-package/src/test/java/com/yahoo')
-rw-r--r--config-application-package/src/test/java/com/yahoo/config/application/IncludeProcessorTest.java28
-rw-r--r--config-application-package/src/test/java/com/yahoo/config/application/XmlPreprocessorTest.java66
2 files changed, 64 insertions, 30 deletions
diff --git a/config-application-package/src/test/java/com/yahoo/config/application/IncludeProcessorTest.java b/config-application-package/src/test/java/com/yahoo/config/application/IncludeProcessorTest.java
index d3c2b672ee5..a456924673d 100644
--- a/config-application-package/src/test/java/com/yahoo/config/application/IncludeProcessorTest.java
+++ b/config-application-package/src/test/java/com/yahoo/config/application/IncludeProcessorTest.java
@@ -13,44 +13,48 @@ import java.io.*;
import java.nio.file.NoSuchFileException;
/**
- * @author lulf
- * @since 5.22
+ * @author Ulf Lilleengen
*/
public class IncludeProcessorTest {
@Test
- public void testInclude() throws IOException, SAXException, XMLStreamException, ParserConfigurationException, TransformerException {
+ public void testInclude() throws IOException, SAXException, ParserConfigurationException, TransformerException {
File app = new File("src/test/resources/multienvapp");
DocumentBuilder docBuilder = Xml.getPreprocessDocumentBuilder();
- String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><services xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\" version=\"1.0\">\n" +
+ String expected =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" +
+ "<services xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\" version=\"1.0\">\n" +
" <preprocess:properties>\n" +
" <qrs.port>4099</qrs.port>\n" +
" <qrs.port>5000</qrs.port>\n" +
" </preprocess:properties>\n" +
" <preprocess:properties deploy:environment='prod'>\n" +
" <qrs.port deploy:region='us-west'>5001</qrs.port>" +
- " <qrs.port deploy:region='us-east'>5002</qrs.port>" +
+ " <qrs.port deploy:region='us-east us-central'>5002</qrs.port>" +
" </preprocess:properties>\n" +
" <admin version=\"2.0\">\n" +
" <adminserver hostalias=\"node0\"/>\n" +
" </admin>\n" +
- " <admin deploy:environment=\"prod\" version=\"2.0\">\n" +
+ " <admin deploy:environment=\"staging prod\" deploy:region=\"us-east us-central\" version=\"2.0\">\n" +
" <adminserver hostalias=\"node1\"/>\n" +
" </admin>\n" +
" <content id=\"foo\" version=\"1.0\">\n" +
" <redundancy>1</redundancy><documents>\n" +
" <document mode=\"index\" type=\"music.sd\"/>\n" +
- "</documents><nodes>\n" +
+ " </documents><nodes>\n" +
" <node distribution-key=\"0\" hostalias=\"node0\"/>\n" +
- "</nodes><nodes deploy:environment=\"prod\">\n" +
+ " </nodes>" +
+ " <nodes deploy:environment=\"prod\">\n" +
" <node distribution-key=\"0\" hostalias=\"node0\"/>\n" +
" <node distribution-key=\"1\" hostalias=\"node1\"/>\n" +
- "</nodes><nodes deploy:environment=\"prod\" deploy:region=\"us-west\">\n" +
+ " </nodes>" +
+ " <nodes deploy:environment=\"prod\" deploy:region=\"us-west\">\n" +
" <node distribution-key=\"0\" hostalias=\"node0\"/>\n" +
" <node distribution-key=\"1\" hostalias=\"node1\"/>\n" +
" <node distribution-key=\"2\" hostalias=\"node2\"/>\n" +
- "</nodes></content>\n" +
+ " </nodes>" +
+ "</content>\n" +
"<jdisc id=\"stateless\" version=\"1.0\">\n" +
" <search deploy:environment=\"prod\">\n" +
" <chain id=\"common\">\n" +
@@ -68,7 +72,7 @@ public class IncludeProcessorTest {
" </nodes>\n" +
"</jdisc></services>";
- Document doc = (new IncludeProcessor(app)).process(docBuilder.parse(Xml.getServices(app)));
+ Document doc = new IncludeProcessor(app).process(docBuilder.parse(Xml.getServices(app)));
// System.out.println(Xml.documentAsString(doc));
TestBase.assertDocument(expected, doc);
}
@@ -77,7 +81,7 @@ public class IncludeProcessorTest {
public void testRequiredIncludeIsDefault() throws ParserConfigurationException, IOException, SAXException, TransformerException {
File app = new File("src/test/resources/multienvapp_failrequired");
DocumentBuilder docBuilder = Xml.getPreprocessDocumentBuilder();
- (new IncludeProcessor(app)).process(docBuilder.parse(Xml.getServices(app)));
+ new IncludeProcessor(app).process(docBuilder.parse(Xml.getServices(app)));
}
}
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 b20437bc259..3827fe2ad42 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
@@ -23,8 +23,10 @@ public class XmlPreprocessorTest {
private static final File services = new File(appDir, "services.xml");
@Test
- public void testPreProcessing() throws IOException, SAXException, XMLStreamException, ParserConfigurationException, TransformerException {
- String expectedDev = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><services xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\" version=\"1.0\">\n" +
+ public void testPreProcessing() throws IOException, SAXException, ParserConfigurationException, TransformerException {
+ String expectedDev =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" +
+ "<services xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\" version=\"1.0\">\n" +
" <admin version=\"2.0\">\n" +
" <adminserver hostalias=\"node0\"/>\n" +
" </admin>\n" +
@@ -46,14 +48,40 @@ public class XmlPreprocessorTest {
" </nodes>\n" +
" </jdisc>\n" +
"</services>";
+ TestBase.assertDocument(expectedDev, new XmlPreProcessor(appDir, services, Environment.dev, RegionName.from("default")).run());
- Document docDev = (new XmlPreProcessor(appDir, services, Environment.dev, RegionName.from("default")).run());
- TestBase.assertDocument(expectedDev, docDev);
-
+ String expectedStaging =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" +
+ "<services xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\" version=\"1.0\">\n" +
+ " <admin version=\"2.0\">\n" +
+ " <adminserver hostalias=\"node1\"/>\n" + // Difference from dev: node1
+ " </admin>\n" +
+ " <content id=\"foo\" version=\"1.0\">\n" +
+ " <redundancy>1</redundancy>\n" +
+ " <documents>\n" +
+ " <document mode=\"index\" type=\"music.sd\"/>\n" +
+ " </documents>\n" +
+ " <nodes>\n" +
+ " <node distribution-key=\"0\" hostalias=\"node0\"/>\n" +
+ " </nodes>\n" +
+ " </content>\n" +
+ " <jdisc id=\"stateless\" version=\"1.0\">\n" +
+ " <search/>\n" +
+ " <component bundle=\"foobundle\" class=\"MyFoo\" id=\"foo\"/>\n" +
+ "" + // Difference from dev: no TestBar
+ " <nodes>\n" +
+ " <node hostalias=\"node0\" baseport=\"5000\"/>\n" +
+ " </nodes>\n" +
+ " </jdisc>\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());
- String expectedUsWest = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><services xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\" version=\"1.0\">\n" +
+ String expectedUsWest =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" +
+ "<services xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\" version=\"1.0\">\n" +
" <admin version=\"2.0\">\n" +
- " <adminserver hostalias=\"node1\"/>\n" +
+ " <adminserver hostalias=\"node0\"/>\n" +
" </admin>\n" +
" <content id=\"foo\" version=\"1.0\">\n" +
" <redundancy>1</redundancy>\n" +
@@ -81,12 +109,11 @@ public class XmlPreprocessorTest {
" </nodes>\n" +
" </jdisc>\n" +
"</services>";
+ TestBase.assertDocument(expectedUsWest, new XmlPreProcessor(appDir, services, Environment.prod, RegionName.from("us-west")).run());
- Document docUsWest = (new XmlPreProcessor(appDir, services, Environment.prod, RegionName.from("us-west"))).run();
- // System.out.println(Xml.documentAsString(docUsWest));
- TestBase.assertDocument(expectedUsWest, docUsWest);
-
- String expectedUsEast = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><services xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\" version=\"1.0\">\n" +
+ String expectedUsEastAndCentral =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" +
+ "<services xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\" version=\"1.0\">\n" +
" <admin version=\"2.0\">\n" +
" <adminserver hostalias=\"node1\"/>\n" +
" </admin>\n" +
@@ -115,14 +142,16 @@ public class XmlPreprocessorTest {
" </nodes>\n" +
" </jdisc>\n" +
"</services>";
-
- Document docUsEast = (new XmlPreProcessor(appDir, services, Environment.prod, RegionName.from("us-east"))).run();
- TestBase.assertDocument(expectedUsEast, docUsEast);
+ TestBase.assertDocument(expectedUsEastAndCentral,
+ new XmlPreProcessor(appDir, services, Environment.prod, RegionName.from("us-east")).run());
+ TestBase.assertDocument(expectedUsEastAndCentral,
+ new XmlPreProcessor(appDir, services, Environment.prod, RegionName.from("us-central")).run());
}
@Test
- public void testPropertiesWithOverlappingNames() throws IOException, SAXException, XMLStreamException, ParserConfigurationException, TransformerException {
- String input = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" +
+ public void testPropertiesWithOverlappingNames() throws IOException, SAXException, ParserConfigurationException, TransformerException {
+ String input =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" +
"<services xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\" version=\"1.0\">" +
" <preprocess:properties>" +
" <sherpa.host>gamma-usnc1.dht.yahoo.com</sherpa.host>" +
@@ -146,7 +175,8 @@ public class XmlPreprocessorTest {
" </admin>" +
"</services>";
- String expectedProd = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" +
+ String expectedProd =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" +
"<services xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\" version=\"1.0\">" +
" <config name='a'>" +
" <a>36000</a>" +