You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2021/01/09 15:54:32 UTC

[lucene-solr] branch branch_8x updated: SOLR-14999: Fixing SolrXmlConfig tests for hostPort.

This is an automated email from the ASF dual-hosted git repository.

houston pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new a305bad  SOLR-14999: Fixing SolrXmlConfig tests for hostPort.
a305bad is described below

commit a305bad5a3397d95c373255ec5f474bfec5b84e6
Author: Houston Putman <ho...@apache.org>
AuthorDate: Sat Jan 9 10:19:47 2021 -0500

    SOLR-14999: Fixing SolrXmlConfig tests for hostPort.
---
 solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java |  2 +-
 solr/core/src/test/org/apache/solr/core/TestSolrXml.java   | 14 ++++++++------
 2 files changed, 9 insertions(+), 7 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 fb91f47..f0b9718 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrXmlConfig.java
@@ -422,7 +422,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 35bc674..62bb1c6 100644
--- a/solr/core/src/test/org/apache/solr/core/TestSolrXml.java
+++ b/solr/core/src/test/org/apache/solr/core/TestSolrXml.java
@@ -130,11 +130,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>";
@@ -142,6 +143,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() {
@@ -314,18 +316,18 @@ 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 testCloudConfigRequiresHost() {
     expectedException.expect(SolrException.class);
-    expectedException.expectMessage("solrcloud section missing required entry 'hostPort'");
+    expectedException.expectMessage("solrcloud section missing required entry 'host'");
 
-    SolrXmlConfig.fromString(solrHome, "<solr><solrcloud><str name=\"host\">host</str></solrcloud></solr>");
+    SolrXmlConfig.fromString(solrHome, "<solr><solrcloud><int name=\"hostPort\">8983</int></solrcloud></solr>");
   }
 
   public void testCloudConfigRequiresHostContext() {