Apache Lucene open-source search software
SOLR-4513: We can speed up the Collections API test quite a bit by not loading any cores on startup.
Mark Robert Miller99b77c04aa17
diff --git a/solr/core/src/test-files/solr/solr-no-core.xml b/solr/core/src/test-files/solr/solr-no-core.xmlnew file mode 100644index 00000000000..986bc221e1a--- /dev/null+++ b/solr/core/src/test-files/solr/solr-no-core.xml@@ -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>diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.javaindex 8ad5e590aca..8d1cc0614d4 100644--- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java@@ -104,6 +104,10 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBaSystem.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 AbstractFullDistribZkTestBashardCount = 4;completionService = new ExecutorCompletionService<Request>(executor);pending = new HashSet<Future<Request>>();+ checkCreatedVsState = false;}@@ -135,25 +140,10 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa@Overridepublic 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();}diff --git a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.javaindex 521da88ac01..1713befb7c8 100644--- a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java+++ b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java@@ -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"));+ }+ }}diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.javaindex 1b6c8d1c39d..a3919516fa5 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java@@ -83,6 +83,7 @@ public abstract class AbstractDistribZkTestBase extends BaseDistributedSearchTes// give everyone there own solrhomeFile 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 BaseDistributedSearchTesif (sb.length() > 0) sb.append(',');// give everyone there own solrhomeFile 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()));diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.javaindex 2f7b9fa544f..da5f01ce61c 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java@@ -107,6 +107,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTesprotected 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 AbstractDistribZkTesFile 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 AbstractDistribZkTesinitCloud();- 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 AbstractDistribZkTesFile 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 AbstractDistribZkTesthis.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 stringfor (int i = 1; i <= numJettys / 2; i++) {