diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/metrics/TestDataNodeOutlierDetectionViaMetrics.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/metrics/TestDataNodeOutlierDetectionViaMetrics.java index eb7769e8fd2..2cade4b9ba3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/metrics/TestDataNodeOutlierDetectionViaMetrics.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/metrics/TestDataNodeOutlierDetectionViaMetrics.java @@ -18,6 +18,7 @@ package org.apache.hadoop.hdfs.server.datanode.metrics; +import com.google.common.base.Supplier; import org.apache.hadoop.test.GenericTestUtils; import org.apache.log4j.Level; import org.junit.Before; @@ -81,6 +82,13 @@ public class TestDataNodeOutlierDetectionViaMetrics { // Trigger a snapshot. peerMetrics.dumpSendPacketDownstreamAvgInfoAsJson(); + GenericTestUtils.waitFor(new Supplier() { + @Override + public Boolean get() { + return peerMetrics.getOutliers().size() > 0; + } + }, 500, 100_000); + final Map outliers = peerMetrics.getOutliers(); LOG.info("Got back outlier nodes: {}", outliers); assertThat(outliers.size(), is(1));