You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mapreduce-commits@hadoop.apache.org by vi...@apache.org on 2011/11/04 08:48:26 UTC
svn commit: r1197415 - in /hadoop/common/trunk/hadoop-mapreduce-project:
CHANGES.txt
src/test/mapred/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java
Author: vinodkv
Date: Fri Nov 4 07:48:26 2011
New Revision: 1197415
URL: http://svn.apache.org/viewvc?rev=1197415&view=rev
Log:
MAPREDUCE-3219. Reenabled and fixed bugs in the failing test TestDelegationToken. Contributed by Hitesh Shah.
Modified:
hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt
hadoop/common/trunk/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java
Modified: hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt?rev=1197415&r1=1197414&r2=1197415&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt Fri Nov 4 07:48:26 2011
@@ -66,12 +66,15 @@ Release 0.23.1 - Unreleased
BUG FIXES
- MAPREDUCE-3221. Reneabled the previously ignored test in TestSubmitJob
+ MAPREDUCE-3221. Reenabled the previously ignored test in TestSubmitJob
and fixed bugs in it. (Devaraj K via vinodkv)
- MAPREDUCE-3215. Reneabled and fixed bugs in the failing test
+ MAPREDUCE-3215. Reenabled and fixed bugs in the failing test
TestNoJobSetupCleanup. (Hitesh Shah via vinodkv)
+ MAPREDUCE-3219. Reenabled and fixed bugs in the failing test
+ TestDelegationToken. (Hitesh Shah via vinodkv)
+
Release 0.23.0 - 2011-11-01
INCOMPATIBLE CHANGES
Modified: hadoop/common/trunk/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java?rev=1197415&r1=1197414&r2=1197415&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java (original)
+++ hadoop/common/trunk/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java Fri Nov 4 07:48:26 2011
@@ -29,7 +29,6 @@ import org.apache.hadoop.security.token.
import org.apache.hadoop.security.token.SecretManager.InvalidToken;
import org.junit.Assert;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -48,26 +47,27 @@ public class TestDelegationToken {
cluster = new MiniMRCluster(0,0,1,"file:///",1);
}
+ @SuppressWarnings("deprecation")
@Test
- @Ignore
public void testDelegationToken() throws Exception {
- JobClient client;
+ final JobClient client;
client = user1.doAs(new PrivilegedExceptionAction<JobClient>(){
-
@Override
public JobClient run() throws Exception {
return new JobClient(cluster.createJobConf());
- }});
- JobClient bobClient;
+ }
+ });
+
+ final JobClient bobClient;
bobClient = user2.doAs(new PrivilegedExceptionAction<JobClient>(){
-
@Override
public JobClient run() throws Exception {
return new JobClient(cluster.createJobConf());
- }});
+ }
+ });
- Token<DelegationTokenIdentifier> token =
+ final Token<DelegationTokenIdentifier> token =
client.getDelegationToken(new Text(user1.getUserName()));
DataInputBuffer inBuf = new DataInputBuffer();
@@ -85,26 +85,58 @@ public class TestDelegationToken {
System.out.println("max time: " + maxTime);
assertTrue("createTime < current", createTime < currentTime);
assertTrue("current < maxTime", currentTime < maxTime);
- client.renewDelegationToken(token);
- client.renewDelegationToken(token);
- try {
- bobClient.renewDelegationToken(token);
- Assert.fail("bob renew");
- } catch (AccessControlException ace) {
- // PASS
- }
- try {
- bobClient.cancelDelegationToken(token);
- Assert.fail("bob renew");
- } catch (AccessControlException ace) {
- // PASS
- }
- client.cancelDelegationToken(token);
- try {
- client.cancelDelegationToken(token);
- Assert.fail("second alice cancel");
- } catch (InvalidToken it) {
- // PASS
- }
+
+ // renew should work as user alice
+ user1.doAs(new PrivilegedExceptionAction<Void>() {
+ @Override
+ public Void run() throws Exception {
+ client.renewDelegationToken(token);
+ client.renewDelegationToken(token);
+ return null;
+ }
+ });
+
+ // bob should fail to renew
+ user2.doAs(new PrivilegedExceptionAction<Void>() {
+ @Override
+ public Void run() throws Exception {
+ try {
+ bobClient.renewDelegationToken(token);
+ Assert.fail("bob renew");
+ } catch (AccessControlException ace) {
+ // PASS
+ }
+ return null;
+ }
+ });
+
+ // bob should fail to cancel
+ user2.doAs(new PrivilegedExceptionAction<Void>() {
+ @Override
+ public Void run() throws Exception {
+ try {
+ bobClient.cancelDelegationToken(token);
+ Assert.fail("bob cancel");
+ } catch (AccessControlException ace) {
+ // PASS
+ }
+ return null;
+ }
+ });
+
+ // alice should be able to cancel but only cancel once
+ user1.doAs(new PrivilegedExceptionAction<Void>() {
+ @Override
+ public Void run() throws Exception {
+ client.cancelDelegationToken(token);
+ try {
+ client.cancelDelegationToken(token);
+ Assert.fail("second alice cancel");
+ } catch (InvalidToken it) {
+ // PASS
+ }
+ return null;
+ }
+ });
}
}