HDFS-11842. TestDataNodeOutlierDetectionViaMetrics UT fails intermittently. Controbuted by Hanisha Koneru.

This commit is contained in:
Arpit Agarwal 2017-05-17 19:38:54 -07:00
parent 4bb0565443
commit 3db695d400
1 changed files with 9 additions and 1 deletions

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.hdfs.server.datanode.metrics; package org.apache.hadoop.hdfs.server.datanode.metrics;
import com.google.common.base.Supplier;
import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.test.GenericTestUtils;
import org.apache.log4j.Level; import org.apache.log4j.Level;
import org.junit.Before; import org.junit.Before;
@ -71,7 +72,7 @@ public class TestDataNodeOutlierDetectionViaMetrics {
public void testOutlierIsDetected() throws Exception { public void testOutlierIsDetected() throws Exception {
final String slowNodeName = "SlowNode"; final String slowNodeName = "SlowNode";
DataNodePeerMetrics peerMetrics = new DataNodePeerMetrics( final DataNodePeerMetrics peerMetrics = new DataNodePeerMetrics(
"PeerMetrics-For-Test", WINDOW_INTERVAL_SECONDS, "PeerMetrics-For-Test", WINDOW_INTERVAL_SECONDS,
ROLLING_AVERAGE_WINDOWS); ROLLING_AVERAGE_WINDOWS);
@ -81,6 +82,13 @@ public class TestDataNodeOutlierDetectionViaMetrics {
// Trigger a snapshot. // Trigger a snapshot.
peerMetrics.dumpSendPacketDownstreamAvgInfoAsJson(); peerMetrics.dumpSendPacketDownstreamAvgInfoAsJson();
GenericTestUtils.waitFor(new Supplier<Boolean>() {
@Override
public Boolean get() {
return peerMetrics.getOutliers().size() > 0;
}
}, 500, 100_000);
final Map<String, Double> outliers = peerMetrics.getOutliers(); final Map<String, Double> outliers = peerMetrics.getOutliers();
LOG.info("Got back outlier nodes: {}", outliers); LOG.info("Got back outlier nodes: {}", outliers);
assertThat(outliers.size(), is(1)); assertThat(outliers.size(), is(1));