hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vino...@apache.org
Subject svn commit: r1197416 - in /hadoop/common/branches/branch-0.23/hadoop-mapreduce-project: CHANGES.txt src/test/mapred/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java
Date Fri, 04 Nov 2011 07:49:46 GMT
Author: vinodkv
Date: Fri Nov  4 07:49:45 2011
New Revision: 1197416

URL: http://svn.apache.org/viewvc?rev=1197416&view=rev
Log:
MAPREDUCE-3219. Reenabled and fixed bugs in the failing test TestDelegationToken. Contributed
by Hitesh Shah.            
svn merge -c r1197415 --ignore-ancestry ../../trunk/

Modified:
    hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/CHANGES.txt
    hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java

Modified: hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/CHANGES.txt?rev=1197416&r1=1197415&r2=1197416&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/CHANGES.txt Fri Nov  4 07:49:45
2011
@@ -16,12 +16,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/branches/branch-0.23/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java?rev=1197416&r1=1197415&r2=1197416&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java
(original)
+++ hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/src/test/mapred/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java
Fri Nov  4 07:49:45 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;
+      }   
+    });
   }
 }



Mime
View raw message