You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by zh...@apache.org on 2019/06/05 20:42:21 UTC

[geode] 01/01: GEODE-6321: This is race caused by not enough SLOP time (it could use up to 300ms). The next test testShutdown2 used 3 seconds sleep, but verify at least run for 2 seconds. Apply the same design to resolve the race. The logic is already verified in assertTrue(ex.awaitTermination())

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

zhouxj pushed a commit to branch feature/GEODE-6321
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 5678143786e89ce41df9acefae4a4bdf25f16519
Author: zhouxh <gz...@pivotal.io>
AuthorDate: Wed Jun 5 13:38:25 2019 -0700

    GEODE-6321: This is race caused by not enough SLOP time (it could use up to 300ms). The next test testShutdown2 used 3 seconds sleep,
    but verify at least run for 2 seconds. Apply the same design to resolve the race.
    The logic is already verified in assertTrue(ex.awaitTermination())
---
 .../ScheduledThreadPoolExecutorWithKeepAliveJUnitTest.java   | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/geode-core/src/integrationTest/java/org/apache/geode/internal/ScheduledThreadPoolExecutorWithKeepAliveJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/internal/ScheduledThreadPoolExecutorWithKeepAliveJUnitTest.java
index d716cc5..df6c128 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/internal/ScheduledThreadPoolExecutorWithKeepAliveJUnitTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/internal/ScheduledThreadPoolExecutorWithKeepAliveJUnitTest.java
@@ -212,11 +212,15 @@ public class ScheduledThreadPoolExecutorWithKeepAliveJUnitTest {
     ex.schedule(new Runnable() {
       @Override
       public void run() {
-        // The testShutdown2 will test only with sleep, no deley
-        // let testShutdown to test only with delay
-        System.out.println("Finished scheduled task");
+        try {
+          // change to sleep 3 seconds, the same as testShutdown2, to avoid not enough SLOP time
+          Thread.sleep(3000);
+          System.out.println("Finished scheduled task");
+        } catch (InterruptedException e) {
+          fail("interrupted");
+        }
       }
-    }, 4, TimeUnit.SECONDS);
+    }, 2, TimeUnit.SECONDS);
     long start = System.nanoTime();
     ex.shutdown();
     assertTrue(ex.awaitTermination(10, TimeUnit.SECONDS));