From 16234cbd5f93946bb76f8457407575ed35d7fc0a Mon Sep 17 00:00:00 2001 From: Aaron Myers Date: Fri, 7 Sep 2012 02:01:21 +0000 Subject: [PATCH] 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 --- .../hadoop-hdfs/CHANGES.HDFS-3077.txt | 2 ++ .../security/token/block/TestBlockToken.java | 33 ++++++++++++------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-3077.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-3077.txt index e54e97a592..6702723bd0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-3077.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-3077.txt @@ -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-3893. QJM: Make QJM work with security enabled. (atm) + +HDFS-3897. QJM: TestBlockToken fails after HDFS-3893. (atm) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/token/block/TestBlockToken.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/token/block/TestBlockToken.java index f32b70dc3d..6a9a071b43 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/token/block/TestBlockToken.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/token/block/TestBlockToken.java @@ -74,6 +74,7 @@ import org.apache.log4j.Level; import org.junit.Assert; import org.junit.Assume; +import org.junit.Before; import org.junit.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -87,14 +88,6 @@ public class TestBlockToken { public static final Log LOG = LogFactory.getLog(TestBlockToken.class); 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 { ((Log4JLogger) Client.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 block2 = new ExtendedBlock("10", 10L); 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 Answer { @@ -215,8 +215,9 @@ public void testBlockTokenSecretManager() throws Exception { tokenGenerationAndVerification(masterHandler, slaveHandler); } - private Server createMockDatanode(BlockTokenSecretManager sm, - Token token) throws IOException, ServiceException { + private static Server createMockDatanode(BlockTokenSecretManager sm, + Token token, Configuration conf) + throws IOException, ServiceException { ClientDatanodeProtocolPB mockDN = mock(ClientDatanodeProtocolPB.class); BlockTokenIdentifier id = sm.createIdentifier(); @@ -238,12 +239,16 @@ private Server createMockDatanode(BlockTokenSecretManager sm, @Test public void testBlockTokenRpc() throws Exception { + Configuration conf = new Configuration(); + conf.set(HADOOP_SECURITY_AUTHENTICATION, "kerberos"); + UserGroupInformation.setConfiguration(conf); + BlockTokenSecretManager sm = new BlockTokenSecretManager( blockKeyUpdateInterval, blockTokenLifetime, 0, "fake-pool", null); Token token = sm.generateToken(block3, EnumSet.allOf(BlockTokenSecretManager.AccessMode.class)); - final Server server = createMockDatanode(sm, token); + final Server server = createMockDatanode(sm, token, conf); server.start(); @@ -272,13 +277,17 @@ public void testBlockTokenRpc() throws Exception { */ @Test public void testBlockTokenRpcLeak() throws Exception { + Configuration conf = new Configuration(); + conf.set(HADOOP_SECURITY_AUTHENTICATION, "kerberos"); + UserGroupInformation.setConfiguration(conf); + Assume.assumeTrue(FD_DIR.exists()); BlockTokenSecretManager sm = new BlockTokenSecretManager( blockKeyUpdateInterval, blockTokenLifetime, 0, "fake-pool", null); Token token = sm.generateToken(block3, EnumSet.allOf(BlockTokenSecretManager.AccessMode.class)); - final Server server = createMockDatanode(sm, token); + final Server server = createMockDatanode(sm, token, conf); server.start(); final InetSocketAddress addr = NetUtils.getConnectAddress(server);