You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2013/02/28 15:30:30 UTC

svn commit: r1451214 - in /lucene/dev/trunk/solr: core/src/test-files/solr/ core/src/test/org/apache/solr/cloud/ test-framework/src/java/org/apache/solr/ test-framework/src/java/org/apache/solr/cloud/

Author: markrmiller
Date: Thu Feb 28 14:30:30 2013
New Revision: 1451214

URL: http://svn.apache.org/r1451214
Log:
SOLR-4513: We can speed up the Collections API test quite a bit by not loading any cores on startup.

Added:
    lucene/dev/trunk/solr/core/src/test-files/solr/solr-no-core.xml   (with props)
Modified:
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
    lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
    lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java
    lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java

Added: lucene/dev/trunk/solr/core/src/test-files/solr/solr-no-core.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test-files/solr/solr-no-core.xml?rev=1451214&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test-files/solr/solr-no-core.xml (added)
+++ lucene/dev/trunk/solr/core/src/test-files/solr/solr-no-core.xml Thu Feb 28 14:30:30 2013
@@ -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>

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java?rev=1451214&r1=1451213&r2=1451214&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java Thu Feb 28 14:30:30 2013
@@ -104,6 +104,10 @@ public class CollectionsAPIDistributedZk
     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 CollectionsAPIDistributedZk
     shardCount = 4;
     completionService = new ExecutorCompletionService<Request>(executor);
     pending = new HashSet<Future<Request>>();
+    checkCreatedVsState = false;
     
   }
   
@@ -135,25 +140,10 @@ public class CollectionsAPIDistributedZk
   
   @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();
     }

Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java?rev=1451214&r1=1451213&r2=1451214&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java Thu Feb 28 14:30:30 2013
@@ -33,6 +33,7 @@ import java.util.concurrent.atomic.Atomi
 
 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 BaseDistributedSea
       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"));
+    }
+  }
 }

Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java?rev=1451214&r1=1451213&r2=1451214&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java Thu Feb 28 14:30:30 2013
@@ -83,6 +83,7 @@ public abstract class AbstractDistribZkT
     // 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 AbstractDistribZkT
       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()));

Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java?rev=1451214&r1=1451213&r2=1451214&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java Thu Feb 28 14:30:30 2013
@@ -107,6 +107,7 @@ public abstract class AbstractFullDistri
   
   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 AbstractFullDistri
 
     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 AbstractFullDistri
 
     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 AbstractFullDistri
       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 AbstractFullDistri
     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 AbstractFullDistri
       }
     }
 
-    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++) {