siddhantsangwan commented on code in PR #6967:
URL: https://github.com/apache/ozone/pull/6967#discussion_r1687620956


##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/TestContainerReportHandler.java:
##########
@@ -442,6 +446,85 @@ public void testClosingToClosedForECContainer()
     assertEquals(LifeCycleState.CLOSED, 
containerManager.getContainer(container2.containerID()).getState());
   }
 
+  /**
+   * Tests that a DELETING container transitions to CLOSED if a non-empty 
CLOSED replica is reported. It does not
+   * transition if a non-empty CLOSING (or any other state) replica is 
reported.
+   */
+  @Test
+  public void shouldTransitionFromDeletingToClosedWhenNonEmptyClosedReplica() 
throws IOException {
+    ContainerInfo container = getContainer(LifeCycleState.DELETING);
+    containerStateManager.addContainer(container.getProtobuf());
+
+    // set up a non-empty CLOSED replica
+    DatanodeDetails dnWithClosedReplica = 
nodeManager.getNodes(NodeStatus.inServiceHealthy()).get(0);
+    ContainerReplicaProto.Builder builder = ContainerReplicaProto.newBuilder();
+    ContainerReplicaProto closedReplica = 
builder.setContainerID(container.getContainerID())
+        .setIsEmpty(false)
+        .setState(ContainerReplicaProto.State.CLOSED)
+        .setKeyCount(0)
+        .setBlockCommitSequenceId(123)
+        .setOriginNodeId(dnWithClosedReplica.getUuidString()).build();
+
+    // set up a non-empty CLOSING replica
+    DatanodeDetails dnWithClosingReplica = 
nodeManager.getNodes(NodeStatus.inServiceHealthy()).get(1);
+    ContainerReplicaProto closingReplica = 
builder.setState(ContainerReplicaProto.State.CLOSING)
+        .setOriginNodeId(dnWithClosingReplica.getUuidString()).build();
+
+    // should not transition on processing the CLOSING replica's report
+    ContainerReportHandler containerReportHandler = new 
ContainerReportHandler(nodeManager, containerManager);
+    ContainerReportsProto closingContainerReport = 
getContainerReports(closingReplica);
+    containerReportHandler
+        .onMessage(new ContainerReportFromDatanode(dnWithClosingReplica, 
closingContainerReport), publisher);
+
+    assertEquals(LifeCycleState.DELETING, 
containerStateManager.getContainer(container.containerID()).getState());
+
+    // should transition on processing the CLOSED replica's report
+    ContainerReportsProto closedContainerReport = 
getContainerReports(closedReplica);
+    containerReportHandler
+        .onMessage(new ContainerReportFromDatanode(dnWithClosedReplica, 
closedContainerReport), publisher);
+    assertEquals(LifeCycleState.CLOSED, 
containerStateManager.getContainer(container.containerID()).getState());
+  }
+
+  /**
+   * Tests that a DELETING EC container transitions to CLOSED if a non-empty 
CLOSED replica is reported. It does not
+   * transition if a non-empty CLOSING (or any other state) replica is 
reported.
+   */
+  @Test
+  public void 
ecContainerShouldTransitionFromDeletingToClosedWhenNonEmptyClosedReplica() 
throws IOException {

Review Comment:
   I think it is clearer to keep them separate, since we're also considering 
quasi-closed replicas for Ratis containers.



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