Repository: incubator-geode Updated Branches: refs/heads/feature/GEODE-320 4ec5ea1bc -> e98073dd3
Destroying regions in DistributedTestCase.tearDown My previous commit closed the cache, but it didn't destroy the regions first. That left persistent regions lying around. It looks like there were some tests that actually were calling cleanup directly and got stuck because it didn't clean up the persistent files. I also found that RegionTestCase was previously not cleaning up the cache at all, so I added a missing call to super.tearDown. Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/e98073dd Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/e98073dd Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/e98073dd Branch: refs/heads/feature/GEODE-320 Commit: e98073dd32c7733a6d8b93e44b03ae06be922407 Parents: 4ec5ea1 Author: Dan Smith <[email protected]> Authored: Thu Sep 10 10:19:05 2015 -0700 Committer: Dan Smith <[email protected]> Committed: Thu Sep 10 10:19:05 2015 -0700 ---------------------------------------------------------------------- .../gemstone/gemfire/cache30/CacheTestCase.java | 27 ++-------------- .../gemfire/cache30/RegionTestCase.java | 1 + .../test/java/dunit/DistributedTestCase.java | 33 ++++++++++++++++++++ 3 files changed, 37 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e98073dd/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/CacheTestCase.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/CacheTestCase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/CacheTestCase.java index e318370..951c985 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/CacheTestCase.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/CacheTestCase.java @@ -16,6 +16,7 @@ import java.util.Iterator; import java.util.Map; import java.util.Properties; +import com.gemstone.gemfire.InternalGemFireError; import com.gemstone.gemfire.SystemFailure; import com.gemstone.gemfire.cache.AttributesFactory; import com.gemstone.gemfire.cache.Cache; @@ -453,29 +454,7 @@ public abstract class CacheTestCase extends DistributedTestCase { protected synchronized static void remoteTearDown() { try { DistributionMessageObserver.setInstance(null); - if (cache != null && !cache.isClosed()) { - //try to destroy the root regions first so that - //we clean up any persistent files. - for (Iterator itr = cache.rootRegions().iterator(); itr.hasNext();) { - Region root = (Region)itr.next(); -// String name = root.getName(); - //for colocated regions you can't locally destroy a partitioned - //region. - if(root.isDestroyed() || root instanceof HARegion || root instanceof PartitionedRegion) { - continue; - } - try { - root.localDestroyRegion("teardown"); - } - catch (VirtualMachineError e) { - SystemFailure.initiateFailure(e); - throw e; - } - catch (Throwable t) { - getLogWriter().error(t); - } - } - } + destroyRegions(cache); } finally { try { @@ -497,7 +476,7 @@ public abstract class CacheTestCase extends DistributedTestCase { getLogWriter().error("Error cleaning disk dirs", e); } } - + /** * Returns a region with the given name and attributes */ http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e98073dd/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/RegionTestCase.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/RegionTestCase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/RegionTestCase.java index 4b20b42..81c8afb 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/RegionTestCase.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/RegionTestCase.java @@ -102,6 +102,7 @@ public abstract class RegionTestCase extends CacheTestCase { } public void tearDown2() throws Exception { + super.tearDown2(); cleanup(); invokeInEveryVM(getClass(), "cleanup"); /*for (int h = 0; h < Host.getHostCount(); h++) { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e98073dd/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 f680cf0..c78510a 100755 --- a/gemfire-core/src/test/java/dunit/DistributedTestCase.java +++ b/gemfire-core/src/test/java/dunit/DistributedTestCase.java @@ -29,10 +29,13 @@ import org.springframework.data.gemfire.support.GemfireCache; import junit.framework.TestCase; +import com.gemstone.gemfire.InternalGemFireError; import com.gemstone.gemfire.LogWriter; +import com.gemstone.gemfire.SystemFailure; import com.gemstone.gemfire.admin.internal.AdminDistributedSystemImpl; import com.gemstone.gemfire.cache.Cache; import com.gemstone.gemfire.cache.DiskStoreFactory; +import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.hdfs.internal.HDFSStoreImpl; import com.gemstone.gemfire.cache.hdfs.internal.hoplog.HoplogConfig; import com.gemstone.gemfire.cache.query.QueryTestUtils; @@ -56,8 +59,10 @@ import com.gemstone.gemfire.internal.SocketCreator; import com.gemstone.gemfire.internal.admin.ClientStatsManager; import com.gemstone.gemfire.internal.cache.DiskStoreObserver; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; +import com.gemstone.gemfire.internal.cache.HARegion; import com.gemstone.gemfire.internal.cache.InitialImageOperation; import com.gemstone.gemfire.internal.cache.LocalRegion; +import com.gemstone.gemfire.internal.cache.PartitionedRegion; import com.gemstone.gemfire.internal.cache.tier.InternalBridgeMembership; import com.gemstone.gemfire.internal.cache.tier.sockets.CacheServerTestUtil; import com.gemstone.gemfire.internal.cache.tier.sockets.ClientProxyMembershipID; @@ -814,10 +819,38 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se private static void closeCache() { GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); if(cache != null && !cache.isClosed()) { + destroyRegions(cache); cache.close(); } } + protected static final void destroyRegions(Cache cache) + throws InternalGemFireError, Error, VirtualMachineError { + if (cache != null && !cache.isClosed()) { + //try to destroy the root regions first so that + //we clean up any persistent files. + for (Iterator itr = cache.rootRegions().iterator(); itr.hasNext();) { + Region root = (Region)itr.next(); + //for colocated regions you can't locally destroy a partitioned + //region. + if(root.isDestroyed() || root instanceof HARegion || root instanceof PartitionedRegion) { + continue; + } + try { + root.localDestroyRegion("teardown"); + } + catch (VirtualMachineError e) { + SystemFailure.initiateFailure(e); + throw e; + } + catch (Throwable t) { + getLogWriter().error(t); + } + } + } + } + + public static void unregisterAllDataSerializersFromAllVms() { unregisterDataSerializerInThisVM();
