geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From upthewatersp...@apache.org
Subject incubator-geode git commit: GEODE-320: Close the cache in DistributedTestCase tear down
Date Wed, 09 Sep 2015 20:23:36 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-320 [created] 4ec5ea1bc


GEODE-320: Close the cache in DistributedTestCase tear down

Close the cache in distributed test case teardown to deal with bad
behaving tests that aren't cleaning up their cache.

Also, adding a log that shows us what tests ran previously to help debug
in situations where the progress file is not available.


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

Branch: refs/heads/feature/GEODE-320
Commit: 4ec5ea1bc0681ce1791d51fcdbfe9c545b6d9997
Parents: f770621
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Wed Sep 9 13:21:06 2015 -0700
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Wed Sep 9 13:21:06 2015 -0700

----------------------------------------------------------------------
 .../test/java/dunit/DistributedTestCase.java    | 23 ++++++++++++++++++++
 1 file changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4ec5ea1b/gemfire-core/src/test/java/dunit/DistributedTestCase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/dunit/DistributedTestCase.java b/gemfire-core/src/test/java/dunit/DistributedTestCase.java
index 2e7ac03..f680cf0 100755
--- a/gemfire-core/src/test/java/dunit/DistributedTestCase.java
+++ b/gemfire-core/src/test/java/dunit/DistributedTestCase.java
@@ -16,6 +16,7 @@ import java.text.DecimalFormat;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -24,6 +25,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
+import org.springframework.data.gemfire.support.GemfireCache;
 
 import junit.framework.TestCase;
 
@@ -92,6 +94,7 @@ import dunit.standalone.DUnitLauncher;
 public abstract class DistributedTestCase extends TestCase implements java.io.Serializable
{
   private static final Logger logger = LogService.getLogger();
   private static final LogWriterLogger oldLogger = LogWriterLogger.create(logger);
+  private static final LinkedHashSet<String> testHistory = new LinkedHashSet<String>();
 
   private static void setUpCreationStackGenerator() {
     // the following is moved from InternalDistributedSystem to fix #51058
@@ -672,6 +675,7 @@ public abstract class DistributedTestCase extends TestCase implements
java.io.Se
    */
   @Override
   public void setUp() throws Exception {
+    logTestHistory();
     setUpCreationStackGenerator();
     testName = getName();
     System.setProperty(HoplogConfig.ALLOW_LOCAL_HDFS_PROP, "true");
@@ -691,6 +695,16 @@ public abstract class DistributedTestCase extends TestCase implements
java.io.Se
     System.out.println("\n\n[setup] START TEST " + getClass().getSimpleName()+"."+testName+"\n\n");
   }
 
+  /**
+   * Write a message to the log about what tests have ran previously. This
+   * makes it easier to figure out if a previous test may have caused problems
+   */
+  private void logTestHistory() {
+    String classname = getClass().getSimpleName();
+    testHistory.add(classname);
+    System.out.println("Previously run tests: " + testHistory);
+  }
+
   public static void perVMSetUp(String name, String defaultDiskStoreName) {
     setTestName(name);
     GemFireCacheImpl.setDefaultDiskStoreName(defaultDiskStoreName);
@@ -767,6 +781,8 @@ public abstract class DistributedTestCase extends TestCase implements
java.io.Se
 
 
   private static void cleanupThisVM() {
+    closeCache();
+    
     IpAddress.resolve_dns = true;
     SocketCreator.resolve_dns = true;
     InitialImageOperation.slowImageProcessing = 0;
@@ -794,6 +810,13 @@ public abstract class DistributedTestCase extends TestCase implements
java.io.Se
       ex.remove();
     }
   }
+
+  private static void closeCache() {
+    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
+    if(cache != null && !cache.isClosed()) {
+      cache.close();
+    }
+  }
   
   public static void unregisterAllDataSerializersFromAllVms()
   {


Mime
View raw message