Repository: hbase
Updated Branches:
  refs/heads/master ed977fd12 -> 0f14856b0


HBASE-15416 TestHFileBackedByBucketCache is flakey since it went in


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/0f14856b
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/0f14856b
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/0f14856b

Branch: refs/heads/master
Commit: 0f14856b01ed14eca9b1cd91087d85732b3ad2d3
Parents: ed977fd
Author: stack <[email protected]>
Authored: Mon Mar 7 16:31:09 2016 -0800
Committer: stack <[email protected]>
Committed: Mon Mar 7 16:31:09 2016 -0800

----------------------------------------------------------------------
 .../hbase/io/hfile/TestHFileBackedByBucketCache.java  | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/0f14856b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileBackedByBucketCache.java
----------------------------------------------------------------------
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 5c2e7d6..2759078 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<Cell> writtenCells = writeFile(hfilePath, Compression.Algorithm.NONE, 
cacheConfig, count);
     CacheStats stats = cacheConfig.getBlockCache().getStats();
     List<Cell> readCells = readFile(hfilePath, cacheConfig);

Reply via email to