SOLR-7246: Speed up BasicZkTest, TestManagedResourceStorage

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1666749 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ramkumar Aiyengar 2015-03-14 21:33:16 +00:00
parent 97d1f28b62
commit 24b20a53ff
3 changed files with 21 additions and 1 deletions

View File

@ -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.

View File

@ -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");

View File

@ -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");