YARN-2785. Fixed intermittent TestContainerResourceUsage failure. Contributed by Varun Vasudev.

This commit is contained in:
Zhijie Shen 2014-11-02 15:20:40 -08:00
parent 5c0381c96a
commit 27715ec63b
2 changed files with 19 additions and 5 deletions

View File

@ -836,6 +836,9 @@ Release 2.6.0 - UNRELEASED
beyond HFDS delegation-token expiry even when RM is a proxy-user (YARN-2704). beyond HFDS delegation-token expiry even when RM is a proxy-user (YARN-2704).
(Jian He via vinodkv) (Jian He via vinodkv)
YARN-2785. Fixed intermittent TestContainerResourceUsage failure. (Varun Vasudev
via zjshen)
Release 2.5.1 - 2014-09-05 Release 2.5.1 - 2014-09-05
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -70,7 +70,7 @@ public class TestContainerResourceUsage {
public void tearDown() { public void tearDown() {
} }
@Test (timeout = 60000) @Test (timeout = 120000)
public void testUsageWithOneAttemptAndOneContainer() throws Exception { public void testUsageWithOneAttemptAndOneContainer() throws Exception {
MockRM rm = new MockRM(conf); MockRM rm = new MockRM(conf);
rm.start(); rm.start();
@ -102,7 +102,12 @@ public class TestContainerResourceUsage {
.getRMContainer(attempt0.getMasterContainer().getId()); .getRMContainer(attempt0.getMasterContainer().getId());
// Allow metrics to accumulate. // Allow metrics to accumulate.
Thread.sleep(1000); int sleepInterval = 1000;
int cumulativeSleepTime = 0;
while (rmAppMetrics.getMemorySeconds() <= 0 && cumulativeSleepTime < 5000) {
Thread.sleep(sleepInterval);
cumulativeSleepTime += sleepInterval;
}
rmAppMetrics = app0.getRMAppMetrics(); rmAppMetrics = app0.getRMAppMetrics();
Assert.assertTrue( Assert.assertTrue(
@ -127,7 +132,7 @@ public class TestContainerResourceUsage {
rm.stop(); rm.stop();
} }
@Test (timeout = 60000) @Test (timeout = 120000)
public void testUsageWithMultipleContainersAndRMRestart() throws Exception { public void testUsageWithMultipleContainersAndRMRestart() throws Exception {
// Set max attempts to 1 so that when the first attempt fails, the app // Set max attempts to 1 so that when the first attempt fails, the app
// won't try to start a new one. // won't try to start a new one.
@ -180,8 +185,14 @@ public class TestContainerResourceUsage {
.getSchedulerAppInfo(attempt0.getAppAttemptId()) .getSchedulerAppInfo(attempt0.getAppAttemptId())
.getLiveContainers(); .getLiveContainers();
// Give the metrics time to accumulate. // Allow metrics to accumulate.
Thread.sleep(1000); int sleepInterval = 1000;
int cumulativeSleepTime = 0;
while (app0.getRMAppMetrics().getMemorySeconds() <= 0
&& cumulativeSleepTime < 5000) {
Thread.sleep(sleepInterval);
cumulativeSleepTime += sleepInterval;
}
// Stop all non-AM containers // Stop all non-AM containers
for (Container c : conts) { for (Container c : conts) {