Skip to content

Commit 44d0af2

Browse files
committed
MAPREDUCE-6768. TestRecovery.testSpeculative failed with NPE. Contributed by Haibo Chen
1 parent 875c140 commit 44d0af2

File tree

1 file changed

+9
-0
lines changed
  • hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app

1 file changed

+9
-0
lines changed

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestRecovery.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import static org.mockito.Mockito.verify;
2626
import static org.mockito.Mockito.when;
2727

28+
import com.google.common.base.Supplier;
2829
import java.io.File;
2930
import java.io.FileInputStream;
3031
import java.io.IOException;
@@ -96,6 +97,7 @@
9697
import org.apache.hadoop.yarn.api.records.ContainerId;
9798
import org.apache.hadoop.yarn.api.records.Resource;
9899
import org.apache.hadoop.yarn.event.EventHandler;
100+
import org.apache.hadoop.test.GenericTestUtils;
99101
import org.apache.hadoop.yarn.util.Clock;
100102
import org.apache.hadoop.yarn.util.SystemClock;
101103
import org.junit.Test;
@@ -1195,7 +1197,14 @@ public void testSpeculative() throws Exception {
11951197
TaskAttempt task1Attempt1 = t1it.next();
11961198
TaskAttempt task1Attempt2 = t1it.next();
11971199
TaskAttempt task2Attempt = mapTask2.getAttempts().values().iterator().next();
1200+
final TaskAttempt t2a = task2Attempt;
11981201

1202+
// wait for the second task attempt to be assigned.
1203+
GenericTestUtils.waitFor(new Supplier<Boolean>() {
1204+
@Override public Boolean get() {
1205+
return t2a.getAssignedContainerID() != null;
1206+
}
1207+
}, 10, 10000);
11991208
ContainerId t1a2contId = task1Attempt2.getAssignedContainerID();
12001209

12011210
LOG.info(t1a2contId.toString());

0 commit comments

Comments
 (0)