From 0f14856b01ed14eca9b1cd91087d85732b3ad2d3 Mon Sep 17 00:00:00 2001 From: stack Date: Mon, 7 Mar 2016 16:31:09 -0800 Subject: [PATCH] HBASE-15416 TestHFileBackedByBucketCache is flakey since it went in --- .../io/hfile/TestHFileBackedByBucketCache.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileBackedByBucketCache.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileBackedByBucketCache.java index 5c2e7d607ee..2759078d94a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileBackedByBucketCache.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileBackedByBucketCache.java @@ -42,7 +42,7 @@ import org.apache.hadoop.hbase.io.compress.Compression; import org.apache.hadoop.hbase.io.hfile.bucket.BucketAllocator; import org.apache.hadoop.hbase.io.hfile.bucket.BucketCache; import org.apache.hadoop.hbase.testclassification.IOTests; -import org.apache.hadoop.hbase.testclassification.SmallTests; +import org.apache.hadoop.hbase.testclassification.LargeTests; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -53,7 +53,10 @@ import org.junit.rules.TestRule; /** * Test for file-backed BucketCache. */ -@Category({IOTests.class, SmallTests.class}) +// This is marked a LargeTest so it runs in its own JVM. We do this because we are making use of +// the cache and the cache is global. We don't want any other concurrent test polluting ours which +// can happen if more than one test in a single JVM which can happen when tests are small. +@Category({IOTests.class, LargeTests.class}) public class TestHFileBackedByBucketCache { private static final Log LOG = LogFactory.getLog(TestHFileBackedByBucketCache.class); @Rule public TestName name = new TestName(); @@ -134,11 +137,14 @@ public class TestHFileBackedByBucketCache { this.conf.setStrings("hbase.bucketcache.bucket.sizes", Integer.toString(BUCKETSIZE)); // This is minimum bucketcache size.... 1MB. this.conf.setInt("hbase.bucketcache.size", 1); - CacheConfig cacheConfig = new CacheConfig(conf); - Path hfilePath = new Path(TEST_UTIL.getDataTestDir(), this.name.getMethodName()); // Write 8 entries which should make for four hfileBlocks. final int count = 8; final int hfileBlockCount = 4; + Path hfilePath = new Path(TEST_UTIL.getDataTestDir(), this.name.getMethodName()); + // Clear out any existing global cache instance. Will pollute our tests below. Any concurrent + // running test will pollute our results below. + CacheConfig.GLOBAL_BLOCK_CACHE_INSTANCE = null; + CacheConfig cacheConfig = new CacheConfig(conf); List writtenCells = writeFile(hfilePath, Compression.Algorithm.NONE, cacheConfig, count); CacheStats stats = cacheConfig.getBlockCache().getStats(); List readCells = readFile(hfilePath, cacheConfig);