This is an automated email from the ASF dual-hosted git repository. dweiss pushed a commit to branch jira/solr-13105-toMerge in repository https://gitbox.apache.org/repos/asf/solr.git
commit 0d98c2e58c9b9085c01876d8eb5b96a5855960ff Author: Houston Putman <[email protected]> AuthorDate: Sat Jan 9 10:19:47 2021 -0500 SOLR-14999: Fixing SolrXmlConfig tests for hostPort. --- .../src/java/org/apache/solr/core/SolrXmlConfig.java | 2 +- .../src/test/org/apache/solr/core/TestSolrXml.java | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java index 823aa28..b222c27 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java +++ b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java @@ -434,7 +434,7 @@ public class SolrXmlConfig { private static CloudConfig fillSolrCloudSection(NamedList<Object> nl, XmlConfigFile config, String defaultZkHost) { - int hostPort = parseInt("hostPort", removeValue(nl, "hostPort")); + int hostPort = parseInt("hostPort", required("solrcloud", "hostPort", removeValue(nl, "hostPort"))); if (hostPort <= 0) { // Default to the port that jetty is listening on, or 8983 if that is not provided. hostPort = parseInt("jetty.port", System.getProperty("jetty.port", "8983")); diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrXml.java b/solr/core/src/test/org/apache/solr/core/TestSolrXml.java index f45ae27..4405ddb 100644 --- a/solr/core/src/test/org/apache/solr/core/TestSolrXml.java +++ b/solr/core/src/test/org/apache/solr/core/TestSolrXml.java @@ -129,11 +129,12 @@ public class TestSolrXml extends SolrTestCaseJ4 { } public void testExplicitNullGivesDefaults() { + System.setProperty("jetty.port", "8000"); String solrXml = "<solr>" + "<null name=\"maxBooleanClauses\"/>" + "<solrcloud>" + "<str name=\"host\">host</str>" + - "<int name=\"hostPort\">8983</int>" + + "<int name=\"hostPort\">0</int>" + "<str name=\"hostContext\">solr</str>" + "<null name=\"leaderVoteWait\"/>" + "</solrcloud></solr>"; @@ -141,6 +142,7 @@ public class TestSolrXml extends SolrTestCaseJ4 { NodeConfig cfg = SolrXmlConfig.fromString(solrHome, solrXml); assertNull("maxBooleanClauses", cfg.getBooleanQueryMaxClauseCount()); // default is null assertEquals("leaderVoteWait", 180000, cfg.getCloudConfig().getLeaderVoteWait()); + assertEquals("hostPort", 8000, cfg.getCloudConfig().getSolrHostPort()); } public void testIntAsLongBad() { @@ -313,18 +315,25 @@ public class TestSolrXml extends SolrTestCaseJ4 { SolrXmlConfig.fromString(solrHome, solrXml); // return not used, only for validation } - public void testCloudConfigRequiresHost() { + public void testCloudConfigRequiresHostPort() { expectedException.expect(SolrException.class); - expectedException.expectMessage("solrcloud section missing required entry 'host'"); + expectedException.expectMessage("solrcloud section missing required entry 'hostPort'"); SolrXmlConfig.fromString(solrHome, "<solr><solrcloud></solrcloud></solr>"); } - public void testCloudConfigRequiresHostPort() { + public void testCloudConfigDefaultHostPort() { expectedException.expect(SolrException.class); expectedException.expectMessage("solrcloud section missing required entry 'hostPort'"); - SolrXmlConfig.fromString(solrHome, "<solr><solrcloud><str name=\"host\">host</str></solrcloud></solr>"); + SolrXmlConfig.fromString(solrHome, "<solr><solrcloud></solrcloud></solr>"); + } + + public void testCloudConfigRequiresHost() { + expectedException.expect(SolrException.class); + expectedException.expectMessage("solrcloud section missing required entry 'host'"); + + SolrXmlConfig.fromString(solrHome, "<solr><solrcloud><int name=\"hostPort\">8983</int></solrcloud></solr>"); } public void testCloudConfigRequiresHostContext() {
