You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2015/11/02 22:52:31 UTC

[05/50] [abbrv] incubator-geode git commit: GEODE-445: fix race in unit test

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 <ds...@pivotal.io>
Authored: Wed Oct 21 14:51:34 2015 -0700
Committer: Darrel Schneider <ds...@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);
         }
       });
     }