From e79f9da8de27cb34dd6979d441fdcdd5ed2e8ff9 Mon Sep 17 00:00:00 2001 From: Anu Engineer Date: Thu, 2 Mar 2017 15:10:47 -0800 Subject: [PATCH] HDFS-11484. Ozone: Fix flaky TestNodeManager#testScmNodeReportUpdate. Contributed by Xiaoyu Yao. --- .../hadoop/ozone/scm/node/TestNodeManager.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/scm/node/TestNodeManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/scm/node/TestNodeManager.java index 355baed66f0..b6acfd1149c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/scm/node/TestNodeManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/scm/node/TestNodeManager.java @@ -970,13 +970,14 @@ public class TestNodeManager { Thread.sleep(100); } - GenericTestUtils.waitFor(() -> nodeManager.waitForHeartbeatThead(), 100, - 4 * 1000); - assertEquals(nodeCount, nodeManager.getNodeCount(HEALTHY)); - final long expectedScmUsed = usedPerHeartbeat * (heartbeatCount -1); final long expectedRemaining = capacity - usedPerHeartbeat * (heartbeatCount - 1); + + GenericTestUtils.waitFor( + () -> nodeManager.getStats().getScmUsed() == expectedScmUsed, 100, + 4 * 1000); + assertEquals(capacity, nodeManager.getStats().getCapacity()); assertEquals(expectedScmUsed, nodeManager.getStats().getScmUsed()); assertEquals(expectedRemaining, nodeManager.getStats().getRemaining()); @@ -1001,11 +1002,11 @@ public class TestNodeManager { assertEquals(expectedRemaining, nodeManager.getNodeStats().get(0).getRemaining()); - // Wait up to 3 more seconds so the node becomes dead + // Wait up to 4 more seconds so the node becomes dead // Verify usage info should be updated. GenericTestUtils.waitFor( () -> nodeManager.getNodeCount(NodeManager.NODESTATE.DEAD) == 1, 100, - 3 * 1000); + 4 * 1000); assertEquals(0, nodeManager.getNodeStats().size()); assertEquals(0, nodeManager.getStats().getCapacity()); @@ -1026,6 +1027,9 @@ public class TestNodeManager { GenericTestUtils.waitFor( () -> nodeManager.getNodeCount(NodeManager.NODESTATE.HEALTHY) == 1, 100, 5 * 1000); + GenericTestUtils.waitFor( + () -> nodeManager.getStats().getScmUsed() == expectedScmUsed, 100, + 4 * 1000); assertEquals(nodeCount, nodeManager.getNodeStats().size()); assertEquals(capacity, nodeManager.getNodeStats().get(0).getCapacity()); assertEquals(expectedScmUsed,