YARN-2319. Made the MiniKdc instance start/close before/after the class of TestRMWebServicesDelegationTokens. Contributed by Wenwu Peng.

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


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2.5@1612592 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhijie Shen 2014-07-22 15:18:50 +00:00
parent 24f813aa20
commit f08f5d1086
2 changed files with 21 additions and 27 deletions

View File

@ -331,6 +331,9 @@ Release 2.5.0 - UNRELEASED
YARN-2270. Made TestFSDownload#testDownloadPublicWithStatCache be skipped YARN-2270. Made TestFSDownload#testDownloadPublicWithStatCache be skipped
when theres no ancestor permissions. (Akira Ajisaka via zjshen) when theres no ancestor permissions. (Akira Ajisaka via zjshen)
YARN-2319. Made the MiniKdc instance start/close before/after the class of
TestRMWebServicesDelegationTokens. (Wenwu Peng via zjshen)
Release 2.4.1 - 2014-06-23 Release 2.4.1 - 2014-06-23
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -60,7 +60,9 @@
import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject; import org.codehaus.jettison.json.JSONObject;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; import org.junit.runners.Parameterized;
@ -90,28 +92,14 @@
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class TestRMWebServicesDelegationTokens extends JerseyTest { public class TestRMWebServicesDelegationTokens extends JerseyTest {
private static final File testRootDir = new File("target", private static File testRootDir;
TestRMWebServicesDelegationTokens.class.getName() + "-root");
private static File httpSpnegoKeytabFile = new File( private static File httpSpnegoKeytabFile = new File(
KerberosTestUtils.getKeytabFile()); KerberosTestUtils.getKeytabFile());
private static String httpSpnegoPrincipal = KerberosTestUtils private static String httpSpnegoPrincipal = KerberosTestUtils
.getServerPrincipal(); .getServerPrincipal();
private static boolean miniKDCStarted = false;
private static MiniKdc testMiniKDC; private static MiniKdc testMiniKDC;
static {
try {
testMiniKDC = new MiniKdc(MiniKdc.createConf(), testRootDir);
} catch (Exception e) {
assertTrue("Couldn't create MiniKDC", false);
}
}
private static MockRM rm; private static MockRM rm;
private Injector injector; private Injector injector;
private boolean isKerberosAuth = false; private boolean isKerberosAuth = false;
// Make sure the test uses the published header string // Make sure the test uses the published header string
@ -237,7 +225,6 @@ public TestRMWebServicesDelegationTokens(int run) throws Exception {
.contextListenerClass(GuiceServletConfig.class) .contextListenerClass(GuiceServletConfig.class)
.filterClass(com.google.inject.servlet.GuiceFilter.class) .filterClass(com.google.inject.servlet.GuiceFilter.class)
.contextPath("jersey-guice-filter").servletPath("/").build()); .contextPath("jersey-guice-filter").servletPath("/").build());
setupKDC();
switch (run) { switch (run) {
case 0: case 0:
default: default:
@ -249,17 +236,14 @@ public TestRMWebServicesDelegationTokens(int run) throws Exception {
} }
} }
private void setupKDC() throws Exception { @BeforeClass
if (miniKDCStarted == false) { public static void setupKDC() throws Exception {
testMiniKDC.start(); testRootDir = new File("target",
getKdc().createPrincipal(httpSpnegoKeytabFile, "HTTP/localhost", TestRMWebServicesDelegationTokens.class.getName() + "-root");
"client", "client2", "client3"); testMiniKDC = new MiniKdc(MiniKdc.createConf(), testRootDir);
miniKDCStarted = true; testMiniKDC.start();
} testMiniKDC.createPrincipal(httpSpnegoKeytabFile, "HTTP/localhost",
} "client", "client2", "client3");
private MiniKdc getKdc() {
return testMiniKDC;
} }
@Before @Before
@ -270,6 +254,13 @@ public void setUp() throws Exception {
testRootDir.deleteOnExit(); testRootDir.deleteOnExit();
} }
@AfterClass
public static void shutdownKdc() {
if (testMiniKDC != null) {
testMiniKDC.stop();
}
}
@After @After
@Override @Override
public void tearDown() throws Exception { public void tearDown() throws Exception {