geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bschucha...@apache.org
Subject [39/50] [abbrv] incubator-geode git commit: GEODE-138: remove race condition from testEventDelivery
Date Fri, 14 Aug 2015 20:40:28 GMT
GEODE-138: remove race condition from testEventDelivery

The race due to the test expecting local event delivery to be synchronous
but the implementation of off-heap resource manager events being async.
The test has been changed to always use a wait criteria when waiting
for a memory event to arrive.


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

Branch: refs/heads/feature/GEODE-77
Commit: bd84581e3d5a93cbbb3fcdf06ebe60bb9460e702
Parents: e255c75
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Mon Aug 10 14:24:58 2015 -0700
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Mon Aug 10 16:29:09 2015 -0700

----------------------------------------------------------------------
 .../MemoryThresholdsOffHeapDUnitTest.java       | 42 ++++++++++----------
 1 file changed, 22 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bd84581e/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 0b704a6..83b8608 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
@@ -146,14 +146,14 @@ public class MemoryThresholdsOffHeapDUnitTest extends BridgeTestCase
{
     // NORMAL -> EVICTION
     setUsageAboveEvictionThreshold(server2, regionName);
     verifyListenerValue(server1, MemoryState.EVICTION, 1, true);
-    verifyListenerValue(server2, MemoryState.EVICTION, 1, false);
+    verifyListenerValue(server2, MemoryState.EVICTION, 1, true);
     
     // EVICTION -> CRITICAL
     setUsageAboveCriticalThreshold(server2, regionName);
     verifyListenerValue(server1, MemoryState.CRITICAL, 1, true);
-    verifyListenerValue(server2, MemoryState.CRITICAL, 1, false);
+    verifyListenerValue(server2, MemoryState.CRITICAL, 1, true);
     verifyListenerValue(server1, MemoryState.EVICTION, 2, true);
-    verifyListenerValue(server2, MemoryState.EVICTION, 2, false);
+    verifyListenerValue(server2, MemoryState.EVICTION, 2, true);
     
     // CRITICAL -> CRITICAL
     server2.invoke(new SerializableCallable() {
@@ -168,9 +168,9 @@ public class MemoryThresholdsOffHeapDUnitTest extends BridgeTestCase {
       }
     });
     verifyListenerValue(server1, MemoryState.CRITICAL, 1, true);
-    verifyListenerValue(server2, MemoryState.CRITICAL, 1, false);
+    verifyListenerValue(server2, MemoryState.CRITICAL, 1, true);
     verifyListenerValue(server1, MemoryState.EVICTION, 2, true);
-    verifyListenerValue(server2, MemoryState.EVICTION, 2, false);
+    verifyListenerValue(server2, MemoryState.EVICTION, 2, true);
     
     // CRITICAL -> EVICTION
     server2.invoke(new SerializableCallable() {
@@ -185,7 +185,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends BridgeTestCase {
       }
     });
     verifyListenerValue(server1, MemoryState.EVICTION, 3, true);
-    verifyListenerValue(server2, MemoryState.EVICTION, 3, false);
+    verifyListenerValue(server2, MemoryState.EVICTION, 3, true);
 
     // EVICTION -> EVICTION
     server2.invoke(new SerializableCallable() {
@@ -198,7 +198,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends BridgeTestCase {
       }
     });
     verifyListenerValue(server1, MemoryState.EVICTION, 3, true);
-    verifyListenerValue(server2, MemoryState.EVICTION, 3, false);
+    verifyListenerValue(server2, MemoryState.EVICTION, 3, true);
 
     // EVICTION -> NORMAL
     server2.invoke(new SerializableCallable() {
@@ -215,9 +215,9 @@ public class MemoryThresholdsOffHeapDUnitTest extends BridgeTestCase {
     verifyListenerValue(server1, MemoryState.EVICTION, 3, true);
     verifyListenerValue(server1, MemoryState.NORMAL, 1, true);
     
-    verifyListenerValue(server2, MemoryState.CRITICAL, 1, false);
-    verifyListenerValue(server2, MemoryState.EVICTION, 3, false);
-    verifyListenerValue(server2, MemoryState.NORMAL, 1, false);
+    verifyListenerValue(server2, MemoryState.CRITICAL, 1, true);
+    verifyListenerValue(server2, MemoryState.EVICTION, 3, true);
+    verifyListenerValue(server2, MemoryState.NORMAL, 1, true);
   }
   
   /**
@@ -245,23 +245,23 @@ public class MemoryThresholdsOffHeapDUnitTest extends BridgeTestCase
{
     registerTestMemoryThresholdListener(server2);
     
     setUsageAboveEvictionThreshold(server1, regionName);
-    verifyListenerValue(server1, MemoryState.EVICTION, 0, false);
+    verifyListenerValue(server1, MemoryState.EVICTION, 0, true);
     verifyListenerValue(server2, MemoryState.EVICTION, 0, true);
 
     setThresholds(server1, 70f, 0f);
-    verifyListenerValue(server1, MemoryState.EVICTION, 1, false);
+    verifyListenerValue(server1, MemoryState.EVICTION, 1, true);
     verifyListenerValue(server2, MemoryState.EVICTION, 1, true);
 
     setUsageAboveCriticalThreshold(server1, regionName);
-    verifyListenerValue(server1, MemoryState.CRITICAL, 0, false);
+    verifyListenerValue(server1, MemoryState.CRITICAL, 0, true);
     verifyListenerValue(server2, MemoryState.CRITICAL, 0, true);
 
     setThresholds(server1, 0f, 0f);
-    verifyListenerValue(server1, MemoryState.EVICTION_DISABLED, 1, false);
+    verifyListenerValue(server1, MemoryState.EVICTION_DISABLED, 1, true);
     verifyListenerValue(server2, MemoryState.EVICTION_DISABLED, 1, true);
 
     setThresholds(server1, 0f, 90f);
-    verifyListenerValue(server1, MemoryState.CRITICAL, 1, false);
+    verifyListenerValue(server1, MemoryState.CRITICAL, 1, true);
     verifyListenerValue(server2, MemoryState.CRITICAL, 1, true);
 
     //verify that stats on server2 are not changed by events on server1
@@ -373,7 +373,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends BridgeTestCase {
     setUsageAboveCriticalThreshold(server2, regionName);
 
     verifyListenerValue(server1, MemoryState.CRITICAL, 1, true);
-    verifyListenerValue(server2, MemoryState.CRITICAL, 1, false);
+    verifyListenerValue(server2, MemoryState.CRITICAL, 1, true);
 
     //make sure that client puts are rejected
     doPuts(client, regionName, true/*catchRejectedException*/,
@@ -448,7 +448,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends BridgeTestCase {
     setUsageAboveCriticalThreshold(server2, regionName);
 
     verifyListenerValue(server1, MemoryState.CRITICAL, 1, true);
-    verifyListenerValue(server2, MemoryState.CRITICAL, 1, false);
+    verifyListenerValue(server2, MemoryState.CRITICAL, 1, true);
 
     //make sure that local server1 puts are rejected
     doPuts(server1, regionName, false/*catchRejectedException*/,
@@ -1552,7 +1552,9 @@ public class MemoryThresholdsOffHeapDUnitTest extends BridgeTestCase
{
 
   /**
    * Verifies that the test listener value on the given vm is what is expected
-   * Note that for remote events useWaitCriterion must be true
+   * Note that for remote events useWaitCriterion must be true.
+   * Note also that since off-heap local events are async local events must also
+   * set useWaitCriterion to true.
    * 
    * @param vm
    *          the vm where verification should take place
@@ -1562,7 +1564,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends BridgeTestCase
{
    * @param value
    *          the expected value
    * @param useWaitCriterion
-   *          must be true for remote events
+   *          must be true for both local and remote events (see GEODE-138)
    */
   private void verifyListenerValue(VM vm, final MemoryState state, final int value, final
boolean useWaitCriterion) {
     vm.invoke(new SerializableCallable() {
@@ -1672,7 +1674,7 @@ public class MemoryThresholdsOffHeapDUnitTest extends BridgeTestCase
{
           throw new IllegalStateException("Unknown memory state");
         }
         if (useWaitCriterion) {
-          waitForCriterion(wc, 5000, 100, true);
+          waitForCriterion(wc, 5000, 10, true);
         }
         return null;
       }


Mime
View raw message