DomGarguilo commented on code in PR #4796:
URL: https://github.com/apache/accumulo/pull/4796#discussion_r1723837279


##########
core/src/test/java/org/apache/accumulo/core/util/CountDownTimerTest.java:
##########
@@ -30,29 +31,61 @@
 public class CountDownTimerTest {
   @Test
   public void testCountDownTimer() throws Exception {
+
+    long start = System.nanoTime();
+
     var timer1 = CountDownTimer.startNew(Duration.ofMillis(100));
     Thread.sleep(10);
-    var timer2 = CountDownTimer.startNew(Duration.ofMillis(100));
+    var timer2 = CountDownTimer.startNew(100, TimeUnit.MILLISECONDS);
     Thread.sleep(10);
     var timer3 = CountDownTimer.startNew(Duration.ofMillis(100));
     Thread.sleep(10);
 
+    boolean expired1 = timer1.isExpired();
+    boolean expired2 = timer1.isExpired();
+    boolean expired3 = timer1.isExpired();
+
     var left3 = timer3.timeLeft(TimeUnit.MILLISECONDS);
     var left2 = timer2.timeLeft(TimeUnit.MILLISECONDS);
     var left1 = timer1.timeLeft(TimeUnit.MILLISECONDS);
 
+    long elapsed = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
+
     assertTrue(left3 <= 90);
     assertTrue(left2 <= 80);
     assertTrue(left1 <= 70);
 
-    assertTrue(left3 >= left2);
-    assertTrue(left2 >= left1);
+    assertTrue(Math.max(left3 - 10, 0) >= left2);
+    assertTrue(Math.max(left2 - 10, 0) >= left1);
+    assertTrue(left1 >= 100 - elapsed);

Review Comment:
   I am getting this test to fail locally too pretty consistently.



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

Reply via email to