geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject incubator-geode git commit: GEODE-96: fix race condition in unit test testDistributedRegionClientPutRejection
Date Wed, 15 Jul 2015 17:38:59 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop abb7755ce -> 4f8c8cd85


GEODE-96: fix race condition in unit test testDistributedRegionClientPutRejection

The race condition was caused by WaitCriterion on the server not waiting for
the region to be marked as sick. Instead it was just waiting for OffHeapMemoryMonitor
state to be critical.
Reviewed by Kirk Lund


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

Branch: refs/heads/develop
Commit: 4f8c8cd850640e98ceec1913bc3ed5338e581944
Parents: abb7755
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Tue Jul 14 16:53:00 2015 -0700
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Wed Jul 15 10:36:57 2015 -0700

----------------------------------------------------------------------
 .../MemoryThresholdsOffHeapDUnitTest.java       | 48 +++++++++++++++-----
 1 file changed, 37 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f8c8cd8/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsOffHeapDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsOffHeapDUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsOffHeapDUnitTest.java
index aae64c4..0b704a6 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsOffHeapDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsOffHeapDUnitTest.java
@@ -1401,18 +1401,44 @@ public class MemoryThresholdsOffHeapDUnitTest extends BridgeTestCase
{
         final OffHeapMemoryMonitor ohm = irm.getOffHeapMonitor();
         assertTrue(ohm.getState().isNormal());
         getCache().getLoggerI18n().fine(addExpectedExString);
-        getRootRegion().getSubregion(regionName).put(1, new byte[943720]);
-        WaitCriterion wc = new WaitCriterion() {
-          @Override
-          public String description() {
-            return "Expected to go critical";
-          }
+        final LocalRegion r = (LocalRegion) getRootRegion().getSubregion(regionName);
+        final Object key = 1;
+        r.put(key, new byte[943720]);
+        WaitCriterion wc;
+        if (r instanceof PartitionedRegion) {
+          final PartitionedRegion pr = (PartitionedRegion) r;
+          final int bucketId = PartitionedRegionHelper.getHashKey(pr, null, key, null, null);
+          wc = new WaitCriterion() {
+            @Override
+            public String description() {
+              return "Expected to go critical: isCritical=" + ohm.getState().isCritical();
+            }
 
-          @Override
-          public boolean done() {
-            return ohm.getState().isCritical();
-          }
-        };
+            @Override
+            public boolean done() {
+              if (!ohm.getState().isCritical()) return false;
+              // Only done once the bucket has been marked sick
+              try {
+                pr.getRegionAdvisor().checkIfBucketSick(bucketId, key);
+                return false;
+              } catch (LowMemoryException ignore) {
+                return true;
+              }
+            }
+          };
+        } else {
+          wc = new WaitCriterion() {
+            @Override
+            public String description() {
+              return "Expected to go critical: isCritical=" + ohm.getState().isCritical()
+ " memoryThresholdReached=" + r.memoryThresholdReached.get();
+            }
+
+            @Override
+            public boolean done() {
+              return ohm.getState().isCritical() && r.memoryThresholdReached.get();
+            }
+          };
+        }
         waitForCriterion(wc, 5000, 100, true);
         getCache().getLoggerI18n().fine(removeExpectedExString);
         return;


Mime
View raw message