YARN-6747. TestFSAppStarvation.testPreemptionEnable fails intermittently. (Contributed by Miklos Szegedi)

(cherry picked from commit d4811c8cfae02f42a7aae1f775e87b6726caa3c9)
This commit is contained in:
Yufei Gu 2017-10-29 16:44:16 -07:00
parent 6b4319cc50
commit d9f027adbc

View File

@ -62,6 +62,9 @@ public void setup() {
ALLOC_FILE.getAbsolutePath()); ALLOC_FILE.getAbsolutePath());
conf.setBoolean(FairSchedulerConfiguration.PREEMPTION, true); conf.setBoolean(FairSchedulerConfiguration.PREEMPTION, true);
conf.setFloat(FairSchedulerConfiguration.PREEMPTION_THRESHOLD, 0f); 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 @After
@ -124,16 +127,17 @@ public void testPreemptionEnabled() throws Exception {
// Wait for apps to be processed by MockPreemptionThread // Wait for apps to be processed by MockPreemptionThread
for (int i = 0; i < 6000; ++i) { for (int i = 0; i < 6000; ++i) {
if(preemptionThread.totalAppsAdded() > if(preemptionThread.totalAppsAdded() >=
preemptionThread.uniqueAppsAdded()) { preemptionThread.uniqueAppsAdded() * 2) {
break; break;
} }
Thread.sleep(10); Thread.sleep(10);
} }
assertTrue("Each app is marked as starved exactly once", assertEquals("Each app should be marked as starved once" +
preemptionThread.totalAppsAdded() > " at each scheduler update above",
preemptionThread.uniqueAppsAdded()); preemptionThread.totalAppsAdded(),
preemptionThread.uniqueAppsAdded() * 2);
} }
/* /*