You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by tf...@apache.org on 2017/05/10 22:09:57 UTC

[3/6] lucene-solr:jira/solr-10233: Added test coverage for replica types with Collections API

Added test coverage for replica types with Collections API


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

Branch: refs/heads/jira/solr-10233
Commit: d9021e9e542e6ec4454720eb3c2b3da881987bc8
Parents: 507548a
Author: Tomas Fernandez Lobbe <tf...@apache.org>
Authored: Tue May 9 13:05:50 2017 -0700
Committer: Tomas Fernandez Lobbe <tf...@apache.org>
Committed: Tue May 9 13:05:50 2017 -0700

----------------------------------------------------------------------
 .../apache/solr/cloud/TestCollectionAPI.java    |  7 +++-
 .../apache/solr/cloud/TestPassiveReplica.java   | 43 ++++++++++++--------
 2 files changed, 33 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d9021e9e/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java b/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java
index dd55f23..68509b8 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java
@@ -60,7 +60,12 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
   @ShardsFixed(num = 2)
   public void test() throws Exception {
     try (CloudSolrClient client = createCloudClient(null)) {
-      CollectionAdminRequest.Create req = CollectionAdminRequest.createCollection(COLLECTION_NAME, "conf1",2,2);
+      CollectionAdminRequest.Create req;
+      if (useAppendReplicas()) {
+        req = CollectionAdminRequest.createCollection(COLLECTION_NAME, "conf1",2, 0, 1, 1);
+      } else {
+        req = CollectionAdminRequest.createCollection(COLLECTION_NAME, "conf1",2, 1, 0, 1);
+      }
       req.setMaxShardsPerNode(2);
       client.request(req);
       createCollection(null, COLLECTION_NAME1, 1, 1, 1, client, null, "conf1");

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d9021e9e/solr/core/src/test/org/apache/solr/cloud/TestPassiveReplica.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestPassiveReplica.java b/solr/core/src/test/org/apache/solr/cloud/TestPassiveReplica.java
index d087c19..e1f597b 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestPassiveReplica.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestPassiveReplica.java
@@ -63,7 +63,6 @@ public class TestPassiveReplica extends SolrCloudTestCase {
   
   private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
   
-  // TODO: Make sure that FORCELEADER can't be used with Passive
   // TODO: Backup/Snapshot should not work on passive replicas 
   // TODO: ADDSHARD operation
   
@@ -139,22 +138,34 @@ public class TestPassiveReplica extends SolrCloudTestCase {
       CollectionAdminRequest.createCollection(collectionName, "conf", 2, 1, 0, 3)
       .setMaxShardsPerNode(100)
       .process(cluster.getSolrClient());
-      DocCollection docCollection = getCollectionState(collectionName);
-      assertNotNull(docCollection);
-      assertEquals("Expecting 4 relpicas per shard",
-          8, docCollection.getReplicas().size());
-      assertEquals("Expecting 6 passive replicas, 3 per shard",
-          6, docCollection.getReplicas(EnumSet.of(Replica.Type.PASSIVE)).size());
-      assertEquals("Expecting 2 writer replicas, one per shard",
-          2, docCollection.getReplicas(EnumSet.of(Replica.Type.REALTIME)).size());
-      for (Slice s:docCollection.getSlices()) {
-        // read-only replicas can never become leaders
-        assertFalse(s.getLeader().getType() == Replica.Type.PASSIVE);
-        List<String> shardElectionNodes = cluster.getZkClient().getChildren(ZkStateReader.getShardLeadersElectPath(collectionName, s.getName()), null, true);
-        assertEquals("Unexpected election nodes for Shard: " + s.getName() + ": " + Arrays.toString(shardElectionNodes.toArray()), 
-            1, shardElectionNodes.size());
+      boolean reloaded = false;
+      while (true) {
+        DocCollection docCollection = getCollectionState(collectionName);
+        assertNotNull(docCollection);
+        assertEquals("Expecting 4 relpicas per shard",
+            8, docCollection.getReplicas().size());
+        assertEquals("Expecting 6 passive replicas, 3 per shard",
+            6, docCollection.getReplicas(EnumSet.of(Replica.Type.PASSIVE)).size());
+        assertEquals("Expecting 2 writer replicas, one per shard",
+            2, docCollection.getReplicas(EnumSet.of(Replica.Type.REALTIME)).size());
+        for (Slice s:docCollection.getSlices()) {
+          // read-only replicas can never become leaders
+          assertFalse(s.getLeader().getType() == Replica.Type.PASSIVE);
+          List<String> shardElectionNodes = cluster.getZkClient().getChildren(ZkStateReader.getShardLeadersElectPath(collectionName, s.getName()), null, true);
+          assertEquals("Unexpected election nodes for Shard: " + s.getName() + ": " + Arrays.toString(shardElectionNodes.toArray()), 
+              1, shardElectionNodes.size());
+        }
+        assertUlogPresence(docCollection);
+        if (reloaded) {
+          break;
+        } else {
+          // reload
+          CollectionAdminResponse response = CollectionAdminRequest.reloadCollection(collectionName)
+          .process(cluster.getSolrClient());
+          assertEquals(0, response.getStatus());
+          reloaded = true;
+        }
       }
-      assertUlogPresence(docCollection);
     } finally {
       zkClient().printLayoutToStdOut();
     }