vikramahuja1001 commented on code in PR #5303:
URL: https://github.com/apache/hive/pull/5303#discussion_r1668180682
##########
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/security/TestTokenStoreDelegationTokenSecretManager.java:
##########
@@ -99,19 +112,46 @@ private DelegationTokenIdentifier getID(String tokenStr)
throws IOException {
@Test public void testExpiry() throws IOException, InterruptedException {
DelegationTokenStore tokenStore = new MemoryTokenStore();
- TokenStoreDelegationTokenSecretManager mgr = createTokenMgr(tokenStore, 1);
+ TokenStoreDelegationTokenSecretManager mgr = createTokenMgr(tokenStore, 1,
8, 2);
try {
mgr.startThreads();
String tokenStr =
mgr.getDelegationToken(UserGroupInformation.getCurrentUser().getShortUserName(),
UserGroupInformation.getCurrentUser().getShortUserName());
DelegationTokenIdentifier id = getID(tokenStr);
Assert.assertNotNull(mgr.verifyDelegationToken(tokenStr));
- // Sleep for the renewal duration
- Thread.sleep(1000);
- SecretManager.InvalidToken ex =
Assert.assertThrows(SecretManager.InvalidToken.class,
+ // Sleep for the expiration/maxlife duration duration
+ Thread.sleep(6000);
+ IllegalStateException ex =
Assert.assertThrows(IllegalStateException.class,
() -> mgr.verifyDelegationToken(tokenStr));
- Assert.assertTrue(ex.getMessage(), ex.getMessage().contains("has
expired"));
+ Assert.assertTrue(ex.getMessage(), ex.getMessage().contains("Expiration
time passed"));
+ Thread.sleep(6000);
+ //Expiry thread will remove the token as it has crossed the maxLifeTime.
+
Assert.assertEquals(tokenStore.getAllDelegationTokenIdentifiers().size(), 0);
+ } finally {
+ mgr.stopThreads();
+ }
+ }
+
+ @Test
+ public void testExpiryThreadRenewingAndRemovingToken() throws IOException,
InterruptedException {
+ DelegationTokenStore tokenStore = new MemoryTokenStore();
Review Comment:
Done, reduced the sleep time as well
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]