This is an automated email from the ASF dual-hosted git repository.

cshannon pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/2.1 by this push:
     new 1531fe5d7e Fix intermittent failure in 
AuthenticationTokenSecretManagerTest (#4203)
1531fe5d7e is described below

commit 1531fe5d7edbe4ce8286d8894a888465ca76d5e2
Author: Christopher L. Shannon <cshan...@apache.org>
AuthorDate: Sat Jan 27 10:37:43 2024 -0500

    Fix intermittent failure in AuthenticationTokenSecretManagerTest (#4203)
    
    There fixes a test race condition in the testVerifyPassword test that
    could occasionally cause the test to fail if it ran too quickly. Token
    generation uses System.currentTimeMillis() so the test previously would
    fail when trying to generate a new token if the timestamp didn't update
    as the same token would be returned. This commit adds a short sleep of 50
    ms to guarantee that the test won't fail.
---
 .../security/delegation/AuthenticationTokenSecretManagerTest.java   | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git 
a/server/base/src/test/java/org/apache/accumulo/server/security/delegation/AuthenticationTokenSecretManagerTest.java
 
b/server/base/src/test/java/org/apache/accumulo/server/security/delegation/AuthenticationTokenSecretManagerTest.java
index d30afce00d..00d9e6cf03 100644
--- 
a/server/base/src/test/java/org/apache/accumulo/server/security/delegation/AuthenticationTokenSecretManagerTest.java
+++ 
b/server/base/src/test/java/org/apache/accumulo/server/security/delegation/AuthenticationTokenSecretManagerTest.java
@@ -207,6 +207,12 @@ public class AuthenticationTokenSecretManagerTest extends 
WithTestNames {
     // The passwords line up against multiple calls with the same ID
     assertArrayEquals(password, secretManager.retrievePassword(id));
 
+    // Sleep 50 ms to make sure we generate another token for the test
+    // System.currentTimeMillis() is used as part of the token generation and 
if
+    // the test runs fast enough it can return the same value that was used
+    // when generating the first token and the test will fail
+    Thread.sleep(50);
+
     // Make a second token for the same user
     Entry<Token<AuthenticationTokenIdentifier>,AuthenticationTokenIdentifier> 
pair2 =
         secretManager.generateToken(principal, cfg);

Reply via email to