lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1547415 - /lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
Date Tue, 03 Dec 2013 14:55:42 GMT
Author: markrmiller
Date: Tue Dec  3 14:55:42 2013
New Revision: 1547415

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

Modified:
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java

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=1547415&r1=1547414&r2=1547415&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
Tue Dec  3 14:55:42 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()



Mime
View raw message