devmadhuu commented on code in PR #10326:
URL: https://github.com/apache/ozone/pull/10326#discussion_r3373558233
##########
hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/scm/TestReconContainerManager.java:
##########
@@ -175,12 +179,188 @@ public void testUpdateContainerStateFromOpen() throws
Exception {
DatanodeDetails datanodeDetails = randomDatanodeDetails();
- // First report with "CLOSED" replica state moves container state to
+ // First report with "CLOSING" replica state moves container state to
// "CLOSING".
- getContainerManager().checkAndAddNewContainer(containerID, State.CLOSED,
+ getContainerManager().checkAndAddNewContainer(containerID, State.CLOSING,
datanodeDetails);
assertEquals(CLOSING,
getContainerManager().getContainer(containerID).getState());
+ assertFalse(getContainerManager().getPipelineToOpenContainer()
+ .containsKey(containerWithPipeline.getPipeline().getId()));
+ }
+
+ @Test
+ public void testOpenContainerReconcilesToClosedFromScmOnClosedDnReport()
+ throws Exception {
+ ContainerWithPipeline openContainer =
+ getTestContainer(113L, LifeCycleState.OPEN);
+ ContainerID containerID = openContainer.getContainerInfo().containerID();
+ getContainerManager().addNewContainer(openContainer);
+
+ when(getContainerManager().getScmClient()
+ .getContainerWithPipeline(containerID.getId()))
+ .thenReturn(getTestContainer(113L, CLOSED));
+
+ getContainerManager().checkAndAddNewContainer(containerID, State.CLOSED,
+ randomDatanodeDetails());
+
+ assertEquals(CLOSED,
+ getContainerManager().getContainer(containerID).getState());
+ assertFalse(getContainerManager().getPipelineToOpenContainer()
+ .containsKey(openContainer.getPipeline().getId()));
+ }
+
+ @Test
+ public void testOpenContainerNotUpdatedFromUnhealthyReplicaReports()
+ throws Exception {
+ for (State replicaState : new State[] {
+ State.UNHEALTHY, State.INVALID, State.DELETED}) {
+ ContainerWithPipeline containerWithPipeline =
+ getTestContainer(120L + replicaState.ordinal(), LifeCycleState.OPEN);
+ ContainerID containerID =
+ containerWithPipeline.getContainerInfo().containerID();
+ getContainerManager().addNewContainer(containerWithPipeline);
+
+ getContainerManager().checkAndAddNewContainer(containerID, replicaState,
+ randomDatanodeDetails());
+
+ assertEquals(LifeCycleState.OPEN,
+ getContainerManager().getContainer(containerID).getState());
+ assertTrue(getContainerManager().getPipelineToOpenContainer()
+ .containsKey(containerWithPipeline.getPipeline().getId()));
+ }
+ }
+
+ @Test
+ public void testClosingContainerAdvancesToQuasiClosedFromScm()
+ throws Exception {
+ assertClosingContainerAdvancesToScmState(101L, QUASI_CLOSED,
+ QUASI_CLOSED);
+ }
+
+ @Test
+ public void testClosingContainerAdvancesToClosedFromScm() throws Exception {
+ assertClosingContainerAdvancesToScmState(102L, CLOSED, CLOSED);
+ }
+
+ @Test
+ public void testClosingContainerAdvancesToDeletingFromScm()
+ throws Exception {
+ assertClosingContainerAdvancesToScmState(103L, DELETING, DELETING);
+ }
+
+ @Test
+ public void testClosingContainerAdvancesToDeletedFromScm() throws Exception {
+ assertClosingContainerAdvancesToScmState(104L, DELETED, DELETED);
+ }
+
+ @Test
+ public void testClosingContainerNotUpdatedFromUnhealthyReplicaReport()
+ throws Exception {
+ ContainerWithPipeline closingContainer = getTestContainer(105L, CLOSING);
+ ContainerID containerID =
closingContainer.getContainerInfo().containerID();
+ getContainerManager().addNewContainer(closingContainer);
+
+ getContainerManager().checkAndAddNewContainer(containerID, State.UNHEALTHY,
+ randomDatanodeDetails());
+
+ assertEquals(CLOSING,
+ getContainerManager().getContainer(containerID).getState());
+ }
+
+ @Test
+ public void testRecoverDeletedContainerToClosedFromDnReport()
+ throws Exception {
+ assertDeletedContainerRecoversFromScm(106L, State.CLOSED, CLOSED);
+ }
+
+ @Test
+ public void testRecoverDeletedContainerToQuasiClosedFromDnReport()
+ throws Exception {
+ assertDeletedContainerRecoversFromScm(107L, State.QUASI_CLOSED,
+ QUASI_CLOSED);
+ }
+
+ @Test
+ public void testDeletedContainerRecoversFromOpenDnReportWhenScmIsLive()
+ throws Exception {
+ assertDeletedContainerRecoversFromScm(108L, State.OPEN, CLOSED);
+ }
+
+ @Test
+ public void testDeletedContainerNotRecoveredWhenScmIsNotLive()
Review Comment:
No longer valid. I removed that code.
--
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]