geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jensde...@apache.org
Subject [geode] branch develop updated: GEODE-4884: Remove Thread.sleep from ServerLauncherDUnitTest
Date Sat, 17 Mar 2018 15:16:51 GMT
This is an automated email from the ASF dual-hosted git repository.

jensdeppe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 794af72  GEODE-4884: Remove Thread.sleep from ServerLauncherDUnitTest
794af72 is described below

commit 794af72bf670f4334a3ee14f634141c5c6780998
Author: Jens Deppe <jdeppe@pivotal.io>
AuthorDate: Sat Mar 17 08:16:08 2018 -0700

    GEODE-4884: Remove Thread.sleep from ServerLauncherDUnitTest
---
 .../geode/distributed/ServerLauncherDUnitTest.java      | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherDUnitTest.java
index 183b966..94ea7a4 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherDUnitTest.java
@@ -21,8 +21,10 @@ import java.io.BufferedInputStream;
 import java.io.ByteArrayOutputStream;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.logging.log4j.Logger;
+import org.awaitility.Awaitility;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -52,11 +54,23 @@ public class ServerLauncherDUnitTest {
   public static class TestManagementListener extends UniversalMembershipListenerAdapter {
 
     public static boolean crashed = false;
+    public static boolean joined = false;
+    public static boolean left = false;
 
     @Override
     public void memberCrashed(MembershipEvent event) {
       crashed = true;
     }
+
+    @Override
+    public void memberJoined(MembershipEvent event) {
+      joined = true;
+    }
+
+    @Override
+    public void memberLeft(MembershipEvent event) {
+      left = true;
+    }
   }
 
   @Test
@@ -77,7 +91,8 @@ public class ServerLauncherDUnitTest {
 
     launchServer(locator.getPort());
 
-    Thread.sleep(5000);
+    Awaitility.waitAtMost(10, TimeUnit.SECONDS).until(
+        () -> locator.invoke(() -> TestManagementListener.joined && TestManagementListener.left));
 
     assertThat(locator.invoke(() -> TestManagementListener.crashed)).isFalse();
   }

-- 
To stop receiving notification emails like this one, please contact
jensdeppe@apache.org.

Mime
View raw message