|
@@ -110,7 +110,8 @@ import com.google.common.base.Supplier;
|
|
|
public class TestDelegationTokenRenewer {
|
|
|
private static final Log LOG =
|
|
|
LogFactory.getLog(TestDelegationTokenRenewer.class);
|
|
|
- private static final Text KIND = new Text("HDFS_DELEGATION_TOKEN");
|
|
|
+ private static final Text KIND =
|
|
|
+ DelegationTokenRenewer.HDFS_DELEGATION_KIND;
|
|
|
|
|
|
private static BlockingQueue<Event> eventQueue;
|
|
|
private static volatile AtomicInteger counter;
|
|
@@ -480,7 +481,26 @@ public class TestDelegationTokenRenewer {
|
|
|
}
|
|
|
fail("App submission with a cancelled token should have failed");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ // Testcase for YARN-3021, let RM skip renewing token if the renewer string
|
|
|
+ // is empty
|
|
|
+ @Test(timeout=60000)
|
|
|
+ public void testAppTokenWithNonRenewer() throws Exception {
|
|
|
+ MyFS dfs = (MyFS)FileSystem.get(conf);
|
|
|
+ LOG.info("dfs="+(Object)dfs.hashCode() + ";conf="+conf.hashCode());
|
|
|
+
|
|
|
+ // Test would fail if using non-empty renewer string here
|
|
|
+ MyToken token = dfs.getDelegationToken("");
|
|
|
+ token.cancelToken();
|
|
|
+
|
|
|
+ Credentials ts = new Credentials();
|
|
|
+ ts.addToken(token.getKind(), token);
|
|
|
+
|
|
|
+ // register the tokens for renewal
|
|
|
+ ApplicationId appId = BuilderUtils.newApplicationId(0, 0);
|
|
|
+ delegationTokenRenewer.addApplicationSync(appId, ts, true, "user");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Basic idea of the test:
|
|
|
* 1. register a token for 2 seconds with no cancel at the end
|
|
@@ -721,7 +741,7 @@ public class TestDelegationTokenRenewer {
|
|
|
throws IOException, InterruptedException, BrokenBarrierException {
|
|
|
final Credentials credsx = new Credentials();
|
|
|
final Token<DelegationTokenIdentifier> tokenx = mock(Token.class);
|
|
|
- when(tokenx.getKind()).thenReturn(new Text("HDFS_DELEGATION_TOKEN"));
|
|
|
+ when(tokenx.getKind()).thenReturn(KIND);
|
|
|
DelegationTokenIdentifier dtId1 =
|
|
|
new DelegationTokenIdentifier(new Text("user1"), new Text("renewer"),
|
|
|
new Text("user1"));
|
|
@@ -765,7 +785,7 @@ public class TestDelegationTokenRenewer {
|
|
|
// this token uses barriers to block during renew
|
|
|
final Credentials creds1 = new Credentials();
|
|
|
final Token<DelegationTokenIdentifier> token1 = mock(Token.class);
|
|
|
- when(token1.getKind()).thenReturn(new Text("HDFS_DELEGATION_TOKEN"));
|
|
|
+ when(token1.getKind()).thenReturn(KIND);
|
|
|
DelegationTokenIdentifier dtId1 =
|
|
|
new DelegationTokenIdentifier(new Text("user1"), new Text("renewer"),
|
|
|
new Text("user1"));
|
|
@@ -783,7 +803,7 @@ public class TestDelegationTokenRenewer {
|
|
|
// this dummy token fakes renewing
|
|
|
final Credentials creds2 = new Credentials();
|
|
|
final Token<DelegationTokenIdentifier> token2 = mock(Token.class);
|
|
|
- when(token2.getKind()).thenReturn(new Text("HDFS_DELEGATION_TOKEN"));
|
|
|
+ when(token2.getKind()).thenReturn(KIND);
|
|
|
when(token2.decodeIdentifier()).thenReturn(dtId1);
|
|
|
creds2.addToken(new Text("token"), token2);
|
|
|
doReturn(true).when(token2).isManaged();
|