diff --git hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCacheOnWriteInSchema.java hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCacheOnWriteInSchema.java index 1fb16cd..b080b71 100644 --- hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCacheOnWriteInSchema.java +++ hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCacheOnWriteInSchema.java @@ -53,7 +53,6 @@ import org.apache.hadoop.hbase.regionserver.StoreFile.BloomType; import org.apache.hadoop.hbase.regionserver.wal.HLog; import org.apache.hadoop.hbase.regionserver.wal.HLogFactory; import org.apache.hadoop.hbase.util.Bytes; - import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -64,7 +63,7 @@ import org.junit.runners.Parameterized.Parameters; /** * Tests {@link HFile} cache-on-write functionality for data blocks, non-root - * index blocks, and Bloom filter blocks, as specified by the column family. + * index blocks, and Bloom filter blocks, as specified by the column family. */ @RunWith(Parameterized.class) @Category(MediumTests.class) @@ -121,7 +120,9 @@ public class TestCacheOnWriteInSchema { private final CacheOnWriteType cowType; private Configuration conf; private final String testDescription; + private HRegion region; private HStore store; + private HLog hlog; private FileSystem fs; public TestCacheOnWriteInSchema(CacheOnWriteType cowType) { @@ -163,14 +164,16 @@ public class TestCacheOnWriteInSchema { fs.delete(logdir, true); HRegionInfo info = new HRegionInfo(htd.getName(), null, null, false); - HLog hlog = HLogFactory.createHLog(fs, basedir, logName, conf); + hlog = HLogFactory.createHLog(fs, basedir, logName, conf); - HRegion region = new HRegion(basedir, hlog, fs, conf, info, htd, null); + region = new HRegion(basedir, hlog, fs, conf, info, htd, null); store = new HStore(basedir, region, hcd, fs, conf); } @After - public void tearDown() { + public void tearDown() throws IOException { + region.close(); + hlog.close(); try { fs.delete(new Path(DIR), true); } catch (IOException e) { @@ -190,7 +193,7 @@ public class TestCacheOnWriteInSchema { } private void readStoreFile(Path path) throws IOException { - CacheConfig cacheConf = store.getCacheConfig(); + CacheConfig cacheConf = store.getCacheConfig(); BlockCache cache = cacheConf.getBlockCache(); StoreFile sf = new StoreFile(fs, path, conf, cacheConf, BloomType.ROWCOL, null); diff --git hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactSelection.java hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactSelection.java index 4a26f21..6bab9d2 100644 --- hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactSelection.java +++ hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactSelection.java @@ -40,6 +40,7 @@ import org.apache.hadoop.hbase.regionserver.wal.HLog; import org.apache.hadoop.hbase.regionserver.wal.HLogFactory; import org.apache.hadoop.hbase.util.Bytes; +import org.junit.After; import com.google.common.collect.Lists; import org.junit.experimental.categories.Category; @@ -60,6 +61,8 @@ public class TestCompactSelection extends TestCase { private static final long minSize = 10; private static final long maxSize = 1000; + private HLog hlog; + private HRegion region; @Override public void setUp() throws Exception { @@ -86,9 +89,9 @@ public class TestCompactSelection extends TestCase { htd.addFamily(hcd); HRegionInfo info = new HRegionInfo(htd.getName(), null, null, false); - HLog hlog = HLogFactory.createHLog(fs, basedir, + hlog = HLogFactory.createHLog(fs, basedir, logName, conf); - HRegion region = HRegion.createHRegion(info, basedir, conf, htd); + region = HRegion.createHRegion(info, basedir, conf, htd); HRegion.closeHRegion(region); Path tableDir = new Path(basedir, Bytes.toString(htd.getName())); region = new HRegion(tableDir, hlog, fs, conf, info, htd, null); @@ -98,6 +101,12 @@ public class TestCompactSelection extends TestCase { fs.create(TEST_FILE); } + @After + public void tearDown() throws IOException { + region.close(); + hlog.closeAndDelete(); + } + // used so our tests don't deal with actual StoreFiles static class MockStoreFile extends StoreFile { long length = 0; @@ -158,13 +167,13 @@ public class TestCompactSelection extends TestCase { } return aNums; } - - void compactEquals(List candidates, long ... expected) + + void compactEquals(List candidates, long ... expected) throws IOException { compactEquals(candidates, false, expected); } - void compactEquals(List candidates, boolean forcemajor, + void compactEquals(List candidates, boolean forcemajor, long ... expected) throws IOException { store.forceMajor = forcemajor; @@ -191,7 +200,7 @@ public class TestCompactSelection extends TestCase { compactEquals(sfCreate(tooBig, tooBig, 700,700) /* empty */); // small files = don't care about ratio compactEquals(sfCreate(8,3,1), 8,3,1); - /* TODO: add sorting + unit test back in when HBASE-2856 is fixed + /* TODO: add sorting + unit test back in when HBASE-2856 is fixed // sort first so you don't include huge file the tail end // happens with HFileOutputFormat bulk migration compactEquals(sfCreate(100,50,23,12,12, 500), 23, 12, 12); @@ -201,7 +210,7 @@ public class TestCompactSelection extends TestCase { store.compactSelection(sfCreate(7,6,5,4,3,2,1)).getFilesToCompact().size()); // note: file selection starts with largest to smallest. compactEquals(sfCreate(7, 6, 5, 4, 3, 2, 1), 7, 6, 5, 4, 3); - + /* MAJOR COMPACTION */ // if a major compaction has been forced, then compact everything compactEquals(sfCreate(50,25,12,12), true, 50, 25, 12, 12); @@ -240,7 +249,7 @@ public class TestCompactSelection extends TestCase { store.compactSelection(sfCreate(true, 7,6,5,4,3,2,1)).getFilesToCompact().size()); // reference compaction compactEquals(sfCreate(true, 7, 6, 5, 4, 3, 2, 1), 5, 4, 3, 2, 1); - + // empty case compactEquals(new ArrayList() /* empty */); // empty case (because all files are too big)