lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tflo...@apache.org
Subject [2/4] lucene-solr:jira/solr-10233: Include replica types in delete replicas by count
Date Tue, 16 May 2017 22:49:27 GMT
Include replica types in delete replicas by count


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

Branch: refs/heads/jira/solr-10233
Commit: 2bd43abce27fceb80a1b0809a797ccd571f3e108
Parents: bcdb827
Author: Tomas Fernandez Lobbe <tflobbe@apache.org>
Authored: Tue May 16 15:46:23 2017 -0700
Committer: Tomas Fernandez Lobbe <tflobbe@apache.org>
Committed: Tue May 16 15:46:23 2017 -0700

----------------------------------------------------------------------
 .../apache/solr/cloud/DeleteReplicaTest.java    | 22 +++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2bd43abc/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java b/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
index 5699a8f..4c6253e 100644
--- a/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
@@ -19,9 +19,11 @@ package org.apache.solr.cloud;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.EnumSet;
 
 import org.apache.solr.client.solrj.request.CollectionAdminRequest;
 import org.apache.solr.client.solrj.request.CoreStatus;
+import org.apache.solr.common.SolrException;
 import org.apache.solr.common.cloud.DocCollection;
 import org.apache.solr.common.cloud.Replica;
 import org.apache.solr.common.cloud.Slice;
@@ -101,11 +103,29 @@ public class DeleteReplicaTest extends SolrCloudTestCase {
   public void deleteReplicaByCount() throws Exception {
 
     final String collectionName = "deleteByCount";
-    CollectionAdminRequest.createCollection(collectionName, "conf", 1, 3).process(cluster.getSolrClient());
+    pickRandom(
+        CollectionAdminRequest.createCollection(collectionName, "conf", 1, 3),
+        CollectionAdminRequest.createCollection(collectionName, "conf", 1, 1, 1, 1),
+        CollectionAdminRequest.createCollection(collectionName, "conf", 1, 1, 0, 2),
+        CollectionAdminRequest.createCollection(collectionName, "conf", 1, 0, 1, 2))
+    .process(cluster.getSolrClient());
     waitForState("Expected a single shard with three replicas", collectionName, clusterShape(1,
3));
 
     CollectionAdminRequest.deleteReplicasFromShard(collectionName, "shard1", 2).process(cluster.getSolrClient());
     waitForState("Expected a single shard with a single replica", collectionName, clusterShape(1,
1));
+    
+    try {
+      CollectionAdminRequest.deleteReplicasFromShard(collectionName, "shard1", 1).process(cluster.getSolrClient());
+      fail("Expected Exception, Can't delete the last replica by count");
+    } catch (SolrException e) {
+      // expected
+      assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, e.code());
+      assertTrue(e.getMessage().contains("There is only one replica available"));
+    }
+    DocCollection docCollection = getCollectionState(collectionName);
+    // We know that since leaders are preserved, PULL replicas should not be left alone in
the shard
+    assertEquals(0, docCollection.getSlice("shard1").getReplicas(EnumSet.of(Replica.Type.PULL)).size());
+    
 
   }
 


Mime
View raw message