Return-Path: X-Original-To: apmail-geode-commits-archive@minotaur.apache.org Delivered-To: apmail-geode-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A40C918146 for ; Thu, 1 Oct 2015 17:58:55 +0000 (UTC) Received: (qmail 89979 invoked by uid 500); 1 Oct 2015 17:58:55 -0000 Delivered-To: apmail-geode-commits-archive@geode.apache.org Received: (qmail 89948 invoked by uid 500); 1 Oct 2015 17:58:55 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 89939 invoked by uid 99); 1 Oct 2015 17:58:55 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Oct 2015 17:58:55 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 1D2AB180970 for ; Thu, 1 Oct 2015 17:58:55 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.775 X-Spam-Level: * X-Spam-Status: No, score=1.775 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.006, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id josFna4TKsL3 for ; Thu, 1 Oct 2015 17:58:52 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with SMTP id 0D9F425871 for ; Thu, 1 Oct 2015 17:58:45 +0000 (UTC) Received: (qmail 88717 invoked by uid 99); 1 Oct 2015 17:58:43 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Oct 2015 17:58:43 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0A832E1556; Thu, 1 Oct 2015 17:58:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bschuchardt@apache.org To: commits@geode.incubator.apache.org Date: Thu, 01 Oct 2015 17:58:52 -0000 Message-Id: <89e62a035b4c488bbe7b815346543cd8@git.apache.org> In-Reply-To: <070f51564de9483d9980d8592b4efdd4@git.apache.org> References: <070f51564de9483d9980d8592b4efdd4@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [11/26] incubator-geode git commit: GEODE-320: Close the cache in DistributedTestCase tear down 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. Adding a log that shows us what tests ran previously to help debug in situations where the progress file is not available. 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/4e65f0c7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/4e65f0c7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/4e65f0c7 Branch: refs/heads/feature/GEODE-77 Commit: 4e65f0c72d30ca24c582543a62dc72b064e9d448 Parents: 391a93d Author: Dan Smith Authored: Wed Sep 9 13:21:06 2015 -0700 Committer: Dan Smith Committed: Mon Sep 14 13:54:27 2015 -0700 ---------------------------------------------------------------------- .../gemstone/gemfire/cache30/CacheTestCase.java | 27 ++-------- .../gemfire/cache30/RegionTestCase.java | 1 + .../test/java/dunit/DistributedTestCase.java | 56 ++++++++++++++++++++ 3 files changed, 60 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4e65f0c7/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/4e65f0c7/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/4e65f0c7/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..c78510a 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,13 +25,17 @@ 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; +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; @@ -54,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; @@ -92,6 +99,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 testHistory = new LinkedHashSet(); private static void setUpCreationStackGenerator() { // the following is moved from InternalDistributedSystem to fix #51058 @@ -672,6 +680,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 +700,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 +786,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 +815,41 @@ 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()) { + 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() {