MAPREDUCE-3219. Reenabled and fixed bugs in the failing test TestDelegationToken. Contributed by Hitesh Shah.
svn merge -c r1197415 --ignore-ancestry ../../trunk/ git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1197416 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4cb237723e
commit
2ecdc2b8a2
|
@ -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
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.apache.hadoop.security.token.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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue