lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject lucene-solr:feature/autoscaling: SOLR-10397: Hardness AutoAddReplicasPlanActionTest
Date Fri, 30 Jun 2017 03:11:46 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/feature/autoscaling b18cf30dd -> 492eebc89


SOLR-10397: Hardness AutoAddReplicasPlanActionTest


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/492eebc8
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/492eebc8
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/492eebc8

Branch: refs/heads/feature/autoscaling
Commit: 492eebc8953dd37cdd4f5ac256dec46225443daa
Parents: b18cf30
Author: Cao Manh Dat <datcm@apache.org>
Authored: Fri Jun 30 10:11:34 2017 +0700
Committer: Cao Manh Dat <datcm@apache.org>
Committed: Fri Jun 30 10:11:34 2017 +0700

----------------------------------------------------------------------
 .../AutoAddReplicasPlanActionTest.java          | 43 ++++++++++++++------
 1 file changed, 31 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/492eebc8/solr/core/src/test/org/apache/solr/cloud/autoscaling/AutoAddReplicasPlanActionTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/AutoAddReplicasPlanActionTest.java
b/solr/core/src/test/org/apache/solr/cloud/autoscaling/AutoAddReplicasPlanActionTest.java
index ebefba2..ef7e3e9 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/AutoAddReplicasPlanActionTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/AutoAddReplicasPlanActionTest.java
@@ -18,6 +18,7 @@
 package org.apache.solr.cloud.autoscaling;
 
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
@@ -26,6 +27,7 @@ import java.util.stream.Collectors;
 import org.apache.solr.client.solrj.SolrRequest;
 import org.apache.solr.client.solrj.embedded.JettySolrRunner;
 import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.cloud.CloudDescriptor;
 import org.apache.solr.cloud.SolrCloudTestCase;
 import org.apache.solr.common.cloud.ClusterStateUtil;
 import org.apache.solr.common.cloud.ZkStateReader;
@@ -82,14 +84,14 @@ public class AutoAddReplicasPlanActionTest extends SolrCloudTestCase{
 
     JettySolrRunner lostJetty = random().nextBoolean()? jetty1 : jetty2;
     String lostNodeName = lostJetty.getNodeName();
-    Set<String> coreNodeNames = lostJetty.getCoreContainer().getCores().stream()
-        .map(solrCore -> solrCore.getCoreDescriptor().getCloudDescriptor().getCoreNodeName())
-        .collect(Collectors.toSet());
+    List<CloudDescriptor> cloudDescriptors = lostJetty.getCoreContainer().getCores().stream()
+        .map(solrCore -> solrCore.getCoreDescriptor().getCloudDescriptor())
+        .collect(Collectors.toList());
     lostJetty.stop();
     waitForNodeLeave(lostNodeName);
 
     List<SolrRequest> operations = getOperations(jetty3, lostNodeName);
-    assertOperations(collection1, operations, lostNodeName,coreNodeNames,  null);
+    assertOperations(collection1, operations, lostNodeName, cloudDescriptors,  null);
 
     lostJetty.start();
     ClusterStateUtil.waitForAllActiveAndLiveReplicas(cluster.getSolrClient().getZkStateReader(),
30000);
@@ -103,14 +105,14 @@ public class AutoAddReplicasPlanActionTest extends SolrCloudTestCase{
 
     lostJetty = random().nextBoolean()? jetty1 : jetty2;
     lostNodeName = lostJetty.getNodeName();
-    coreNodeNames = lostJetty.getCoreContainer().getCores().stream()
-        .map(solrCore -> solrCore.getCoreDescriptor().getCloudDescriptor().getCoreNodeName())
-        .collect(Collectors.toSet());
+    cloudDescriptors = lostJetty.getCoreContainer().getCores().stream()
+        .map(solrCore -> solrCore.getCoreDescriptor().getCloudDescriptor())
+        .collect(Collectors.toList());
     lostJetty.stop();
     waitForNodeLeave(lostNodeName);
 
     operations = getOperations(jetty3, lostNodeName);
-    assertOperations(collection1, operations, lostNodeName, coreNodeNames, jetty3);
+    assertOperations(collection1, operations, lostNodeName, cloudDescriptors, jetty3);
   }
 
   private void waitForNodeLeave(String lostNodeName) throws InterruptedException {
@@ -131,9 +133,10 @@ public class AutoAddReplicasPlanActionTest extends SolrCloudTestCase{
     return operations;
   }
 
-  private void assertOperations(String collection, List<SolrRequest> operations, String
lostNodeName, Set<String> coreNodeNames, JettySolrRunner destJetty) {
+  private void assertOperations(String collection, List<SolrRequest> operations, String
lostNodeName,
+                                List<CloudDescriptor> cloudDescriptors, JettySolrRunner
destJetty) {
     assertEquals("Replicas of " + collection + " is not fully moved, operations="+operations,
-        2, operations.size());
+        cloudDescriptors.stream().filter(cd -> cd.getCollectionName().equals(collection)).count(),
operations.size());
     for (SolrRequest solrRequest : operations) {
       assertTrue(solrRequest instanceof CollectionAdminRequest.MoveReplica);
       SolrParams params = solrRequest.getParams();
@@ -141,12 +144,28 @@ public class AutoAddReplicasPlanActionTest extends SolrCloudTestCase{
       assertEquals(params.get("collection"), collection);
 
       String replica = params.get("replica");
-      assertTrue("Can not find "+replica+ " in node " + lostNodeName, coreNodeNames.contains(replica));
+      boolean found = false;
+      Iterator<CloudDescriptor> it = cloudDescriptors.iterator();
+      while (it.hasNext()) {
+        CloudDescriptor cd = it.next();
+        if (cd.getCollectionName().equals(collection) && cd.getCoreNodeName().equals(replica))
{
+          found = true;
+          it.remove();
+          break;
+        }
+      }
+      assertTrue("Can not find "+replica+ " in node " + lostNodeName, found);
 
       String targetNode = params.get("targetNode");
       assertFalse("Target node match the lost one " + lostNodeName, lostNodeName.equals(targetNode));
       if (destJetty != null) {
-        assertEquals("Target not is expected", destJetty.getNodeName(), targetNode);
+        assertEquals("Target node is not as expectation", destJetty.getNodeName(), targetNode);
+      }
+    }
+
+    for (CloudDescriptor cd : cloudDescriptors) {
+      if (cd.getCollectionName().equals(collection)) {
+        fail("Exist replica which is not moved " + cd);
       }
     }
   }


Mime
View raw message