lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject lucene-solr:branch_7x: SOLR-11469: LeaderElectionContextKeyTest has flawed logic: 50% of the time it checks the wrong shard's elections
Date Mon, 23 Oct 2017 07:46:53 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x 17aa801c1 -> 05ebac5a7


SOLR-11469: LeaderElectionContextKeyTest has flawed logic: 50% of the time it checks the wrong
shard's elections


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

Branch: refs/heads/branch_7x
Commit: 05ebac5a719910abc469b4b07b3a16cb4f883b29
Parents: 17aa801
Author: Cao Manh Dat <datcm@apache.org>
Authored: Mon Oct 23 14:45:32 2017 +0700
Committer: Cao Manh Dat <datcm@apache.org>
Committed: Mon Oct 23 14:46:42 2017 +0700

----------------------------------------------------------------------
 .../cloud/LeaderElectionContextKeyTest.java     | 35 +++++++++++++-------
 1 file changed, 23 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/05ebac5a/solr/core/src/test/org/apache/solr/cloud/LeaderElectionContextKeyTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/LeaderElectionContextKeyTest.java b/solr/core/src/test/org/apache/solr/cloud/LeaderElectionContextKeyTest.java
index bfb1c13..93b119e 100644
--- a/solr/core/src/test/org/apache/solr/cloud/LeaderElectionContextKeyTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/LeaderElectionContextKeyTest.java
@@ -26,6 +26,7 @@ import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.impl.HttpSolrClient;
 import org.apache.solr.client.solrj.request.CollectionAdminRequest;
 import org.apache.solr.client.solrj.request.CoreAdminRequest;
+import org.apache.solr.common.cloud.DocCollection;
 import org.apache.solr.common.cloud.Replica;
 import org.apache.solr.common.cloud.SolrZkClient;
 import org.apache.solr.common.cloud.ZkStateReader;
@@ -34,9 +35,6 @@ import org.hamcrest.CoreMatchers;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
-
-@AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/SOLR-11469")
 public class LeaderElectionContextKeyTest extends SolrCloudTestCase {
 
   private static final String TEST_COLLECTION_1 = "testCollection1";
@@ -48,14 +46,22 @@ public class LeaderElectionContextKeyTest extends SolrCloudTestCase {
         .addConfig("config", TEST_PATH().resolve("configsets").resolve("cloud-minimal").resolve("conf"))
         .configure();
 
-    CollectionAdminRequest
-        .createCollection("testCollection1", "config", 2, 1)
-        .setMaxShardsPerNode(1000)
-        .process(cluster.getSolrClient());
-    CollectionAdminRequest
-        .createCollection("testCollection2", "config", 2, 1)
-        .setMaxShardsPerNode(1000)
-        .process(cluster.getSolrClient());
+    for (int i = 1; i <= 2; i++) {
+      // Create two collections with same order of requests, no parallel
+      // therefore Assign.buildCoreNodeName will create same coreNodeName
+      CollectionAdminRequest
+          .createCollection("testCollection"+i, "config", 2, 1)
+          .setMaxShardsPerNode(100)
+          .setCreateNodeSet("")
+          .process(cluster.getSolrClient());
+      CollectionAdminRequest
+          .addReplicaToShard("testCollection"+i, "shard1")
+          .process(cluster.getSolrClient());
+      CollectionAdminRequest
+          .addReplicaToShard("testCollection"+i, "shard2")
+          .process(cluster.getSolrClient());
+    }
+
     AbstractDistribZkTestBase.waitForRecoveriesToFinish("testCollection1", cluster.getSolrClient().getZkStateReader(),
         false, true, 30);
     AbstractDistribZkTestBase.waitForRecoveriesToFinish("testCollection2", cluster.getSolrClient().getZkStateReader(),
@@ -69,11 +75,12 @@ public class LeaderElectionContextKeyTest extends SolrCloudTestCase {
     List<Replica> replicasOfCollection1 = stateReader.getClusterState().getCollection(TEST_COLLECTION_1).getReplicas();
     List<Replica> replicasOfCollection2 = stateReader.getClusterState().getCollection(TEST_COLLECTION_2).getReplicas();
     Replica replica = findLeaderReplicaWithDuplicatedName(replicasOfCollection1, replicasOfCollection2);
+    String shard = getShard(stateReader.getClusterState().getCollection(TEST_COLLECTION_1),
replica);
     assertNotNull(replica);
 
     SolrClient shardLeaderClient = new HttpSolrClient.Builder(replica.get("base_url").toString()).build();
     try {
-      assertEquals(1L, getElectionNodes(TEST_COLLECTION_1, "shard1", stateReader.getZkClient()).size());
+      assertEquals(1L, getElectionNodes(TEST_COLLECTION_1, shard, stateReader.getZkClient()).size());
       List<String> collection2Shard1Nodes = getElectionNodes(TEST_COLLECTION_2, "shard1",
stateReader.getZkClient());
       List<String> collection2Shard2Nodes = getElectionNodes(TEST_COLLECTION_2, "shard2",
stateReader.getZkClient());
       CoreAdminRequest.unloadCore(replica.getCoreName(), shardLeaderClient);
@@ -97,6 +104,10 @@ public class LeaderElectionContextKeyTest extends SolrCloudTestCase {
     }
   }
 
+  private String getShard(DocCollection docCollection, Replica replica) {
+    return docCollection.getShardId(replica.getNodeName(), replica.getCoreName());
+  }
+
   private Replica findLeaderReplicaWithDuplicatedName(List<Replica> replicas1, List<Replica>
replicas2) {
     for (Replica replica1 : replicas1) {
       if (!replica1.containsKey("leader")) continue;


Mime
View raw message