YARN-1522. Fixed a race condition in the test TestApplicationCleanup that was causing it to randomly fail. Contributed by Liyin Liang.

svn merge --ignore-ancestry -c 1554328 ../../trunk/


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1554329 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vinod Kumar Vavilapalli 2013-12-30 22:22:24 +00:00
parent eb247009b2
commit e81796015a
2 changed files with 23 additions and 14 deletions

View File

@ -259,6 +259,9 @@ Release 2.4.0 - UNRELEASED
YARN-1527. Fix yarn rmadmin command to print the correct usage info.
(Akira AJISAKA via jianhe)
YARN-1522. Fixed a race condition in the test TestApplicationCleanup that was
causing it to randomly fail. (Liyin Liang via vinodkv)
Release 2.3.0 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -100,26 +100,32 @@ public void testAppCleanup() throws Exception {
//currently only containers are cleaned via this
//AM container is cleaned via container launcher
resp = nm1.nodeHeartbeat(true);
List<ContainerId> contsToClean = resp.getContainersToCleanup();
List<ApplicationId> apps = resp.getApplicationsToCleanup();
int cleanedConts = contsToClean.size();
int cleanedApps = apps.size();
List<ContainerId> containersToCleanup = resp.getContainersToCleanup();
List<ApplicationId> appsToCleanup = resp.getApplicationsToCleanup();
int numCleanedContainers = containersToCleanup.size();
int numCleanedApps = appsToCleanup.size();
waitCount = 0;
while ((cleanedConts < 2 || cleanedApps < 1) && waitCount++ < 200) {
while ((numCleanedContainers < 2 || numCleanedApps < 1)
&& waitCount++ < 200) {
LOG.info("Waiting to get cleanup events.. cleanedConts: "
+ cleanedConts + " cleanedApps: " + cleanedApps);
+ numCleanedContainers + " cleanedApps: " + numCleanedApps);
Thread.sleep(100);
resp = nm1.nodeHeartbeat(true);
contsToClean = resp.getContainersToCleanup();
apps = resp.getApplicationsToCleanup();
cleanedConts += contsToClean.size();
cleanedApps += apps.size();
List<ContainerId> deltaContainersToCleanup =
resp.getContainersToCleanup();
List<ApplicationId> deltaAppsToCleanup = resp.getApplicationsToCleanup();
// Add the deltas to the global list
containersToCleanup.addAll(deltaContainersToCleanup);
appsToCleanup.addAll(deltaAppsToCleanup);
// Update counts now
numCleanedContainers = containersToCleanup.size();
numCleanedApps = appsToCleanup.size();
}
Assert.assertEquals(1, apps.size());
Assert.assertEquals(app.getApplicationId(), apps.get(0));
Assert.assertEquals(1, cleanedApps);
Assert.assertEquals(2, cleanedConts);
Assert.assertEquals(1, appsToCleanup.size());
Assert.assertEquals(app.getApplicationId(), appsToCleanup.get(0));
Assert.assertEquals(1, numCleanedApps);
Assert.assertEquals(2, numCleanedContainers);
rm.stop();
}