sodonnel commented on code in PR #3877:
URL: https://github.com/apache/ozone/pull/3877#discussion_r1003551310


##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/replication/health/TestClosingContainerHandler.java:
##########
@@ -153,32 +163,55 @@ public void testUnhealthyRatisReplicaIsNotClosed() {
   /**
    * Close commands should be sent for Open or Closing replicas.
    */
-  @Test
-  public void testOpenOrClosingReplicasAreClosed() {
+  @ParameterizedTest
+  @MethodSource("replicationConfigs")
+  public void testOpenOrClosingReplicasAreClosed(ReplicationConfig repConfig) {
     ContainerInfo containerInfo = ReplicationTestUtil.createContainerInfo(
-        ecReplicationConfig, 1, CLOSING);
-    Set<ContainerReplica> containerReplicas = ReplicationTestUtil
-        .createReplicas(containerInfo.containerID(),
-            ContainerReplicaProto.State.CLOSING, 1, 2);
-    containerReplicas.add(ReplicationTestUtil.createContainerReplica(
-        containerInfo.containerID(), 3,
-        HddsProtos.NodeOperationalState.IN_SERVICE,
-        ContainerReplicaProto.State.OPEN));
+        repConfig, 1, CLOSING);
+
+    final int replicas = repConfig.getRequiredNodes();
+    final int closing = replicas / 2 + 1;
+    final boolean force = repConfig.getReplicationType() != RATIS;
+
+    Set<ContainerReplica> containerReplicas = new HashSet<>();
+
+    // Add CLOSING container replicas with index [1, closing]
+    for (int i = 1; i <= closing; i++) {
+      containerReplicas.add(ReplicationTestUtil.createContainerReplica(
+          containerInfo.containerID(), i,

Review Comment:
   Minor point, but just incase it causes problems in the future, we should fix 
it.
   
   Ratis replicas should always have index = 0. EC replicas should always have 
indexes >= 1.
   
   Based on the force flag, you could set the index to `force == true ? i : 0` 
in the two loops.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to