geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From di...@apache.org
Subject [33/50] [abbrv] incubator-geode git commit: GEODE-427: add test logging and assertions
Date Tue, 10 Nov 2015 23:42:55 GMT
GEODE-427: add test logging and assertions

This test refuses to reproduce the failure and
code review has not revealed the cause.
I've added additional test logging and assertions
to give more info the next time the test fails.


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

Branch: refs/heads/feature/GEODE-12
Commit: 06509f34f81cf7afa3de062c7ca342f309849e05
Parents: 2933ccd
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Fri Nov 6 13:40:35 2015 -0800
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Fri Nov 6 13:40:35 2015 -0800

----------------------------------------------------------------------
 .../management/MemoryThresholdsDUnitTest.java   | 34 +++++++++++++++++++-
 .../control/TestMemoryThresholdListener.java    | 13 ++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/06509f34/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java
index 50654f6..1d1ada3 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsDUnitTest.java
@@ -405,7 +405,7 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
     ServerPorts ports2 = startCacheServer(server2, ports1.getMcastPort(), 80f, 90f,
         regionName, false/*createPR*/, false/*notifyBySubscription*/, 0);
 
-    registerTestMemoryThresholdListener(server1);
+    registerLoggingTestMemoryThresholdListener(server1);
     registerTestMemoryThresholdListener(server2);
 
     //NORMAL -> CRITICAL
@@ -418,6 +418,9 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
         return null;
       }
     });
+    verifyListenerValue(server2, MemoryState.CRITICAL, 1, true);
+    verifyListenerValue(server2, MemoryState.EVICTION, 1, true);
+    verifyListenerValue(server2, MemoryState.NORMAL, 0, true);
 
     //make sure we get two events on remote server
     verifyListenerValue(server1, MemoryState.CRITICAL, 1, true);
@@ -434,6 +437,9 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
         return null;
       }
     });
+    verifyListenerValue(server2, MemoryState.CRITICAL, 1, true);
+    verifyListenerValue(server2, MemoryState.EVICTION, 2, true);
+    verifyListenerValue(server2, MemoryState.NORMAL, 0, true);
     verifyListenerValue(server1, MemoryState.CRITICAL, 1, true);
     verifyListenerValue(server1, MemoryState.EVICTION, 2, true);
     verifyListenerValue(server1, MemoryState.NORMAL, 0, true);;
@@ -446,6 +452,9 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
         return null;
       }
     });
+    verifyListenerValue(server2, MemoryState.CRITICAL, 1, true);
+    verifyListenerValue(server2, MemoryState.EVICTION, 2, true);
+    verifyListenerValue(server2, MemoryState.NORMAL, 0, true);
     verifyListenerValue(server1, MemoryState.CRITICAL, 1, true);
     verifyListenerValue(server1, MemoryState.EVICTION, 2, true);
     verifyListenerValue(server1, MemoryState.NORMAL, 0, true);
@@ -459,10 +468,14 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase
{
       }
     });
 
+    verifyListenerValue(server2, MemoryState.CRITICAL, 1, true);
+    verifyListenerValue(server2, MemoryState.EVICTION, 2, true);
+    verifyListenerValue(server2, MemoryState.NORMAL, 1, true);
     verifyListenerValue(server1, MemoryState.CRITICAL, 1, true);
     verifyListenerValue(server1, MemoryState.EVICTION, 2, true);
     verifyListenerValue(server1, MemoryState.NORMAL, 1, true);
     
+    this.getLogWriter().info("before NORMAL->CRITICAL->NORMAL");
     //NORMAL -> EVICTION -> NORMAL
     server2.invoke(new SerializableCallable() {
       public Object call() throws Exception {
@@ -472,7 +485,11 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
         return null;
       }
     });
+    this.getLogWriter().info("after NORMAL->CRITICAL->NORMAL");
 
+    verifyListenerValue(server2, MemoryState.CRITICAL, 2, true);
+    verifyListenerValue(server2, MemoryState.EVICTION, 3, true);
+    verifyListenerValue(server2, MemoryState.NORMAL, 2, true);
     verifyListenerValue(server1, MemoryState.CRITICAL, 2, true);
     verifyListenerValue(server1, MemoryState.EVICTION, 3, true);
     verifyListenerValue(server1, MemoryState.NORMAL, 2, true);
@@ -486,6 +503,9 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase {
       }
     });
 
+    verifyListenerValue(server2, MemoryState.CRITICAL, 2, true);
+    verifyListenerValue(server2, MemoryState.EVICTION, 4, true);
+    verifyListenerValue(server2, MemoryState.NORMAL, 2, true);
     verifyListenerValue(server1, MemoryState.CRITICAL, 2, true);
     verifyListenerValue(server1, MemoryState.EVICTION, 4, true);
     verifyListenerValue(server1, MemoryState.NORMAL, 2, true);
@@ -1452,6 +1472,18 @@ public class MemoryThresholdsDUnitTest extends ClientServerTestCase
{
     });
   }
 
+  private void registerLoggingTestMemoryThresholdListener(VM vm) {
+    vm.invoke(new SerializableCallable() {
+      public Object call() throws Exception {
+        TestMemoryThresholdListener listener = new TestMemoryThresholdListener(true);
+        InternalResourceManager irm = ((GemFireCacheImpl)getCache()).getResourceManager();
+        irm.addResourceListener(ResourceType.HEAP_MEMORY, listener);
+        assertTrue(irm.getResourceListeners(ResourceType.HEAP_MEMORY).contains(listener));
+        return null;
+      }
+    });
+  }
+
   /**
    * Verifies that the test listener value on the given vm is what is expected
    * Note that for remote events useWaitCriterion must be true

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/06509f34/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/control/TestMemoryThresholdListener.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/control/TestMemoryThresholdListener.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/control/TestMemoryThresholdListener.java
index ba1feb6..7dd596c 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/control/TestMemoryThresholdListener.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/control/TestMemoryThresholdListener.java
@@ -16,6 +16,8 @@
  */
 package com.gemstone.gemfire.internal.cache.control;
 
+import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
+
 
 public class TestMemoryThresholdListener implements ResourceListener<MemoryEvent>{
   private int normalCalls = 0;
@@ -26,6 +28,14 @@ public class TestMemoryThresholdListener implements ResourceListener<MemoryEvent
   private long bytesFromThreshold = 0;
   private int currentHeapPercentage = 0;
   private int allCalls = 0;
+  private final boolean logOnEventCalls;
+  
+  public TestMemoryThresholdListener() {
+    this(false);
+  }
+  public TestMemoryThresholdListener(boolean log) {
+    this.logOnEventCalls = log;
+  }
 
   public  long getBytesFromThreshold() {
     synchronized (this) {
@@ -100,6 +110,9 @@ public class TestMemoryThresholdListener implements ResourceListener<MemoryEvent
    */
   @Override
   public void onEvent(MemoryEvent event) {
+    if (this.logOnEventCalls) {
+      InternalDistributedSystem.getAnyInstance().getLogWriter().info("TestMemoryThresholdListener
onEvent " + event);
+    }
     synchronized (this) {
       if (event.getState().isNormal()) {
         this.normalCalls++;


Mime
View raw message