Browse Source

YARN-7721. Fix TestContinuousScheduling fails sporadically with NPE.

Contributed by Wilfred Spiegelenburg.
prabhujoseph 5 years ago
parent
commit
d4bde134e3

+ 9 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestContinuousScheduling.java

@@ -18,7 +18,9 @@
 
 package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair;
 
+import com.google.common.base.Supplier;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.NodeId;
@@ -383,8 +385,8 @@ public class TestContinuousScheduling extends FairSchedulerTestBase {
         true);
     ask1.add(request1);
     ask1.add(request2);
-    scheduler.allocate(id11, ask1, null, new ArrayList<ContainerId>(), null, null,
-        NULL_UPDATE_REQUESTS);
+    scheduler.allocate(id11, ask1, null, new ArrayList<ContainerId>(), null,
+        null, NULL_UPDATE_REQUESTS);
 
     NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1);
     scheduler.handle(nodeEvent1);
@@ -393,6 +395,11 @@ public class TestContinuousScheduling extends FairSchedulerTestBase {
     // time
     mockClock.tickSec(delayThresholdTimeMs / 1000);
     scheduler.attemptScheduling(node);
+    GenericTestUtils.waitFor(new Supplier<Boolean>() {
+      public Boolean get() {
+        return fsAppAttempt.getLastScheduledContainer().size() != 0;
+      }
+    }, 10, 4000);
     Map<SchedulerRequestKey, Long> lastScheduledContainer =
         fsAppAttempt.getLastScheduledContainer();
     long initSchedulerTime =