CaoManhDat commented on a change in pull request #1167: SOLR-13845: 
DELETEREPLICA API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167#discussion_r381005608
 
 

 ##########
 File path: solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
 ##########
 @@ -170,6 +170,58 @@ public void deleteReplicaAndVerifyDirectoryCleanup() 
throws Exception {
     assertFalse("DataDirectory still exists", 
Files.exists(Paths.get(coreStatus.getDataDirectory())));
   }
 
+  @Test
+  public void deleteReplicaByCountWithType() throws Exception {
+
+    final String collectionName = "deleteByCountWithType";
+
+    Create req = CollectionAdminRequest.createCollection(collectionName, 
"conf", 1, 2, 0, 2);
+    req.setMaxShardsPerNode(2);
+    req.process(cluster.getSolrClient());
+    waitForState("Expected a single shard with six replicas", collectionName, 
clusterShape(1, 4));
+
+    CollectionAdminRequest.deleteReplicasFromShard(collectionName, "shard1", 
1, Replica.Type.NRT).process(cluster.getSolrClient());
+    waitForState("Expected a single shard with a single NRT replica", 
collectionName, clusterShape(1, 1, Replica.Type.NRT));
+    waitForState("Expected a single shard with two PULL replicas", 
collectionName, clusterShape(1, 2, Replica.Type.PULL));
+
+    CollectionAdminRequest.deleteReplicasFromShard(collectionName, "shard1", 
2, Replica.Type.PULL).process(cluster.getSolrClient());
+    waitForState("Expected a single shard with a single PULL replica", 
collectionName, clusterShape(1, 0, Replica.Type.PULL));
+
+    SolrException e = expectThrows(SolrException.class,
+        "Can't delete the last replica by count",
+        () -> CollectionAdminRequest.deleteReplicasFromShard(collectionName, 
"shard1", 1, Replica.Type.NRT).process(cluster.getSolrClient())
+    );
+    assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, e.code());
+    assertTrue(e.getMessage().contains("There are lesser num replicas or 
qualified leaders requested to be deleted than are available in 
shard/collection"));
+    DocCollection docCollection = getCollectionState(collectionName);
+    // We know that since leaders are preserved, PULL replicas should not be 
left alone in the shard
 
 Review comment:
   this one need updated too.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to