geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [05/50] [abbrv] incubator-geode git commit: GEODE-445: fix race in unit test
Date Mon, 02 Nov 2015 21:52:31 GMT
GEODE-445: fix race in unit test

The test now uses a WaitCriteria when checking
member and profile count.


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

Branch: refs/heads/feature/GEODE-328
Commit: 9390a6248d2a92c0028275dac3711c49869f03ce
Parents: ec307d2
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Wed Oct 21 14:51:34 2015 -0700
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Wed Oct 21 16:52:41 2015 -0700

----------------------------------------------------------------------
 .../offheap/OutOfOffHeapMemoryDUnitTest.java    | 27 +++++++++++++++++---
 1 file changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9390a624/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
index a7921ee..76bfde7 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/OutOfOffHeapMemoryDUnitTest.java
@@ -293,10 +293,29 @@ public class OutOfOffHeapMemoryDUnitTest extends CacheTestCase {
           final int countMembersPlusLocator = vmCount+1-1; // +1 for locator, -1 for OOOHME
member
           final int countOtherMembers = vmCount-1-1; // -1 for self, -1 for OOOHME member
           
-          assertEquals(countMembersPlusLocator, ((InternalDistributedSystem)OutOfOffHeapMemoryDUnitTest
-              .system.get()).getDistributionManager().getDistributionManagerIds().size());
-          assertEquals(countOtherMembers, ((DistributedRegion)OutOfOffHeapMemoryDUnitTest
-              .cache.get().getRegion(name)).getDistributionAdvisor().getNumProfiles());
+          final WaitCriterion waitForDisconnect = new WaitCriterion() {
+            public boolean done() {
+              InternalDistributedSystem ids = (InternalDistributedSystem)OutOfOffHeapMemoryDUnitTest.system.get();
+              DistributedRegion dr = (DistributedRegion)OutOfOffHeapMemoryDUnitTest.cache.get().getRegion(name);
+              return countMembersPlusLocator == ids.getDistributionManager().getDistributionManagerIds().size()
+                  && countOtherMembers == dr.getDistributionAdvisor().getNumProfiles();
+            }
+            public String description() {
+              String msg = "";
+              InternalDistributedSystem ids = (InternalDistributedSystem)OutOfOffHeapMemoryDUnitTest.system.get();
+              int currentMemberCount = ids.getDistributionManager().getDistributionManagerIds().size();
+              if (countMembersPlusLocator != currentMemberCount) {
+                msg += " expected " + countMembersPlusLocator + " members but found " + currentMemberCount;
+              }
+              DistributedRegion dr = (DistributedRegion)OutOfOffHeapMemoryDUnitTest.cache.get().getRegion(name);
+              int profileCount = dr.getDistributionAdvisor().getNumProfiles();
+              if (countOtherMembers != profileCount) {
+                msg += " expected " + countOtherMembers + " profiles but found " + profileCount;
+              }
+              return msg;
+            }
+          };
+          waitForCriterion(waitForDisconnect, 30*1000, 10, true);
         }
       });
     }


Mime
View raw message