HDFS-3897. QJM: TestBlockToken fails after HDFS-3893. Contributed by Aaron T. Myers.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-3077@1381842 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
df801074c9
commit
16234cbd5f
|
@ -50,3 +50,5 @@ HDFS-3891. Make selectInputStreams throw IOE instead of RTE (todd)
|
||||||
HDFS-3726. If a logger misses an RPC, don't retry that logger until next segment (todd)
|
HDFS-3726. If a logger misses an RPC, don't retry that logger until next segment (todd)
|
||||||
|
|
||||||
HDFS-3893. QJM: Make QJM work with security enabled. (atm)
|
HDFS-3893. QJM: Make QJM work with security enabled. (atm)
|
||||||
|
|
||||||
|
HDFS-3897. QJM: TestBlockToken fails after HDFS-3893. (atm)
|
||||||
|
|
|
@ -74,6 +74,7 @@ import org.apache.hadoop.util.Time;
|
||||||
import org.apache.log4j.Level;
|
import org.apache.log4j.Level;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Assume;
|
import org.junit.Assume;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
|
@ -87,14 +88,6 @@ public class TestBlockToken {
|
||||||
public static final Log LOG = LogFactory.getLog(TestBlockToken.class);
|
public static final Log LOG = LogFactory.getLog(TestBlockToken.class);
|
||||||
private static final String ADDRESS = "0.0.0.0";
|
private static final String ADDRESS = "0.0.0.0";
|
||||||
|
|
||||||
static final String SERVER_PRINCIPAL_KEY = "test.ipc.server.principal";
|
|
||||||
private static Configuration conf;
|
|
||||||
static {
|
|
||||||
conf = new Configuration();
|
|
||||||
conf.set(HADOOP_SECURITY_AUTHENTICATION, "kerberos");
|
|
||||||
UserGroupInformation.setConfiguration(conf);
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
((Log4JLogger) Client.LOG).getLogger().setLevel(Level.ALL);
|
((Log4JLogger) Client.LOG).getLogger().setLevel(Level.ALL);
|
||||||
((Log4JLogger) Server.LOG).getLogger().setLevel(Level.ALL);
|
((Log4JLogger) Server.LOG).getLogger().setLevel(Level.ALL);
|
||||||
|
@ -111,6 +104,13 @@ public class TestBlockToken {
|
||||||
ExtendedBlock block1 = new ExtendedBlock("0", 0L);
|
ExtendedBlock block1 = new ExtendedBlock("0", 0L);
|
||||||
ExtendedBlock block2 = new ExtendedBlock("10", 10L);
|
ExtendedBlock block2 = new ExtendedBlock("10", 10L);
|
||||||
ExtendedBlock block3 = new ExtendedBlock("-10", -108L);
|
ExtendedBlock block3 = new ExtendedBlock("-10", -108L);
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void disableKerberos() {
|
||||||
|
Configuration conf = new Configuration();
|
||||||
|
conf.set(HADOOP_SECURITY_AUTHENTICATION, "simple");
|
||||||
|
UserGroupInformation.setConfiguration(conf);
|
||||||
|
}
|
||||||
|
|
||||||
private static class GetLengthAnswer implements
|
private static class GetLengthAnswer implements
|
||||||
Answer<GetReplicaVisibleLengthResponseProto> {
|
Answer<GetReplicaVisibleLengthResponseProto> {
|
||||||
|
@ -215,8 +215,9 @@ public class TestBlockToken {
|
||||||
tokenGenerationAndVerification(masterHandler, slaveHandler);
|
tokenGenerationAndVerification(masterHandler, slaveHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Server createMockDatanode(BlockTokenSecretManager sm,
|
private static Server createMockDatanode(BlockTokenSecretManager sm,
|
||||||
Token<BlockTokenIdentifier> token) throws IOException, ServiceException {
|
Token<BlockTokenIdentifier> token, Configuration conf)
|
||||||
|
throws IOException, ServiceException {
|
||||||
ClientDatanodeProtocolPB mockDN = mock(ClientDatanodeProtocolPB.class);
|
ClientDatanodeProtocolPB mockDN = mock(ClientDatanodeProtocolPB.class);
|
||||||
|
|
||||||
BlockTokenIdentifier id = sm.createIdentifier();
|
BlockTokenIdentifier id = sm.createIdentifier();
|
||||||
|
@ -238,12 +239,16 @@ public class TestBlockToken {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBlockTokenRpc() throws Exception {
|
public void testBlockTokenRpc() throws Exception {
|
||||||
|
Configuration conf = new Configuration();
|
||||||
|
conf.set(HADOOP_SECURITY_AUTHENTICATION, "kerberos");
|
||||||
|
UserGroupInformation.setConfiguration(conf);
|
||||||
|
|
||||||
BlockTokenSecretManager sm = new BlockTokenSecretManager(
|
BlockTokenSecretManager sm = new BlockTokenSecretManager(
|
||||||
blockKeyUpdateInterval, blockTokenLifetime, 0, "fake-pool", null);
|
blockKeyUpdateInterval, blockTokenLifetime, 0, "fake-pool", null);
|
||||||
Token<BlockTokenIdentifier> token = sm.generateToken(block3,
|
Token<BlockTokenIdentifier> token = sm.generateToken(block3,
|
||||||
EnumSet.allOf(BlockTokenSecretManager.AccessMode.class));
|
EnumSet.allOf(BlockTokenSecretManager.AccessMode.class));
|
||||||
|
|
||||||
final Server server = createMockDatanode(sm, token);
|
final Server server = createMockDatanode(sm, token, conf);
|
||||||
|
|
||||||
server.start();
|
server.start();
|
||||||
|
|
||||||
|
@ -272,13 +277,17 @@ public class TestBlockToken {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testBlockTokenRpcLeak() throws Exception {
|
public void testBlockTokenRpcLeak() throws Exception {
|
||||||
|
Configuration conf = new Configuration();
|
||||||
|
conf.set(HADOOP_SECURITY_AUTHENTICATION, "kerberos");
|
||||||
|
UserGroupInformation.setConfiguration(conf);
|
||||||
|
|
||||||
Assume.assumeTrue(FD_DIR.exists());
|
Assume.assumeTrue(FD_DIR.exists());
|
||||||
BlockTokenSecretManager sm = new BlockTokenSecretManager(
|
BlockTokenSecretManager sm = new BlockTokenSecretManager(
|
||||||
blockKeyUpdateInterval, blockTokenLifetime, 0, "fake-pool", null);
|
blockKeyUpdateInterval, blockTokenLifetime, 0, "fake-pool", null);
|
||||||
Token<BlockTokenIdentifier> token = sm.generateToken(block3,
|
Token<BlockTokenIdentifier> token = sm.generateToken(block3,
|
||||||
EnumSet.allOf(BlockTokenSecretManager.AccessMode.class));
|
EnumSet.allOf(BlockTokenSecretManager.AccessMode.class));
|
||||||
|
|
||||||
final Server server = createMockDatanode(sm, token);
|
final Server server = createMockDatanode(sm, token, conf);
|
||||||
server.start();
|
server.start();
|
||||||
|
|
||||||
final InetSocketAddress addr = NetUtils.getConnectAddress(server);
|
final InetSocketAddress addr = NetUtils.getConnectAddress(server);
|
||||||
|
|
Loading…
Reference in New Issue