MAPREDUCE-3219. Reenabled and fixed bugs in the failing test TestDelegationToken. Contributed by Hitesh Shah.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1197415 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6afe3e0d22
commit
08cb4cf334
@ -66,12 +66,15 @@ Release 0.23.1 - Unreleased
|
|||||||
|
|
||||||
BUG FIXES
|
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)
|
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)
|
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
|
Release 0.23.0 - 2011-11-01
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -29,7 +29,6 @@ import org.apache.hadoop.security.token.Token;
|
|||||||
import org.apache.hadoop.security.token.SecretManager.InvalidToken;
|
import org.apache.hadoop.security.token.SecretManager.InvalidToken;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
@ -48,26 +47,27 @@ public class TestDelegationToken {
|
|||||||
cluster = new MiniMRCluster(0,0,1,"file:///",1);
|
cluster = new MiniMRCluster(0,0,1,"file:///",1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void testDelegationToken() throws Exception {
|
public void testDelegationToken() throws Exception {
|
||||||
|
|
||||||
JobClient client;
|
final JobClient client;
|
||||||
client = user1.doAs(new PrivilegedExceptionAction<JobClient>(){
|
client = user1.doAs(new PrivilegedExceptionAction<JobClient>(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JobClient run() throws Exception {
|
public JobClient run() throws Exception {
|
||||||
return new JobClient(cluster.createJobConf());
|
return new JobClient(cluster.createJobConf());
|
||||||
}});
|
}
|
||||||
JobClient bobClient;
|
});
|
||||||
|
|
||||||
|
final JobClient bobClient;
|
||||||
bobClient = user2.doAs(new PrivilegedExceptionAction<JobClient>(){
|
bobClient = user2.doAs(new PrivilegedExceptionAction<JobClient>(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JobClient run() throws Exception {
|
public JobClient run() throws Exception {
|
||||||
return new JobClient(cluster.createJobConf());
|
return new JobClient(cluster.createJobConf());
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Token<DelegationTokenIdentifier> token =
|
final Token<DelegationTokenIdentifier> token =
|
||||||
client.getDelegationToken(new Text(user1.getUserName()));
|
client.getDelegationToken(new Text(user1.getUserName()));
|
||||||
|
|
||||||
DataInputBuffer inBuf = new DataInputBuffer();
|
DataInputBuffer inBuf = new DataInputBuffer();
|
||||||
@ -85,20 +85,49 @@ public class TestDelegationToken {
|
|||||||
System.out.println("max time: " + maxTime);
|
System.out.println("max time: " + maxTime);
|
||||||
assertTrue("createTime < current", createTime < currentTime);
|
assertTrue("createTime < current", createTime < currentTime);
|
||||||
assertTrue("current < maxTime", currentTime < maxTime);
|
assertTrue("current < maxTime", currentTime < maxTime);
|
||||||
|
|
||||||
|
// renew should work as user alice
|
||||||
|
user1.doAs(new PrivilegedExceptionAction<Void>() {
|
||||||
|
@Override
|
||||||
|
public Void run() throws Exception {
|
||||||
client.renewDelegationToken(token);
|
client.renewDelegationToken(token);
|
||||||
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 {
|
try {
|
||||||
bobClient.renewDelegationToken(token);
|
bobClient.renewDelegationToken(token);
|
||||||
Assert.fail("bob renew");
|
Assert.fail("bob renew");
|
||||||
} catch (AccessControlException ace) {
|
} catch (AccessControlException ace) {
|
||||||
// PASS
|
// PASS
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// bob should fail to cancel
|
||||||
|
user2.doAs(new PrivilegedExceptionAction<Void>() {
|
||||||
|
@Override
|
||||||
|
public Void run() throws Exception {
|
||||||
try {
|
try {
|
||||||
bobClient.cancelDelegationToken(token);
|
bobClient.cancelDelegationToken(token);
|
||||||
Assert.fail("bob renew");
|
Assert.fail("bob cancel");
|
||||||
} catch (AccessControlException ace) {
|
} catch (AccessControlException ace) {
|
||||||
// PASS
|
// 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);
|
client.cancelDelegationToken(token);
|
||||||
try {
|
try {
|
||||||
client.cancelDelegationToken(token);
|
client.cancelDelegationToken(token);
|
||||||
@ -106,5 +135,8 @@ public class TestDelegationToken {
|
|||||||
} catch (InvalidToken it) {
|
} catch (InvalidToken it) {
|
||||||
// PASS
|
// PASS
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user