SOLR-5832: Scary logging from ZkControllerTest suggests test setup isn't doing what it's suppose to.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1578974 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2014-03-18 17:27:47 +00:00
parent 8f2e504279
commit 9b985f6461
3 changed files with 71 additions and 21 deletions

View File

@ -18,6 +18,7 @@
package org.apache.solr.core;
import com.google.common.collect.Maps;
import org.apache.solr.cloud.ZkController;
import org.apache.solr.cloud.ZkSolrResourceLoader;
import org.apache.solr.common.SolrException;
@ -158,6 +159,20 @@ public class CoreContainer {
this.coresLocator = locator;
}
/**
* This method allows subclasses to construct a CoreContainer
* without any default init behavior.
*
* @param testConstructor pass (Object)null.
* @lucene.experimental
*/
protected CoreContainer(Object testConstructor) {
solrHome = null;
loader = null;
coresLocator = null;
cfg = null;
}
/**
* Create a new CoreContainer and load its cores
* @param solrHome the solr home directory

View File

@ -17,7 +17,12 @@ package org.apache.solr.cloud;
* the License.
*/
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.cloud.SolrZkClient;
@ -25,18 +30,14 @@ import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.handler.component.HttpShardHandlerFactory;
import org.apache.solr.handler.component.ShardHandlerFactory;
import org.apache.solr.util.ExternalPaths;
import org.apache.zookeeper.CreateMode;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slow
public class ZkControllerTest extends SolrTestCaseJ4 {
@ -46,23 +47,14 @@ public class ZkControllerTest extends SolrTestCaseJ4 {
private static final boolean DEBUG = false;
private static final File solrHomeDirectory = new File(TEMP_DIR, "ZkControllerTest");
@BeforeClass
public static void beforeClass() throws Exception {
if (solrHomeDirectory.exists()) {
FileUtils.deleteDirectory(solrHomeDirectory);
}
copyMinFullSetup(solrHomeDirectory);
initCore();
createTempDir();
}
@AfterClass
public static void afterClass() throws Exception {
if (solrHomeDirectory.exists()) {
FileUtils.deleteDirectory(solrHomeDirectory);
}
}
public void testNodeNameUrlConversion() throws Exception {
@ -307,9 +299,7 @@ public class ZkControllerTest extends SolrTestCaseJ4 {
}
private CoreContainer getCoreContainer() {
CoreContainer cc = new CoreContainer(solrHomeDirectory.getAbsolutePath());
cc.load();
return cc;
return new MockCoreContainer();
}
@Override
@ -317,4 +307,25 @@ public class ZkControllerTest extends SolrTestCaseJ4 {
super.tearDown();
}
private static class MockCoreContainer extends CoreContainer {
private HttpShardHandlerFactory shardHandlerFactory;
public MockCoreContainer() {
super((Object)null);
this.shardHandlerFactory = new HttpShardHandlerFactory();
}
@Override
public void load() {};
@Override
public String getAdminPath() {
return "/admin/cores";
}
@Override
public ShardHandlerFactory getShardHandlerFactory() {
return shardHandlerFactory;
}
}
}

View File

@ -0,0 +1,24 @@
package org.apache.solr.util;
import org.apache.solr.core.CoreContainer;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
public class MockCoreContainer extends CoreContainer {
}