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:
   I have kept 2 tests only as both are doing different functionality, but 
reduced the sleep time by a lot.



-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to