.../yarn/server/TestContainerManagerSecurity.java | 46 ++++++---------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerManagerSecurity.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerManagerSecurity.java index f0dcb56..3a993b8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerManagerSecurity.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerManagerSecurity.java @@ -82,8 +82,6 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import com.google.common.io.ByteArrayDataInput; -import com.google.common.io.ByteStreams; @RunWith(Parameterized.class) public class TestContainerManagerSecurity extends KerberosSecurityTestcase { @@ -105,10 +103,20 @@ public void setUp() throws Exception { testRootDir.mkdirs(); httpSpnegoKeytabFile.deleteOnExit(); getKdc().createPrincipal(httpSpnegoKeytabFile, httpSpnegoPrincipal); + + yarnCluster = + new MiniYARNCluster(TestContainerManagerSecurity.class.getName(), 1, 1, + 1); + yarnCluster.init(conf); + yarnCluster.start(); } @After public void tearDown() { + if (yarnCluster != null) { + yarnCluster.stop(); + yarnCluster = null; + } testRootDir.delete(); } @@ -144,11 +152,6 @@ public TestContainerManagerSecurity(Configuration conf) { @Test (timeout = 120000) public void testContainerManager() throws Exception { - try { - yarnCluster = new MiniYARNCluster(TestContainerManagerSecurity.class - .getName(), 1, 1, 1); - yarnCluster.init(conf); - yarnCluster.start(); // TestNMTokens. testNMTokens(conf); @@ -156,36 +159,11 @@ public void testContainerManager() throws Exception { // Testing for container token tampering testContainerToken(conf); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } finally { - if (yarnCluster != null) { - yarnCluster.stop(); - yarnCluster = null; - } - } - } - - @Test (timeout = 120000) - public void testContainerManagerWithEpoch() throws Exception { - try { - yarnCluster = new MiniYARNCluster(TestContainerManagerSecurity.class - .getName(), 1, 1, 1); - yarnCluster.init(conf); - yarnCluster.start(); - - // Testing for container token tampering + // Testing for container manager with epoch testContainerTokenWithEpoch(conf); - } finally { - if (yarnCluster != null) { - yarnCluster.stop(); - yarnCluster = null; - } - } } - + private void testNMTokens(Configuration conf) throws Exception { NMTokenSecretManagerInRM nmTokenSecretManagerRM = yarnCluster.getResourceManager().getRMContext()