steveloughran commented on code in PR #4408:
URL: https://github.com/apache/hadoop/pull/4408#discussion_r893431893


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMTokens.java:
##########
@@ -204,7 +204,7 @@ public void testDelegationToken() throws IOException, 
InterruptedException {
         fail("Should not have succeeded with an expired token");
       } catch (Exception e) {
         assertEquals(InvalidToken.class.getName(), e.getClass().getName());
-        assertTrue(e.getMessage().contains("is expired"));
+        assertTrue(e.getMessage().contains("Token  has expired"));

Review Comment:
   this is pretty old code; we would never write new tests this way. 
   as well as being complicated, if a different exception is raised *we want 
that stack trace*
   
   best to clean up
   
   replace the whole section from L202 with a call of
   ```java
   LambdaTestUtils.intercept(InvalidToken.class, "has expired",
    () -> clientRMWithDT.getNewApplication(request));
   
   ```
   
   look inside the intercept call to see what it does better.



##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMTokens.java:
##########
@@ -198,14 +198,11 @@ public void testDelegationToken() throws IOException, 
InterruptedException {
       }
       Thread.sleep(50l);
       LOG.info("At time: " + System.currentTimeMillis() + ", token should be 
invalid");
-      // Token should have expired.      
-      try {
-        clientRMWithDT.getNewApplication(request);
-        fail("Should not have succeeded with an expired token");
-      } catch (Exception e) {
-        assertEquals(InvalidToken.class.getName(), e.getClass().getName());
-        assertTrue(e.getMessage().contains("is expired"));
-      } 
+      // Token should have expired.
+      final ApplicationClientProtocol finalClientRMWithDT = clientRMWithDT;
+      final GetNewApplicationRequest finalRequest = request;
+      LambdaTestUtils.intercept(InvalidToken.class, "Token  has expired",

Review Comment:
   where is that space coming from? is it because there's no real user in the 
test run?
   
   



-- 
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]

Reply via email to