SOLR-4513: We can speed up the Collections API test quite a bit by not loading any cores on startup.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1451214 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2013-02-28 14:30:30 +00:00
parent 7c3f4ce119
commit 99b77c04aa
5 changed files with 74 additions and 22 deletions

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
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.
-->
<!--
All (relative) paths are relative to the installation path
persistent: Save changes made via the API to this file
sharedLib: path to a lib directory that will be shared across all cores
-->
<solr persistent="${solr.xml.persist:false}">
<!--
adminPath: RequestHandler path to manage cores.
If 'null' (or absent), cores will not be manageable via request handler
-->
<cores adminPath="/admin/cores" defaultCoreName="collection1" host="127.0.0.1" hostPort="${hostPort:8983}"
hostContext="${hostContext:solr}" zkClientTimeout="${solr.zkclienttimeout:30000}" numShards="${numShards:3}" shareSchema="${shareSchema:false}"
distribUpdateConnTimeout="${distribUpdateConnTimeout:15000}" distribUpdateSoTimeout="${distribUpdateSoTimeout:120000}">
<shardHandlerFactory name="shardHandlerFactory" class="HttpShardHandlerFactory">
<int name="socketTimeout">${socketTimeout:120000}</int>
<int name="connTimeout">${connTimeout:15000}</int>
</shardHandlerFactory>
</cores>
</solr>

View File

@ -104,6 +104,10 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
System.setProperty("numShards", Integer.toString(sliceCount));
System.setProperty("solr.xml.persist", "true");
}
protected String getSolrXml() {
return "solr-no-core.xml";
}
public CollectionsAPIDistributedZkTest() {
@ -113,6 +117,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
shardCount = 4;
completionService = new ExecutorCompletionService<Request>(executor);
pending = new HashSet<Future<Request>>();
checkCreatedVsState = false;
}
@ -135,25 +140,10 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
@Override
public void doTest() throws Exception {
// setLoggingLevel(null);
ZkStateReader zkStateReader = cloudClient.getZkStateReader();
// make sure we have leaders for each shard
for (int j = 1; j < sliceCount; j++) {
zkStateReader.getLeaderRetry(DEFAULT_COLLECTION, "shard" + j, 10000);
} // make sure we again have leaders for each shard
waitForRecoveriesToFinish(false);
del("*:*");
// would be better if these where all separate tests - but much, much
// slower
testNodesUsedByCreate();
testCollectionsAPI();
// Thread.sleep(10000000000L);
if (DEBUG) {
super.printLayout();
}

View File

@ -33,6 +33,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import junit.framework.Assert;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.search.FieldCache;
import org.apache.lucene.util. _TestUtil;
import org.apache.lucene.util.Constants;
@ -857,4 +858,16 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
return df.toExternal(d);
}
}
protected String getSolrXml() {
return null;
}
protected void setupJettySolrHome(File jettyHome) throws IOException {
FileUtils.copyDirectory(new File(getSolrHome()), jettyHome);
String solrxml = getSolrXml();
if (solrxml != null) {
FileUtils.copyFile(new File(getSolrHome(), solrxml), new File(jettyHome, "solr.xml"));
}
}
}

View File

@ -83,6 +83,7 @@ public abstract class AbstractDistribZkTestBase extends BaseDistributedSearchTes
// give everyone there own solrhome
File controlHome = new File(new File(getSolrHome()).getParentFile(), "control" + homeCount.incrementAndGet());
FileUtils.copyDirectory(new File(getSolrHome()), controlHome);
setupJettySolrHome(controlHome);
System.setProperty("collection", "control_collection");
String numShardsS = System.getProperty(ZkStateReader.NUM_SHARDS_PROP);
@ -102,7 +103,7 @@ public abstract class AbstractDistribZkTestBase extends BaseDistributedSearchTes
if (sb.length() > 0) sb.append(',');
// give everyone there own solrhome
File jettyHome = new File(new File(getSolrHome()).getParentFile(), "jetty" + homeCount.incrementAndGet());
FileUtils.copyDirectory(new File(getSolrHome()), jettyHome);
setupJettySolrHome(jettyHome);
JettySolrRunner j = createJetty(jettyHome, null, "shard" + (i + 2));
jettys.add(j);
clients.add(createNewSolrServer(j.getLocalPort()));

View File

@ -107,6 +107,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
protected Map<String,CloudJettyRunner> shardToLeaderJetty = new HashMap<String,CloudJettyRunner>();
private boolean cloudInit;
protected boolean checkCreatedVsState;
public static class CloudJettyRunner {
public JettySolrRunner jetty;
@ -247,7 +248,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
File controlJettyDir = new File(TEMP_DIR,
getClass().getName() + "-controljetty-" + System.currentTimeMillis());
org.apache.commons.io.FileUtils.copyDirectory(new File(getSolrHome()), controlJettyDir);
setupJettySolrHome(controlJettyDir);
controlJetty = createJetty(controlJettyDir, testDir + "/control/data"); // don't pass shard name... let it default to "shard1"
System.clearProperty("collection");
@ -272,9 +273,13 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
initCloud();
createJettys(numServers, true);
createJettys(numServers, checkCreatedVsState).size();
int cnt = getTotalReplicas(DEFAULT_COLLECTION);
if (cnt > 0) {
waitForCollection(cloudClient.getZkStateReader(), DEFAULT_COLLECTION, sliceCount);
}
waitForCollection(cloudClient.getZkStateReader(), DEFAULT_COLLECTION, sliceCount);
}
@ -319,7 +324,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
File jettyDir = new File(TEMP_DIR,
getClass().getName() + "-jetty" + cnt + "-" + System.currentTimeMillis());
jettyDir.mkdirs();
org.apache.commons.io.FileUtils.copyDirectory(new File(getSolrHome()), jettyDir);
setupJettySolrHome(jettyDir);
JettySolrRunner j = createJetty(jettyDir, testDir + "/jetty"
+ cnt, null, "solrconfig.xml", null);
jettys.add(j);
@ -330,10 +335,10 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
this.jettys.addAll(jettys);
this.clients.addAll(clients);
int numShards = getTotalReplicas(DEFAULT_COLLECTION);
if (checkCreatedVsState) {
// now wait until we see that the number of shards in the cluster state
// matches what we expect
int numShards = getTotalReplicas(DEFAULT_COLLECTION);
int retries = 0;
while (numShards != shardCount) {
numShards = getTotalReplicas(DEFAULT_COLLECTION);
@ -353,7 +358,9 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
}
}
updateMappingsFromZk(this.jettys, this.clients);
if (numShards > 0) {
updateMappingsFromZk(this.jettys, this.clients);
}
// build the shard string
for (int i = 1; i <= numJettys / 2; i++) {