YARN-9461. TestRMWebServicesDelegationTokenAuthentication.testCancelledDelegationToken fails with HTTP 400. Contributed by Peter Bacsko

This commit is contained in:
Szilard Nemeth 2019-08-16 12:31:58 +02:00
parent 4456ea67b9
commit 9b8359bb08
1 changed files with 17 additions and 6 deletions

View File

@ -59,8 +59,10 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler;
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo;
import org.codehaus.jettison.json.JSONObject; import org.codehaus.jettison.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -84,8 +86,8 @@ public class TestRMWebServicesDelegationTokenAuthentication {
private static boolean miniKDCStarted = false; private static boolean miniKDCStarted = false;
private static MiniKdc testMiniKDC; private static MiniKdc testMiniKDC;
private static MockRM rm;
private static String sunSecurityKrb5RcacheValue; private static String sunSecurityKrb5RcacheValue;
private MockRM rm;
String delegationTokenHeader; String delegationTokenHeader;
@ -107,7 +109,7 @@ public class TestRMWebServicesDelegationTokenAuthentication {
System.setProperty(SUN_SECURITY_KRB5_RCACHE_KEY, "none"); System.setProperty(SUN_SECURITY_KRB5_RCACHE_KEY, "none");
testMiniKDC = new MiniKdc(MiniKdc.createConf(), testRootDir); testMiniKDC = new MiniKdc(MiniKdc.createConf(), testRootDir);
setupKDC(); setupKDC();
setupAndStartRM();
} catch (Exception e) { } catch (Exception e) {
assertTrue("Couldn't create MiniKDC", false); assertTrue("Couldn't create MiniKDC", false);
} }
@ -118,9 +120,6 @@ public class TestRMWebServicesDelegationTokenAuthentication {
if (testMiniKDC != null) { if (testMiniKDC != null) {
testMiniKDC.stop(); testMiniKDC.stop();
} }
if (rm != null) {
rm.stop();
}
if (sunSecurityKrb5RcacheValue == null) { if (sunSecurityKrb5RcacheValue == null) {
System.clearProperty(SUN_SECURITY_KRB5_RCACHE_KEY); System.clearProperty(SUN_SECURITY_KRB5_RCACHE_KEY);
} else { } else {
@ -129,6 +128,18 @@ public class TestRMWebServicesDelegationTokenAuthentication {
} }
} }
@Before
public void before() throws Exception {
setupAndStartRM();
}
@After
public void after() {
if (rm != null) {
rm.stop();
}
}
@Parameterized.Parameters @Parameterized.Parameters
public static Collection<Object[]> headers() { public static Collection<Object[]> headers() {
return Arrays.asList(new Object[][] { {OldDelegationTokenHeader}, {NewDelegationTokenHeader}}); return Arrays.asList(new Object[][] { {OldDelegationTokenHeader}, {NewDelegationTokenHeader}});
@ -139,7 +150,7 @@ public class TestRMWebServicesDelegationTokenAuthentication {
this.delegationTokenHeader = header; this.delegationTokenHeader = header;
} }
private static void setupAndStartRM() throws Exception { private void setupAndStartRM() throws Exception {
Configuration rmconf = new Configuration(); Configuration rmconf = new Configuration();
rmconf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, rmconf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS,
YarnConfiguration.DEFAULT_RM_AM_MAX_ATTEMPTS); YarnConfiguration.DEFAULT_RM_AM_MAX_ATTEMPTS);