geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject geode git commit: GEODE-3131: Replaced Thread.sleep
Date Wed, 12 Jul 2017 21:55:34 GMT
Repository: geode
Updated Branches:
  refs/heads/develop 96bc0ebf1 -> cc8aacb43


GEODE-3131: Replaced Thread.sleep

	* Replaced sleeps with an Awaitility clause which waits for the region sizes to be correct
before starting validation.

	This closes #628


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/cc8aacb4
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/cc8aacb4
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/cc8aacb4

Branch: refs/heads/develop
Commit: cc8aacb43bd8f61d4778c5302f701d0c320a76ed
Parents: 96bc0eb
Author: nabarun <nnag@pivotal.io>
Authored: Wed Jul 12 14:07:48 2017 -0700
Committer: nabarun <nnag@pivotal.io>
Committed: Wed Jul 12 14:51:19 2017 -0700

----------------------------------------------------------------------
 .../cache/ha/HARQueueNewImplDUnitTest.java      | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/cc8aacb4/geode-core/src/test/java/org/apache/geode/internal/cache/ha/HARQueueNewImplDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/ha/HARQueueNewImplDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/ha/HARQueueNewImplDUnitTest.java
index 12e5819..0680945 100755
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/ha/HARQueueNewImplDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/ha/HARQueueNewImplDUnitTest.java
@@ -25,8 +25,10 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.geode.test.junit.categories.ClientSubscriptionTest;
+import org.awaitility.Awaitility;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -374,7 +376,10 @@ public class HARQueueNewImplDUnitTest extends JUnit4DistributedTestCase
{
     serverVM0.invoke(() -> HARQueueNewImplDUnitTest.createEntries());
 
     serverVM1.invoke(() -> HARQueueNewImplDUnitTest.startServer());
-    Thread.sleep(3000); // TODO: Find a better 'n reliable alternative
+
+    serverVM1.invoke(() -> ValidateRegionSizes(PORT2));
+    serverVM0.invoke(() -> ValidateRegionSizes(PORT1));
+
 
     serverVM0.invoke(() -> HARQueueNewImplDUnitTest.updateMapForVM0());
     serverVM1.invoke(() -> HARQueueNewImplDUnitTest.updateMapForVM1());
@@ -385,6 +390,19 @@ public class HARQueueNewImplDUnitTest extends JUnit4DistributedTestCase
{
         new Integer(PORT2)));
   }
 
+  private void ValidateRegionSizes(int port) {
+    Awaitility.await().atMost(60, TimeUnit.SECONDS).until(() -> {
+      Region region = cache.getRegion("/" + regionName);
+      Region msgsRegion = cache.getRegion(CacheServerImpl.generateNameForClientMsgsRegion(port));
+      int clientMsgRegionSize = msgsRegion.size();
+      int regionSize = region.size();
+      assertTrue(
+          "Region sizes were not as expected after 60 seconds elapsed. Actual region size
= "
+              + regionSize + "Actual client msg region size = " + clientMsgRegionSize,
+          true == ((5 == clientMsgRegionSize) && (5 == regionSize)));
+    });
+  }
+
   /**
    * This test verifies that the ha-region-queues decrement the reference count of their
respective
    * HAEventWrapper instances in the client-messages-region correctly, after the events have
been


Mime
View raw message