YARN-11172. Fix TestClientRMTokens#testDelegationToken introduced by HDFS-16563. (#4408)
Regression caused by HDFS-16563; the hdfs exception text was changed, but because it was a YARN test doing the check, Yetus didn't notice. Contributed by zhengchenyu
This commit is contained in:
parent
e199da3fae
commit
80446dcd08
|
@ -518,9 +518,9 @@ extends AbstractDelegationTokenIdentifier>
|
||||||
}
|
}
|
||||||
long now = Time.now();
|
long now = Time.now();
|
||||||
if (info.getRenewDate() < now) {
|
if (info.getRenewDate() < now) {
|
||||||
err =
|
err = "Token " + identifier.getRealUser() + " has expired, current time: "
|
||||||
"Token has" + identifier.getRealUser() + "expired, current time: " + Time.formatTime(now)
|
+ Time.formatTime(now) + " expected renewal time: " + Time
|
||||||
+ " expected renewal time: " + Time.formatTime(info.getRenewDate());
|
.formatTime(info.getRenewDate());
|
||||||
LOG.info("{}, Token={}", err, formatTokenId(identifier));
|
LOG.info("{}, Token={}", err, formatTokenId(identifier));
|
||||||
throw new InvalidToken(err);
|
throw new InvalidToken(err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
package org.apache.hadoop.yarn.server.resourcemanager;
|
package org.apache.hadoop.yarn.server.resourcemanager;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
|
@ -36,6 +35,7 @@ import java.net.InetSocketAddress;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
import java.security.PrivilegedExceptionAction;
|
import java.security.PrivilegedExceptionAction;
|
||||||
|
|
||||||
|
import org.apache.hadoop.test.LambdaTestUtils;
|
||||||
import org.apache.hadoop.thirdparty.protobuf.InvalidProtocolBufferException;
|
import org.apache.hadoop.thirdparty.protobuf.InvalidProtocolBufferException;
|
||||||
import org.apache.hadoop.io.DataOutputBuffer;
|
import org.apache.hadoop.io.DataOutputBuffer;
|
||||||
import org.apache.hadoop.net.NetUtils;
|
import org.apache.hadoop.net.NetUtils;
|
||||||
|
@ -111,7 +111,7 @@ public class TestClientRMTokens {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDelegationToken() throws IOException, InterruptedException {
|
public void testDelegationToken() throws Exception {
|
||||||
|
|
||||||
final YarnConfiguration conf = new YarnConfiguration();
|
final YarnConfiguration conf = new YarnConfiguration();
|
||||||
conf.set(YarnConfiguration.RM_PRINCIPAL, "testuser/localhost@apache.org");
|
conf.set(YarnConfiguration.RM_PRINCIPAL, "testuser/localhost@apache.org");
|
||||||
|
@ -199,13 +199,10 @@ public class TestClientRMTokens {
|
||||||
Thread.sleep(50l);
|
Thread.sleep(50l);
|
||||||
LOG.info("At time: " + System.currentTimeMillis() + ", token should be invalid");
|
LOG.info("At time: " + System.currentTimeMillis() + ", token should be invalid");
|
||||||
// Token should have expired.
|
// Token should have expired.
|
||||||
try {
|
final ApplicationClientProtocol finalClientRMWithDT = clientRMWithDT;
|
||||||
clientRMWithDT.getNewApplication(request);
|
final GetNewApplicationRequest finalRequest = request;
|
||||||
fail("Should not have succeeded with an expired token");
|
LambdaTestUtils.intercept(InvalidToken.class, "Token has expired",
|
||||||
} catch (Exception e) {
|
() -> finalClientRMWithDT.getNewApplication(finalRequest));
|
||||||
assertEquals(InvalidToken.class.getName(), e.getClass().getName());
|
|
||||||
assertTrue(e.getMessage().contains("is expired"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test cancellation
|
// Test cancellation
|
||||||
// Stop the existing proxy, start another.
|
// Stop the existing proxy, start another.
|
||||||
|
|
Loading…
Reference in New Issue