From 6cfa710bad1c6505affbac4f41b3ebd5857e982c Mon Sep 17 00:00:00 2001 From: Vinod Kumar Vavilapalli Date: Thu, 18 Oct 2012 19:12:13 +0000 Subject: [PATCH] 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 --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../security/TestApplicationTokens.java | 24 ++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index c575c3b9641..70f62a93fe5 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -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 diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestApplicationTokens.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestApplicationTokens.java index ae1ced715ab..e778af0e760 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestApplicationTokens.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestApplicationTokens.java @@ -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 + } } }