From 5723603987ba018ee62a9f813854d046ed0a253f Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Fri, 28 Feb 2014 20:56:14 +0100 Subject: [PATCH] Prevent page-tracking checks from spreading across tests. --- .../elasticsearch/cache/recycler/MockPageCacheRecycler.java | 5 ++++- .../java/org/elasticsearch/test/ElasticsearchTestCase.java | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/elasticsearch/cache/recycler/MockPageCacheRecycler.java b/src/test/java/org/elasticsearch/cache/recycler/MockPageCacheRecycler.java index 15716656123..f3904800c83 100644 --- a/src/test/java/org/elasticsearch/cache/recycler/MockPageCacheRecycler.java +++ b/src/test/java/org/elasticsearch/cache/recycler/MockPageCacheRecycler.java @@ -35,12 +35,15 @@ public class MockPageCacheRecycler extends PageCacheRecycler { private static final ConcurrentMap ACQUIRED_PAGES = Maps.newConcurrentMap(); + public static void reset() { + ACQUIRED_PAGES.clear(); + } + public static void ensureAllPagesAreReleased() { if (ACQUIRED_PAGES.size() > 0) { final Throwable t = ACQUIRED_PAGES.entrySet().iterator().next().getValue(); throw new RuntimeException(ACQUIRED_PAGES.size() + " pages have not been released", t); } - ACQUIRED_PAGES.clear(); } private final Random random; diff --git a/src/test/java/org/elasticsearch/test/ElasticsearchTestCase.java b/src/test/java/org/elasticsearch/test/ElasticsearchTestCase.java index 895c17b621e..5e496ba0565 100644 --- a/src/test/java/org/elasticsearch/test/ElasticsearchTestCase.java +++ b/src/test/java/org/elasticsearch/test/ElasticsearchTestCase.java @@ -122,6 +122,11 @@ public abstract class ElasticsearchTestCase extends AbstractRandomizedTest { return new File(uri); } + @Before + public void resetPageTracking() { + MockPageCacheRecycler.reset(); + } + @After public void ensureAllPagesReleased() { MockPageCacheRecycler.ensureAllPagesAreReleased();