HDFS-3831. Failure to renew tokens due to test-sources left in classpath (jlowe via bobby)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1391121 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a33ae4020d
commit
01c0dc98bb
@ -1645,6 +1645,9 @@ Release 0.23.4 - UNRELEASED
|
|||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
||||||
|
HDFS-3831. Failure to renew tokens due to test-sources left in classpath
|
||||||
|
(jlowe via bobby)
|
||||||
|
|
||||||
Release 0.23.3 - UNRELEASED
|
Release 0.23.3 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
package org.apache.hadoop.tools;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.io.Text;
|
||||||
|
import org.apache.hadoop.security.token.Token;
|
||||||
|
import org.apache.hadoop.security.token.TokenRenewer;
|
||||||
|
|
||||||
|
public class FakeRenewer extends TokenRenewer {
|
||||||
|
static Token<?> lastRenewed = null;
|
||||||
|
static Token<?> lastCanceled = null;
|
||||||
|
static final Text KIND = new Text("TESTING-TOKEN-KIND");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handleKind(Text kind) {
|
||||||
|
return FakeRenewer.KIND.equals(kind);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isManaged(Token<?> token) throws IOException {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long renew(Token<?> token, Configuration conf) {
|
||||||
|
lastRenewed = token;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancel(Token<?> token, Configuration conf) {
|
||||||
|
lastCanceled = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void reset() {
|
||||||
|
lastRenewed = null;
|
||||||
|
lastCanceled = null;
|
||||||
|
}
|
||||||
|
}
|
@ -36,9 +36,7 @@
|
|||||||
import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher;
|
import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher;
|
||||||
import org.apache.hadoop.io.Text;
|
import org.apache.hadoop.io.Text;
|
||||||
import org.apache.hadoop.security.Credentials;
|
import org.apache.hadoop.security.Credentials;
|
||||||
import org.apache.hadoop.security.UserGroupInformation;
|
|
||||||
import org.apache.hadoop.security.token.Token;
|
import org.apache.hadoop.security.token.Token;
|
||||||
import org.apache.hadoop.security.token.TokenRenewer;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
@ -50,7 +48,6 @@ public class TestDelegationTokenFetcher {
|
|||||||
private Configuration conf;
|
private Configuration conf;
|
||||||
private URI uri;
|
private URI uri;
|
||||||
private static final String SERVICE_VALUE = "localhost:2005";
|
private static final String SERVICE_VALUE = "localhost:2005";
|
||||||
private static final Text KIND = new Text("TESTING-TOKEN-KIND");
|
|
||||||
private static String tokenFile = "file.dta";
|
private static String tokenFile = "file.dta";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@ -61,37 +58,6 @@ public void init() throws URISyntaxException, IOException {
|
|||||||
FileSystemTestHelper.addFileSystemForTesting(uri, conf, dfs);
|
FileSystemTestHelper.addFileSystemForTesting(uri, conf, dfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class FakeRenewer extends TokenRenewer {
|
|
||||||
static Token<?> lastRenewed = null;
|
|
||||||
static Token<?> lastCanceled = null;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handleKind(Text kind) {
|
|
||||||
return KIND.equals(kind);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isManaged(Token<?> token) throws IOException {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long renew(Token<?> token, Configuration conf) {
|
|
||||||
lastRenewed = token;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cancel(Token<?> token, Configuration conf) {
|
|
||||||
lastCanceled = token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void reset() {
|
|
||||||
lastRenewed = null;
|
|
||||||
lastCanceled = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify that when the DelegationTokenFetcher runs, it talks to the Namenode,
|
* Verify that when the DelegationTokenFetcher runs, it talks to the Namenode,
|
||||||
* pulls out the correct user's token and successfully serializes it to disk.
|
* pulls out the correct user's token and successfully serializes it to disk.
|
||||||
@ -103,13 +69,11 @@ public void expectedTokenIsRetrievedFromDFS() throws Exception {
|
|||||||
new Text("renewer"), new Text("realuser")).getBytes();
|
new Text("renewer"), new Text("realuser")).getBytes();
|
||||||
final byte[] pw = new byte[] { 42 };
|
final byte[] pw = new byte[] { 42 };
|
||||||
final Text service = new Text(uri.toString());
|
final Text service = new Text(uri.toString());
|
||||||
final String user =
|
|
||||||
UserGroupInformation.getCurrentUser().getShortUserName();
|
|
||||||
|
|
||||||
// Create a token for the fetcher to fetch, wire NN to return it when asked
|
// Create a token for the fetcher to fetch, wire NN to return it when asked
|
||||||
// for this particular user.
|
// for this particular user.
|
||||||
final Token<DelegationTokenIdentifier> t =
|
final Token<DelegationTokenIdentifier> t =
|
||||||
new Token<DelegationTokenIdentifier>(ident, pw, KIND, service);
|
new Token<DelegationTokenIdentifier>(ident, pw, FakeRenewer.KIND, service);
|
||||||
when(dfs.addDelegationTokens(eq((String) null), any(Credentials.class))).thenAnswer(
|
when(dfs.addDelegationTokens(eq((String) null), any(Credentials.class))).thenAnswer(
|
||||||
new Answer<Token<?>[]>() {
|
new Answer<Token<?>[]>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1 +1 @@
|
|||||||
org.apache.hadoop.tools.TestDelegationTokenFetcher$FakeRenewer
|
org.apache.hadoop.tools.FakeRenewer
|
||||||
|
Loading…
Reference in New Issue
Block a user