Apache Lucene open-source search software
SOLR-7246: Speed up BasicZkTest, TestManagedResourceStorage
Ramkumar Aiyengar24b20a53ffd1
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex e90d572eec6..d54063779ec 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -315,6 +315,8 @@ Other Changes* SOLR-7173: Fix ReplicationFactorTest on Windows by adding better retrysupport after seeing no response exceptions. (Ishan Chattopadhyaya via Timothy Potter)+* SOLR-7246: Speed up BasicZkTest, TestManagedResourceStorage (Ramkumar Aiyengar)+================== 5.0.0 ==================Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.javaindex 078b75d59ab..ade905f1f61 100644--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java@@ -55,6 +55,7 @@ import org.apache.solr.core.SolrConfig;import org.apache.solr.core.SolrCore;import org.apache.solr.core.SolrResourceLoader;import org.apache.solr.core.SolrXmlConfig;+import org.apache.solr.core.ZkContainer;import org.apache.solr.handler.UpdateRequestHandler;import org.apache.solr.request.LocalSolrQueryRequest;import org.apache.solr.request.SolrQueryRequest;@@ -68,6 +69,7 @@ import org.apache.solr.util.AbstractSolrTestCase;import org.apache.solr.util.RevertDefaultThreadHandlerRule;import org.apache.solr.util.SSLTestConfig;import org.apache.solr.util.TestHarness;+import org.apache.zookeeper.KeeperException;import org.junit.AfterClass;import org.junit.BeforeClass;import org.junit.ClassRule;@@ -686,7 +688,21 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {*/public static void deleteCore() {log.info("###deleteCore" );- if (h != null) { h.close(); }+ if (h != null) {+ // If the test case set up Zk, it should still have it as available,+ // otherwise the core close will just be unnecessarily delayed.+ CoreContainer cc = h.getCoreContainer();+ if (! cc.getCores().isEmpty() && cc.isZooKeeperAware()) {+ try {+ cc.getZkController().getZkClient().exists("/", false);+ } catch (KeeperException e) {+ log.error("Testing connectivity to ZK by checking for root path failed", e);+ fail("Trying to tear down a ZK aware core container with ZK not reachable");+ } catch (InterruptedException ignored) {}+ }++ h.close();+ }if (factoryProp == null) {System.clearProperty("solr.directoryFactory");diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.javaindex 382d3d497d1..c317c9b2b8a 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java@@ -147,6 +147,8 @@ public abstract class AbstractZkTestCase extends SolrTestCaseJ4 {@AfterClasspublic static void azt_afterClass() throws Exception {+ deleteCore();+System.clearProperty("zkHost");System.clearProperty("solr.test.sys.prop1");System.clearProperty("solr.test.sys.prop2");