YARN-32. Fix TestApplicationTokens to not depend on test order and thus pass on JDK7. Contributed by Vinod Kumar Vavilapalli.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1399795 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vinod Kumar Vavilapalli 2012-10-18 19:12:13 +00:00
parent 4d5600f6c7
commit 6cfa710bad
2 changed files with 19 additions and 8 deletions

View File

@ -151,6 +151,9 @@ Release 0.23.5 - UNRELEASED
YARN-43. Fix TestResourceTrackerService to not depend on test order and thus
pass on JDK7. (Thomas Graves via vinodkv)
YARN-32. Fix TestApplicationTokens to not depend on test order and thus pass
on JDK7. (vinodkv)
OPTIMIZATIONS
BUG FIXES

View File

@ -64,6 +64,10 @@ public class TestApplicationTokens {
final MockRM rm = new MockRMWithAMS(new Configuration(), containerManager);
rm.start();
final Configuration conf = rm.getConfig();
final YarnRPC rpc = YarnRPC.create(conf);
AMRMProtocol rmClient = null;
try {
MockNM nm1 = rm.registerNode("localhost:1234", 5120);
@ -82,9 +86,6 @@ public class TestApplicationTokens {
ApplicationAttemptId applicationAttemptId = attempt.getAppAttemptId();
// Create a client to the RM.
final Configuration conf = rm.getConfig();
final YarnRPC rpc = YarnRPC.create(conf);
UserGroupInformation currentUser =
UserGroupInformation
.createRemoteUser(applicationAttemptId.toString());
@ -96,7 +97,7 @@ public class TestApplicationTokens {
token.decodeFromUrlString(tokenURLEncodedStr);
currentUser.addToken(token);
AMRMProtocol rmClient = createRMClient(rm, conf, rpc, currentUser);
rmClient = createRMClient(rm, conf, rpc, currentUser);
RegisterApplicationMasterRequest request =
Records.newRecord(RegisterApplicationMasterRequest.class);
@ -136,6 +137,9 @@ public class TestApplicationTokens {
} finally {
rm.stop();
if (rmClient != null) {
rpc.stopProxy(rmClient, conf); // To avoid using cached client
}
}
}
@ -153,6 +157,10 @@ public class TestApplicationTokens {
final MockRM rm = new MockRMWithAMS(config, containerManager);
rm.start();
final Configuration conf = rm.getConfig();
final YarnRPC rpc = YarnRPC.create(conf);
AMRMProtocol rmClient = null;
try {
MockNM nm1 = rm.registerNode("localhost:1234", 5120);
@ -171,9 +179,6 @@ public class TestApplicationTokens {
ApplicationAttemptId applicationAttemptId = attempt.getAppAttemptId();
// Create a client to the RM.
final Configuration conf = rm.getConfig();
final YarnRPC rpc = YarnRPC.create(conf);
UserGroupInformation currentUser =
UserGroupInformation
.createRemoteUser(applicationAttemptId.toString());
@ -185,7 +190,7 @@ public class TestApplicationTokens {
token.decodeFromUrlString(tokenURLEncodedStr);
currentUser.addToken(token);
AMRMProtocol rmClient = createRMClient(rm, conf, rpc, currentUser);
rmClient = createRMClient(rm, conf, rpc, currentUser);
RegisterApplicationMasterRequest request =
Records.newRecord(RegisterApplicationMasterRequest.class);
@ -217,6 +222,9 @@ public class TestApplicationTokens {
.getReboot());
} finally {
rm.stop();
if (rmClient != null) {
rpc.stopProxy(rmClient, conf); // To avoid using cached client
}
}
}