Skip to content

Commit b4f3d58

Browse files
committed
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
1 parent 69ddccd commit b4f3d58

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ Trunk (Unreleased)
268268
HDFS-4761. When resetting FSDirectory, the inodeMap should also be reset.
269269
(Jing Zhao via szetszwo)
270270

271+
HDFS-4687. TestDelegationTokenForProxyUser#testWebHdfsDoAs is flaky with
272+
JDK7. (Andrew Wang via atm)
273+
271274
BREAKDOWN OF HADOOP-8562 and HDFS-3602 SUBTASKS AND RELATED JIRAS
272275

273276
HDFS-4145. Merge hdfs cmd line scripts from branch-1-win. (David Lao,

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/security/TestDelegationTokenForProxyUser.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,26 @@
6060
import org.apache.hadoop.security.authorize.ProxyUsers;
6161
import org.apache.hadoop.security.token.Token;
6262
import org.apache.log4j.Level;
63-
import org.junit.After;
63+
import org.junit.AfterClass;
6464
import org.junit.Assert;
65-
import org.junit.Before;
65+
import org.junit.BeforeClass;
6666
import org.junit.Test;
6767

6868
public class TestDelegationTokenForProxyUser {
69-
private MiniDFSCluster cluster;
70-
Configuration config;
69+
private static MiniDFSCluster cluster;
70+
private static Configuration config;
7171
final private static String GROUP1_NAME = "group1";
7272
final private static String GROUP2_NAME = "group2";
7373
final private static String[] GROUP_NAMES = new String[] { GROUP1_NAME,
7474
GROUP2_NAME };
7575
final private static String REAL_USER = "RealUser";
7676
final private static String PROXY_USER = "ProxyUser";
77+
private static UserGroupInformation ugi;
78+
private static UserGroupInformation proxyUgi;
7779

7880
private static final Log LOG = LogFactory.getLog(TestDoAsEffectiveUser.class);
7981

80-
private void configureSuperUserIPAddresses(Configuration conf,
82+
private static void configureSuperUserIPAddresses(Configuration conf,
8183
String superUserShortName) throws IOException {
8284
ArrayList<String> ipList = new ArrayList<String>();
8385
Enumeration<NetworkInterface> netInterfaceList = NetworkInterface
@@ -102,8 +104,8 @@ private void configureSuperUserIPAddresses(Configuration conf,
102104
builder.toString());
103105
}
104106

105-
@Before
106-
public void setUp() throws Exception {
107+
@BeforeClass
108+
public static void setUp() throws Exception {
107109
config = new HdfsConfiguration();
108110
config.setBoolean(DFSConfigKeys.DFS_WEBHDFS_ENABLED_KEY, true);
109111
config.setLong(
@@ -119,21 +121,20 @@ public void setUp() throws Exception {
119121
cluster = new MiniDFSCluster.Builder(config).build();
120122
cluster.waitActive();
121123
ProxyUsers.refreshSuperUserGroupsConfiguration(config);
124+
ugi = UserGroupInformation.createRemoteUser(REAL_USER);
125+
proxyUgi = UserGroupInformation.createProxyUserForTesting(PROXY_USER, ugi,
126+
GROUP_NAMES);
122127
}
123128

124-
@After
125-
public void tearDown() throws Exception {
129+
@AfterClass
130+
public static void tearDown() throws Exception {
126131
if(cluster!=null) {
127132
cluster.shutdown();
128133
}
129134
}
130135

131-
@Test
136+
@Test(timeout=20000)
132137
public void testDelegationTokenWithRealUser() throws IOException {
133-
UserGroupInformation ugi = UserGroupInformation
134-
.createRemoteUser(REAL_USER);
135-
final UserGroupInformation proxyUgi = UserGroupInformation
136-
.createProxyUserForTesting(PROXY_USER, ugi, GROUP_NAMES);
137138
try {
138139
Token<?>[] tokens = proxyUgi
139140
.doAs(new PrivilegedExceptionAction<Token<?>[]>() {
@@ -154,12 +155,11 @@ public Token<?>[] run() throws IOException {
154155
}
155156
}
156157

157-
@Test
158+
@Test(timeout=20000)
158159
public void testWebHdfsDoAs() throws Exception {
159160
WebHdfsTestUtil.LOG.info("START: testWebHdfsDoAs()");
160161
((Log4JLogger)NamenodeWebHdfsMethods.LOG).getLogger().setLevel(Level.ALL);
161162
((Log4JLogger)ExceptionHandler.LOG).getLogger().setLevel(Level.ALL);
162-
final UserGroupInformation ugi = UserGroupInformation.createRemoteUser(REAL_USER);
163163
WebHdfsTestUtil.LOG.info("ugi.getShortUserName()=" + ugi.getShortUserName());
164164
final WebHdfsFileSystem webhdfs = WebHdfsTestUtil.getWebHdfsFileSystemAs(ugi, config);
165165

0 commit comments

Comments
 (0)