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

janhoy pushed a commit to branch branch_9_0
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_9_0 by this push:
     new 7d2ed3c  SOLR-9575 Fix remaining tests
7d2ed3c is described below

commit 7d2ed3cbccfc50905120edb55c6f2fad6697154d
Author: Jan Høydahl <[email protected]>
AuthorDate: Mon Jan 31 01:45:39 2022 +0100

    SOLR-9575 Fix remaining tests
    
    (cherry picked from commit 74a1febf58b168608a7a08acd25ccdf1f59c2160)
---
 .../src/test/org/apache/solr/cloud/SolrXmlInZkTest.java   | 15 ++++++++++++++-
 .../src/test/org/apache/solr/core/TestCoreDiscovery.java  | 12 +++++-------
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java 
b/solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java
index 55fcab8..8507ea2 100644
--- a/solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/SolrXmlInZkTest.java
@@ -140,8 +140,20 @@ public class SolrXmlInZkTest extends SolrTestCaseJ4 {
   }
 
   @Test
-  public void testNotInZkOrOnDisk() throws Exception {
+  public void testNotInZkOrOnDiskFallbackDefault() throws Exception {
     try {
+      setUpZkAndDiskXml(false, false);
+      assertEquals("Should have gotten the default port",
+          cfg.getCloudConfig().getSolrHostPort(), 8983);
+    } finally {
+      closeZK();
+    }
+  }
+
+  @Test
+  public void testNotInZkOrOnDiskWhenRequired() throws Exception {
+    try {
+      System.setProperty("solr.solrxml.required", "true");
       SolrException e = expectThrows(SolrException.class, () -> {
         System.setProperty("hostPort", "8787");
         setUpZkAndDiskXml(false, false); // solr.xml not on disk either
@@ -150,6 +162,7 @@ public class SolrXmlInZkTest extends SolrTestCaseJ4 {
           e.getMessage().contains("solr.xml does not exist"));
     } finally {
       closeZK();
+      System.clearProperty("solr.solrxml.required");
     }
   }
 
diff --git a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java 
b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
index 467ebb8..133927f 100644
--- a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
+++ b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
@@ -111,7 +111,7 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {
     FileUtils.copyFile(new File(top, 
"solrconfig.snippet.randomindexconfig.xml"), new File(confDir, 
"solrconfig.snippet.randomindexconfig.xml"));
   }
 
-  private CoreContainer init() throws Exception {
+  private CoreContainer init() {
     final CoreContainer container = new CoreContainer(solrHomeDirectory, new 
Properties());
     try {
       container.load();
@@ -122,9 +122,9 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {
 
     long status = container.getStatus();
 
-    assertTrue("Load complete flag should be set", 
+    assertTrue("Load complete flag should be set",
         (status & LOAD_COMPLETE) == LOAD_COMPLETE);
-    assertTrue("Core discovery should be complete", 
+    assertTrue("Core discovery should be complete",
         (status & CORE_DISCOVERY_COMPLETE) == CORE_DISCOVERY_COMPLETE);
     assertTrue("Initial core loading should be complete", 
         (status & INITIAL_CORE_LOAD_COMPLETE) == INITIAL_CORE_LOAD_COMPLETE);
@@ -324,9 +324,7 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {
       c5.close();
       c6.close();
     } finally {
-      if (cc != null) {
-        cc.shutdown();
-      }
+      cc.shutdown();
     }
   }
 
@@ -503,7 +501,7 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {
       cc = init();
     } catch (SolrException ex) {
       assertTrue("Core init doesn't report if solr home directory doesn't 
exist " + ex.getMessage(),
-          0 <= ex.getMessage().indexOf("solr.xml does not exist"));
+          ex.getMessage().contains("Error reading core root directory"));
     } finally {
       if (cc != null) {
         cc.shutdown();

Reply via email to