YARN-1910. Fixed a race condition in TestAMRMTokens that causes the test to fail more often on Windows. Contributed by Xuan Gong.

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


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1586193 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vinod Kumar Vavilapalli 2014-04-10 01:37:22 +00:00
parent 55758cbd81
commit 614faccf1d
2 changed files with 15 additions and 0 deletions

View File

@ -79,6 +79,9 @@ Release 2.4.1 - UNRELEASED
YARN-1908. Fixed DistributedShell to not fail in secure clusters. (Vinod YARN-1908. Fixed DistributedShell to not fail in secure clusters. (Vinod
Kumar Vavilapalli and Jian He via vinodkv) Kumar Vavilapalli and Jian He via vinodkv)
YARN-1910. Fixed a race condition in TestAMRMTokens that causes the test to
fail more often on Windows. (Xuan Gong via vinodkv)
Release 2.4.0 - 2014-04-07 Release 2.4.0 - 2014-04-07
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -48,6 +48,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.TestAMAuthorization.MockRMW
import org.apache.hadoop.yarn.server.resourcemanager.TestAMAuthorization.MyContainerManager; import org.apache.hadoop.yarn.server.resourcemanager.TestAMAuthorization.MyContainerManager;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptContainerFinishedEvent; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptContainerFinishedEvent;
import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.server.utils.BuilderUtils;
import org.apache.hadoop.yarn.util.Records; import org.apache.hadoop.yarn.util.Records;
@ -63,6 +64,7 @@ public class TestAMRMTokens {
private static final Log LOG = LogFactory.getLog(TestAMRMTokens.class); private static final Log LOG = LogFactory.getLog(TestAMRMTokens.class);
private final Configuration conf; private final Configuration conf;
private static final int maxWaitAttempts = 50;
@Parameters @Parameters
public static Collection<Object[]> configs() { public static Collection<Object[]> configs() {
@ -153,6 +155,16 @@ public class TestAMRMTokens {
new RMAppAttemptContainerFinishedEvent(applicationAttemptId, new RMAppAttemptContainerFinishedEvent(applicationAttemptId,
containerStatus)); containerStatus));
// Make sure the RMAppAttempt is at Finished State.
// Both AMRMToken and ClientToAMToken have been removed.
int count = 0;
while (attempt.getState() != RMAppAttemptState.FINISHED
&& count < maxWaitAttempts) {
Thread.sleep(100);
count++;
}
Assert.assertTrue(attempt.getState() == RMAppAttemptState.FINISHED);
// Now simulate trying to allocate. RPC call itself should throw auth // Now simulate trying to allocate. RPC call itself should throw auth
// exception. // exception.
rpc.stopProxy(rmClient, conf); // To avoid using cached client rpc.stopProxy(rmClient, conf); // To avoid using cached client