diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCloseContainerByPipeline.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCloseContainerByPipeline.java index 866bc321d5..f40e425523 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCloseContainerByPipeline.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCloseContainerByPipeline.java @@ -182,9 +182,11 @@ public class TestCloseContainerByPipeline { new CloseContainerCommand(containerID, HddsProtos.ReplicationType.STAND_ALONE, pipeline.getId())); - GenericTestUtils - .waitFor(() -> isContainerClosed(cluster, containerID, datanodeDetails), - 500, 5 * 1000); + // The log will appear after the state changed to closed in standalone, + // wait for the log to ensure the operation has been done. + GenericTestUtils.waitFor(() -> logCapturer.getOutput().contains( + "submitting CloseContainer request over STAND_ALONE server for" + + " container " + containerID), 500, 5 * 1000); //double check if it's really closed (waitFor also throws an exception) Assert.assertTrue(isContainerClosed(cluster, containerID, datanodeDetails)); @@ -260,7 +262,7 @@ public class TestCloseContainerByPipeline { containerData = datanodeService.getDatanodeStateMachine().getContainer() .getContainerSet().getContainer(containerID).getContainerData(); - return !containerData.isOpen(); + return containerData.isClosed(); } return false; }