From commits-return-102403-archive-asf-public=cust-asf.ponee.io@lucene.apache.org Wed Jul 25 18:12:35 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 2832818062C for ; Wed, 25 Jul 2018 18:12:34 +0200 (CEST) Received: (qmail 53514 invoked by uid 500); 25 Jul 2018 16:12:34 -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 53504 invoked by uid 99); 25 Jul 2018 16:12:34 -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; Wed, 25 Jul 2018 16:12:34 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B13FCDFA6C; Wed, 25 Jul 2018 16:12:33 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: shalin@apache.org To: commits@lucene.apache.org Message-Id: <9df55de1bbf74e728d0737dde921f72b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: lucene-solr:jira/solr-11990: SOLR-11990: Added another test which creates two collections which are colocated with two different collections and ensures that create collection and add replica operations work correctly Date: Wed, 25 Jul 2018 16:12:33 +0000 (UTC) Repository: lucene-solr Updated Branches: refs/heads/jira/solr-11990 4cead778f -> 6bfcd0786 SOLR-11990: Added another test which creates two collections which are colocated with two different collections and ensures that create collection and add replica operations work correctly Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6bfcd078 Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6bfcd078 Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6bfcd078 Branch: refs/heads/jira/solr-11990 Commit: 6bfcd0786bb30353de9c26a01ec97ce3191b58f8 Parents: 4cead77 Author: Shalin Shekhar Mangar Authored: Wed Jul 25 21:42:25 2018 +0530 Committer: Shalin Shekhar Mangar Committed: Wed Jul 25 21:42:25 2018 +0530 ---------------------------------------------------------------------- .../apache/solr/cloud/TestWithCollection.java | 83 ++++++++++++++++++-- 1 file changed, 78 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6bfcd078/solr/core/src/test/org/apache/solr/cloud/TestWithCollection.java ---------------------------------------------------------------------- diff --git a/solr/core/src/test/org/apache/solr/cloud/TestWithCollection.java b/solr/core/src/test/org/apache/solr/cloud/TestWithCollection.java index 0379dcc..a4816a0 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestWithCollection.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestWithCollection.java @@ -514,18 +514,91 @@ public class TestWithCollection extends SolrCloudTestCase { assertEquals(1, replicas.size()); } + public void testMultipleWithCollections() throws Exception { + String prefix = "testMultipleWithCollections"; + String xyz = prefix + "_xyz"; + String xyz2 = prefix + "_xyz2"; + String abc = prefix + "_abc"; + String abc2 = prefix + "_abc2"; + + // start 2 more nodes so we have 4 in total + cluster.startJettySolrRunner(); + cluster.startJettySolrRunner(); + cluster.waitForAllNodes(30); + + CloudSolrClient solrClient = cluster.getSolrClient(); + + String setClusterPolicyCommand = "{" + + " 'set-cluster-policy': [" + + " {'cores':'<10', 'node':'#ANY'}," + + " {'replica':'<2', 'node':'#ANY'}," + + " ]" + + "}"; + SolrRequest req = createAutoScalingRequest(SolrRequest.METHOD.POST, setClusterPolicyCommand); + solrClient.request(req); + + String chosenNode = cluster.getJettySolrRunner(0).getNodeName(); + log.info("Chosen node {} for collection {}", chosenNode, abc); + + CollectionAdminRequest.createCollection(abc, 1, 1) + .setCreateNodeSet(chosenNode) + .process(solrClient); + CollectionAdminRequest.createCollection(xyz, 1, 1) + .setWithCollection(abc) + .process(solrClient); + + String chosenNode2 = cluster.getJettySolrRunner(1).getNodeName(); + log.info("Chosen node {} for collection {}", chosenNode2, abc2); + CollectionAdminRequest.createCollection(abc2, 1, 1) + .setCreateNodeSet(chosenNode2) + .process(solrClient); + CollectionAdminRequest.createCollection(xyz2, 1, 1) + .setWithCollection(abc2) + .process(solrClient); + + // refresh + DocCollection collection = solrClient.getZkStateReader().getClusterState().getCollection(xyz); + DocCollection collection2 = solrClient.getZkStateReader().getClusterState().getCollection(xyz2); + DocCollection withCollection = solrClient.getZkStateReader().getClusterState().getCollection(abc); + DocCollection withCollection2 = solrClient.getZkStateReader().getClusterState().getCollection(abc2); + + // sanity check + assertColocated(collection, chosenNode2, withCollection); // no replica should be on chosenNode2 + assertColocated(collection2, chosenNode, withCollection2); // no replica should be on chosenNode + + String chosenNode3 = cluster.getJettySolrRunner(2).getNodeName(); + CollectionAdminRequest.addReplicaToShard(xyz, "shard1") + .setNode(chosenNode3) + .process(solrClient); + String chosenNode4 = cluster.getJettySolrRunner(2).getNodeName(); + CollectionAdminRequest.addReplicaToShard(xyz2, "shard1") + .setNode(chosenNode4) + .process(solrClient); + + collection = solrClient.getZkStateReader().getClusterState().getCollection(xyz); + collection2 = solrClient.getZkStateReader().getClusterState().getCollection(xyz2); + withCollection = solrClient.getZkStateReader().getClusterState().getCollection(abc); + withCollection2 = solrClient.getZkStateReader().getClusterState().getCollection(abc2); + + // sanity check + assertColocated(collection, null, withCollection); + assertColocated(collection2, null, withCollection2); + } + /** - * Asserts that all replicas of collection on the given node are colocated with at least one - * replica of the withCollection. + * Asserts that all replicas of collection are colocated with at least one + * replica of the withCollection and none of them should be on the given 'noneOnNode'. */ - private void assertColocated(DocCollection collection, String node, DocCollection withCollection) { + private void assertColocated(DocCollection collection, String noneOnNode, DocCollection withCollection) { // sanity check assertTrue(collection.getReplicas().stream().noneMatch( replica -> withCollection.getReplicas(replica.getNodeName()) == null || withCollection.getReplicas(replica.getNodeName()).isEmpty())); - assertTrue(collection.getReplicas().stream().noneMatch( - replica -> node.equals(replica.getNodeName()))); + if (noneOnNode != null) { + assertTrue(collection.getReplicas().stream().noneMatch( + replica -> noneOnNode.equals(replica.getNodeName()))); + } } private static CountDownLatch LATCH = new CountDownLatch(1);