xiaoyuyao commented on a change in pull request #1258:
URL: https://github.com/apache/hadoop-ozone/pull/1258#discussion_r464145469



##########
File path: 
hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/scm/TestReconContainerManager.java
##########
@@ -86,12 +104,39 @@ public void testCheckAndAddNewContainer() throws 
IOException {
     ReconContainerManager containerManager = getContainerManager();
     assertFalse(containerManager.exists(containerID));
     DatanodeDetails datanodeDetails = randomDatanodeDetails();
-    containerManager.checkAndAddNewContainer(containerID, datanodeDetails);
+    containerManager.checkAndAddNewContainer(containerID,
+        OPEN, datanodeDetails);
     assertTrue(containerManager.exists(containerID));
 
     // Doing it one more time should not change any state.
-    containerManager.checkAndAddNewContainer(containerID, datanodeDetails);
+    containerManager.checkAndAddNewContainer(containerID, OPEN,
+        datanodeDetails);
     assertTrue(containerManager.exists(containerID));
+    assertEquals(LifeCycleState.OPEN,
+        getContainerManager().getContainer(containerID).getState());
   }
 
+  @Test
+  public void testUpdateContainerStateFromOpen() throws IOException {
+    ContainerWithPipeline containerWithPipeline =
+        getTestContainer(LifeCycleState.OPEN);
+
+    long id = containerWithPipeline.getContainerInfo().getContainerID();
+    ContainerID containerID =
+        containerWithPipeline.getContainerInfo().containerID();
+
+    // Adding container #100.
+    getContainerManager().addNewContainer(id, containerWithPipeline);
+    assertEquals(LifeCycleState.OPEN,
+        getContainerManager().getContainer(containerID).getState());
+
+    DatanodeDetails datanodeDetails = randomDatanodeDetails();
+
+    // First report with "CLOSED" replica state moves container state to
+    // "CLOSING".
+    getContainerManager().checkAndAddNewContainer(containerID, State.CLOSED,
+        datanodeDetails);
+    assertEquals(CLOSING,
+        getContainerManager().getContainer(containerID).getState());

Review comment:
       LGTM.




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



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

Reply via email to