diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestFetchFailure.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestFetchFailure.java index 8d25079b97..cb2a29e390 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestFetchFailure.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestFetchFailure.java @@ -24,6 +24,7 @@ import java.util.Arrays; import java.util.Iterator; +import com.google.common.base.Supplier; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.mapred.TaskCompletionEvent; import org.apache.hadoop.mapreduce.Counters; @@ -45,6 +46,7 @@ import org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptEvent; import org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptEventType; import org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptStatusUpdateEvent; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.yarn.event.EventHandler; import org.junit.Assert; import org.junit.Test; @@ -79,8 +81,19 @@ public void testFetchFailure() throws Exception { // wait for map success app.waitForState(mapTask, TaskState.SUCCEEDED); - - TaskAttemptCompletionEvent[] events = + + final int checkIntervalMillis = 10; + final int waitForMillis = 800; + GenericTestUtils.waitFor(new Supplier() { + @Override + public Boolean get() { + TaskAttemptCompletionEvent[] events = job + .getTaskAttemptCompletionEvents(0, 100); + return events.length >= 1; + } + }, checkIntervalMillis, waitForMillis); + + TaskAttemptCompletionEvent[] events = job.getTaskAttemptCompletionEvents(0, 100); Assert.assertEquals("Num completion events not correct", 1, events.length);