From 24b20a53ffd130224c62f49347b7b4a2fa118624 Mon Sep 17 00:00:00 2001 From: Ramkumar Aiyengar Date: Sat, 14 Mar 2015 21:33:16 +0000 Subject: [PATCH] SOLR-7246: Speed up BasicZkTest, TestManagedResourceStorage git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1666749 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 2 ++ .../java/org/apache/solr/SolrTestCaseJ4.java | 18 +++++++++++++++++- .../apache/solr/cloud/AbstractZkTestCase.java | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 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 retry support 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.java index 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.java index 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 { @AfterClass public static void azt_afterClass() throws Exception { + deleteCore(); + System.clearProperty("zkHost"); System.clearProperty("solr.test.sys.prop1"); System.clearProperty("solr.test.sys.prop2");