accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [accumulo] branch main updated: Fixes #1763 - Flaky test: SimpleTimerTest (#1816)
Date Mon, 30 Nov 2020 22:14:37 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
     new ca58658  Fixes #1763 - Flaky test: SimpleTimerTest (#1816)
ca58658 is described below

commit ca58658cce43d4758fe3b0dfcc0653cb11791850
Author: Dom G <47725857+DomGarguilo@users.noreply.github.com>
AuthorDate: Mon Nov 30 17:14:28 2020 -0500

    Fixes #1763 - Flaky test: SimpleTimerTest (#1816)
    
    * replaced asserts with loop to recheck test conditions if failed
---
 .../accumulo/server/util/time/SimpleTimerTest.java  | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/server/base/src/test/java/org/apache/accumulo/server/util/time/SimpleTimerTest.java
b/server/base/src/test/java/org/apache/accumulo/server/util/time/SimpleTimerTest.java
index 565e97b..1f03b1a 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/util/time/SimpleTimerTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/util/time/SimpleTimerTest.java
@@ -20,7 +20,6 @@ package org.apache.accumulo.server.util.time;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
 
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -70,35 +69,41 @@ public class SimpleTimerTest {
     }
   }
 
-  @Test
+  @Test(timeout = 5000)
   public void testOneTimeSchedule() throws InterruptedException {
     AtomicInteger i = new AtomicInteger();
     Incrementer r = new Incrementer(i);
     t.schedule(r, DELAY);
     Thread.sleep(DELAY + PAD);
-    assertEquals(1, i.get());
+    while (i.get() != 1) {
+      Thread.sleep(PAD);
+    }
     r.cancel();
   }
 
-  @Test
+  @Test(timeout = 10000)
   public void testFixedDelaySchedule() throws InterruptedException {
     AtomicInteger i = new AtomicInteger();
     Incrementer r = new Incrementer(i);
     t.schedule(r, DELAY, PERIOD);
     Thread.sleep(DELAY + (2 * PERIOD) + PAD);
-    assertEquals(3, i.get());
+    while (i.get() != 3) {
+      Thread.sleep(PAD);
+    }
     r.cancel();
   }
 
-  @Test
+  @Test(timeout = 5000)
   public void testFailure() throws InterruptedException {
     Thrower r = new Thrower();
     t.schedule(r, DELAY);
     Thread.sleep(DELAY + PAD);
-    assertTrue(r.wasRun);
+    while (!r.wasRun) {
+      Thread.sleep(PAD);
+    }
   }
 
-  @Test
+  @Test(timeout = 5000)
   public void testSingleton() {
     assertEquals(1, SimpleTimer.getInstanceThreadPoolSize());
     SimpleTimer t2 = SimpleTimer.getInstance(2);


Mime
View raw message