From f2315f2e9c31879b8c30eb9028f1959dfe48e5f4 Mon Sep 17 00:00:00 2001 From: Xiaoyu Yao Date: Wed, 15 Aug 2018 08:10:08 -0700 Subject: [PATCH] HDDS-347. TestCloseContainerByPipeline#testCloseContainerViaStandaAlone sometimes fails. Contributed by Lixin Ge. --- .../commandhandler/TestCloseContainerByPipeline.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 void testCloseContainerViaStandAlone() 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 @@ private Boolean isContainerClosed(MiniOzoneCluster cluster, long containerID, containerData = datanodeService.getDatanodeStateMachine().getContainer() .getContainerSet().getContainer(containerID).getContainerData(); - return !containerData.isOpen(); + return containerData.isClosed(); } return false; }