diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFSAppStarvation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFSAppStarvation.java index 0712b4cda4..9665f9a7bb 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFSAppStarvation.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFSAppStarvation.java @@ -62,6 +62,9 @@ public void setup() { ALLOC_FILE.getAbsolutePath()); conf.setBoolean(FairSchedulerConfiguration.PREEMPTION, true); conf.setFloat(FairSchedulerConfiguration.PREEMPTION_THRESHOLD, 0f); + // This effectively disables the update thread since we call update + // explicitly on the main thread + conf.setLong(FairSchedulerConfiguration.UPDATE_INTERVAL_MS, Long.MAX_VALUE); } @After @@ -124,16 +127,17 @@ public void testPreemptionEnabled() throws Exception { // Wait for apps to be processed by MockPreemptionThread for (int i = 0; i < 6000; ++i) { - if(preemptionThread.totalAppsAdded() > - preemptionThread.uniqueAppsAdded()) { + if(preemptionThread.totalAppsAdded() >= + preemptionThread.uniqueAppsAdded() * 2) { break; } Thread.sleep(10); } - assertTrue("Each app is marked as starved exactly once", - preemptionThread.totalAppsAdded() > - preemptionThread.uniqueAppsAdded()); + assertEquals("Each app should be marked as starved once" + + " at each scheduler update above", + preemptionThread.totalAppsAdded(), + preemptionThread.uniqueAppsAdded() * 2); } /*