Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id AAAED200CC8 for ; Fri, 30 Jun 2017 05:11:48 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A8494160BF7; Fri, 30 Jun 2017 03:11:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C8209160BED for ; Fri, 30 Jun 2017 05:11:47 +0200 (CEST) Received: (qmail 33999 invoked by uid 500); 30 Jun 2017 03:11:46 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 33990 invoked by uid 99); 30 Jun 2017 03:11:46 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Jun 2017 03:11:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B3141DFB30; Fri, 30 Jun 2017 03:11:46 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: datcm@apache.org To: commits@lucene.apache.org Message-Id: <48a74fc687424f8ab583ffd7779708c0@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: lucene-solr:feature/autoscaling: SOLR-10397: Hardness AutoAddReplicasPlanActionTest Date: Fri, 30 Jun 2017 03:11:46 +0000 (UTC) archived-at: Fri, 30 Jun 2017 03:11:48 -0000 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 Authored: Fri Jun 30 10:11:34 2017 +0700 Committer: Cao Manh Dat 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 coreNodeNames = lostJetty.getCoreContainer().getCores().stream() - .map(solrCore -> solrCore.getCoreDescriptor().getCloudDescriptor().getCoreNodeName()) - .collect(Collectors.toSet()); + List cloudDescriptors = lostJetty.getCoreContainer().getCores().stream() + .map(solrCore -> solrCore.getCoreDescriptor().getCloudDescriptor()) + .collect(Collectors.toList()); lostJetty.stop(); waitForNodeLeave(lostNodeName); List 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 operations, String lostNodeName, Set coreNodeNames, JettySolrRunner destJetty) { + private void assertOperations(String collection, List operations, String lostNodeName, + List 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 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); } } }