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/12/03 15:56:50 UTC

svn commit: r1547416 - in /lucene/dev/branches/branch_4x: ./ solr/ solr/core/ solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java

Author: markrmiller
Date: Tue Dec  3 14:56:50 2013
New Revision: 1547416

URL: http://svn.apache.org/r1547416
Log:
SOLR-5449: Add more stress testing around creating and removing collections.

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java?rev=1547416&r1=1547415&r2=1547416&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java Tue Dec  3 14:56:50 2013
@@ -43,7 +43,6 @@ import javax.management.MBeanServer;
 import javax.management.MBeanServerFactory;
 import javax.management.ObjectName;
 
-import org.apache.lucene.util.Constants;
 import org.apache.lucene.util.LuceneTestCase.Slow;
 import org.apache.lucene.util._TestUtil;
 import org.apache.solr.SolrTestCaseJ4;
@@ -195,6 +194,7 @@ public class CollectionsAPIDistributedZk
     testSolrJAPICalls();
     testNodesUsedByCreate();
     testCollectionsAPI();
+    testCollectionsAPIAddRemoveStress();
     testErrorHandling();
     deletePartiallyCreatedCollection();
     deleteCollectionRemovesStaleZkCollectionsNode();
@@ -612,11 +612,11 @@ public class CollectionsAPIDistributedZk
     
     // create new collections rapid fire
     Map<String,List<Integer>> collectionInfos = new HashMap<String,List<Integer>>();
-    int cnt = random().nextInt(6) + 1;
+    int cnt = random().nextInt(TEST_NIGHTLY ? 6 : 3) + 1;
     
     for (int i = 0; i < cnt; i++) {
       int numShards = _TestUtil.nextInt(random(), 0, shardCount) + 1;
-      int replicationFactor = _TestUtil.nextInt(random(), 0, 3) + 2;
+      int replicationFactor = _TestUtil.nextInt(random(), 0, 3) + 1;
       int maxShardsPerNode = (((numShards * replicationFactor) / getCommonCloudSolrServer()
           .getZkStateReader().getClusterState().getLiveNodes().size())) + 1;
 
@@ -882,6 +882,80 @@ public class CollectionsAPIDistributedZk
     
     checkNoTwoShardsUseTheSameIndexDir();
   }
+  
+  private void testCollectionsAPIAddRemoveStress() throws Exception {
+    
+    class CollectionThread extends Thread {
+      
+      private String name;
+
+      public CollectionThread(String name) {
+        this.name = name;
+      }
+      
+      public void run() {
+        // create new collections rapid fire
+        Map<String,List<Integer>> collectionInfos = new HashMap<String,List<Integer>>();
+        int cnt = random().nextInt(TEST_NIGHTLY ? 13 : 3) + 1;
+        
+        for (int i = 0; i < cnt; i++) {
+          String collectionName = "awholynewstresscollection_" + name + "_" + i;
+          int numShards = _TestUtil.nextInt(random(), 0, shardCount * 2) + 1;
+          int replicationFactor = _TestUtil.nextInt(random(), 0, 3) + 1;
+          int maxShardsPerNode = (((numShards * 2 * replicationFactor) / getCommonCloudSolrServer()
+              .getZkStateReader().getClusterState().getLiveNodes().size())) + 1;
+          
+          CloudSolrServer client = null;
+          try {
+            if (i == 0) {
+              client = createCloudClient(null);
+            } else if (i == 1) {
+              client = createCloudClient(collectionName);
+            }
+            
+            createCollection(collectionInfos, collectionName,
+                numShards, replicationFactor, maxShardsPerNode, client, null,
+                "conf1");
+            
+            // remove collection
+            ModifiableSolrParams params = new ModifiableSolrParams();
+            params.set("action", CollectionAction.DELETE.toString());
+            params.set("name", collectionName);
+            QueryRequest request = new QueryRequest(params);
+            request.setPath("/admin/collections");
+            
+            if (client == null) {
+              client = createCloudClient(null);
+            }
+            
+            client.request(request);
+            
+          } catch (SolrServerException e) {
+            e.printStackTrace();
+            throw new RuntimeException(e);
+          } catch (IOException e) {
+            e.printStackTrace();
+            throw new RuntimeException(e);
+          } finally {
+            if (client != null) client.shutdown();
+          }
+        }
+      }
+    }
+    List<Thread> threads = new ArrayList<Thread>();
+    int numThreads = TEST_NIGHTLY ? 6 : 2;
+    for (int i = 0; i < numThreads; i++) {
+      CollectionThread thread = new CollectionThread("collection" + i);
+      threads.add(thread);
+    }
+    
+    for (Thread thread : threads) {
+      thread.start();
+    }
+    for (Thread thread : threads) {
+      thread.join();
+    }
+  }
 
   private void checkInstanceDirs(JettySolrRunner jetty) {
     CoreContainer cores = ((SolrDispatchFilter) jetty.getDispatchFilter()