From ce73b3b01f31de4daed79340edb9777a5b9dc242 Mon Sep 17 00:00:00 2001 From: Aaron Myers Date: Mon, 29 Apr 2013 21:10:50 +0000 Subject: [PATCH] HDFS-4687. TestDelegationTokenForProxyUser#testWebHdfsDoAs is flaky with JDK7. Contributed by Andrew Wang. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1477344 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 ++ .../TestDelegationTokenForProxyUser.java | 32 +++++++++---------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 46cad99be1..97f1dcd6f8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -268,6 +268,9 @@ Trunk (Unreleased) HDFS-4761. When resetting FSDirectory, the inodeMap should also be reset. (Jing Zhao via szetszwo) + HDFS-4687. TestDelegationTokenForProxyUser#testWebHdfsDoAs is flaky with + JDK7. (Andrew Wang via atm) + BREAKDOWN OF HADOOP-8562 and HDFS-3602 SUBTASKS AND RELATED JIRAS HDFS-4145. Merge hdfs cmd line scripts from branch-1-win. (David Lao, diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/TestDelegationTokenForProxyUser.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/TestDelegationTokenForProxyUser.java index b1e694cd1f..b13c81a156 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/TestDelegationTokenForProxyUser.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/TestDelegationTokenForProxyUser.java @@ -60,24 +60,26 @@ import org.apache.hadoop.security.authorize.ProxyUsers; import org.apache.hadoop.security.token.Token; import org.apache.log4j.Level; -import org.junit.After; +import org.junit.AfterClass; import org.junit.Assert; -import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; public class TestDelegationTokenForProxyUser { - private MiniDFSCluster cluster; - Configuration config; + private static MiniDFSCluster cluster; + private static Configuration config; final private static String GROUP1_NAME = "group1"; final private static String GROUP2_NAME = "group2"; final private static String[] GROUP_NAMES = new String[] { GROUP1_NAME, GROUP2_NAME }; final private static String REAL_USER = "RealUser"; final private static String PROXY_USER = "ProxyUser"; + private static UserGroupInformation ugi; + private static UserGroupInformation proxyUgi; private static final Log LOG = LogFactory.getLog(TestDoAsEffectiveUser.class); - private void configureSuperUserIPAddresses(Configuration conf, + private static void configureSuperUserIPAddresses(Configuration conf, String superUserShortName) throws IOException { ArrayList ipList = new ArrayList(); Enumeration netInterfaceList = NetworkInterface @@ -102,8 +104,8 @@ private void configureSuperUserIPAddresses(Configuration conf, builder.toString()); } - @Before - public void setUp() throws Exception { + @BeforeClass + public static void setUp() throws Exception { config = new HdfsConfiguration(); config.setBoolean(DFSConfigKeys.DFS_WEBHDFS_ENABLED_KEY, true); config.setLong( @@ -119,21 +121,20 @@ public void setUp() throws Exception { cluster = new MiniDFSCluster.Builder(config).build(); cluster.waitActive(); ProxyUsers.refreshSuperUserGroupsConfiguration(config); + ugi = UserGroupInformation.createRemoteUser(REAL_USER); + proxyUgi = UserGroupInformation.createProxyUserForTesting(PROXY_USER, ugi, + GROUP_NAMES); } - @After - public void tearDown() throws Exception { + @AfterClass + public static void tearDown() throws Exception { if(cluster!=null) { cluster.shutdown(); } } - @Test + @Test(timeout=20000) public void testDelegationTokenWithRealUser() throws IOException { - UserGroupInformation ugi = UserGroupInformation - .createRemoteUser(REAL_USER); - final UserGroupInformation proxyUgi = UserGroupInformation - .createProxyUserForTesting(PROXY_USER, ugi, GROUP_NAMES); try { Token[] tokens = proxyUgi .doAs(new PrivilegedExceptionAction[]>() { @@ -154,12 +155,11 @@ public Token[] run() throws IOException { } } - @Test + @Test(timeout=20000) public void testWebHdfsDoAs() throws Exception { WebHdfsTestUtil.LOG.info("START: testWebHdfsDoAs()"); ((Log4JLogger)NamenodeWebHdfsMethods.LOG).getLogger().setLevel(Level.ALL); ((Log4JLogger)ExceptionHandler.LOG).getLogger().setLevel(Level.ALL); - final UserGroupInformation ugi = UserGroupInformation.createRemoteUser(REAL_USER); WebHdfsTestUtil.LOG.info("ugi.getShortUserName()=" + ugi.getShortUserName()); final WebHdfsFileSystem webhdfs = WebHdfsTestUtil.getWebHdfsFileSystemAs(ugi, config);