diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMHATimelineCollectors.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMHATimelineCollectors.java index d4f156bd0b..f086d080e3 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMHATimelineCollectors.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMHATimelineCollectors.java @@ -18,6 +18,7 @@ package org.apache.hadoop.yarn.server.resourcemanager; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.server.api.records.AppCollectorData; @@ -27,6 +28,8 @@ import org.junit.Before; import org.junit.Test; +import com.google.common.base.Supplier; + import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -97,16 +100,28 @@ public void testRebuildCollectorDataOnFailover() throws Exception { assertEquals(collectorAddr2, results1.get(app2.getApplicationId()).getCollectorAddr()); - Map results2 - = nm2.nodeHeartbeat(true).getAppCollectors(); // addr of app1 should be collectorAddr1 since it's registering (no time - // stamp). - assertEquals(collectorAddr1, - results2.get(app1.getApplicationId()).getCollectorAddr()); - // addr of app2 should be collectorAddr22 since its version number is + // stamp). and addr of app2 should be collectorAddr22 since its version + // number is // greater. - assertEquals(collectorAddr22, - results2.get(app2.getApplicationId()).getCollectorAddr()); + GenericTestUtils.waitFor(new Supplier() { + @Override + public Boolean get() { + try { + Map results2 = nm2 + .nodeHeartbeat(true).getAppCollectors(); + if (null != results2) { + return collectorAddr1 == results2.get(app1.getApplicationId()) + .getCollectorAddr() + && collectorAddr22 == results2.get(app2.getApplicationId()) + .getCollectorAddr(); + } + return false; + } catch (Exception e) { + return false; + } + } + }, 300, 10000); // Now nm1 should get updated collector list nm1.getRegisteringCollectors().clear();