mirror of https://github.com/apache/lucene.git
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:
parent
8f2e504279
commit
9b985f6461
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.solr.core;
|
package org.apache.solr.core;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import org.apache.solr.cloud.ZkController;
|
import org.apache.solr.cloud.ZkController;
|
||||||
import org.apache.solr.cloud.ZkSolrResourceLoader;
|
import org.apache.solr.cloud.ZkSolrResourceLoader;
|
||||||
import org.apache.solr.common.SolrException;
|
import org.apache.solr.common.SolrException;
|
||||||
|
@ -158,6 +159,20 @@ public class CoreContainer {
|
||||||
this.coresLocator = locator;
|
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
|
* Create a new CoreContainer and load its cores
|
||||||
* @param solrHome the solr home directory
|
* @param solrHome the solr home directory
|
||||||
|
|
|
@ -17,7 +17,12 @@ package org.apache.solr.cloud;
|
||||||
* the License.
|
* 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.lucene.util.LuceneTestCase.Slow;
|
||||||
import org.apache.solr.SolrTestCaseJ4;
|
import org.apache.solr.SolrTestCaseJ4;
|
||||||
import org.apache.solr.common.cloud.SolrZkClient;
|
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.common.cloud.ZkStateReader;
|
||||||
import org.apache.solr.core.CoreContainer;
|
import org.apache.solr.core.CoreContainer;
|
||||||
import org.apache.solr.core.CoreDescriptor;
|
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.solr.util.ExternalPaths;
|
||||||
import org.apache.zookeeper.CreateMode;
|
import org.apache.zookeeper.CreateMode;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
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
|
@Slow
|
||||||
public class ZkControllerTest extends SolrTestCaseJ4 {
|
public class ZkControllerTest extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
|
@ -46,23 +47,14 @@ public class ZkControllerTest extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
|
|
||||||
|
|
||||||
private static final File solrHomeDirectory = new File(TEMP_DIR, "ZkControllerTest");
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() throws Exception {
|
public static void beforeClass() throws Exception {
|
||||||
if (solrHomeDirectory.exists()) {
|
createTempDir();
|
||||||
FileUtils.deleteDirectory(solrHomeDirectory);
|
|
||||||
}
|
|
||||||
copyMinFullSetup(solrHomeDirectory);
|
|
||||||
initCore();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void afterClass() throws Exception {
|
public static void afterClass() throws Exception {
|
||||||
if (solrHomeDirectory.exists()) {
|
|
||||||
FileUtils.deleteDirectory(solrHomeDirectory);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNodeNameUrlConversion() throws Exception {
|
public void testNodeNameUrlConversion() throws Exception {
|
||||||
|
@ -307,9 +299,7 @@ public class ZkControllerTest extends SolrTestCaseJ4 {
|
||||||
}
|
}
|
||||||
|
|
||||||
private CoreContainer getCoreContainer() {
|
private CoreContainer getCoreContainer() {
|
||||||
CoreContainer cc = new CoreContainer(solrHomeDirectory.getAbsolutePath());
|
return new MockCoreContainer();
|
||||||
cc.load();
|
|
||||||
return cc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -317,4 +307,25 @@ public class ZkControllerTest extends SolrTestCaseJ4 {
|
||||||
super.tearDown();
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue