diff --git hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStripeStoreFileManager.java hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStripeStoreFileManager.java index 0fdf5d8..ed5eb74 100644 --- hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStripeStoreFileManager.java +++ hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStripeStoreFileManager.java @@ -18,6 +18,13 @@ */ package org.apache.hadoop.hbase.regionserver; +import static org.apache.hadoop.hbase.regionserver.StripeStoreFileManager.OPEN_KEY; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -26,9 +33,6 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -import static org.junit.Assert.*; -import static org.apache.hadoop.hbase.regionserver.StripeStoreFileManager.OPEN_KEY; - import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; @@ -63,6 +67,8 @@ public class TestStripeStoreFileManager { private static final KeyValue KV_C = new KeyValue(KEY_C, 0L); private static final KeyValue KV_D = new KeyValue(KEY_D, 0L); + private StripeStoreFileManager manager = null; + @Before public void setUp() throws Exception { FileSystem fs = TEST_UTIL.getTestFileSystem(); @@ -73,6 +79,13 @@ public class TestStripeStoreFileManager { @After public void tearDown() throws Exception { + if (manager != null) { + for(StoreFile sf : manager.getStorefiles()) { + sf.closeReader(false); + } + manager = null; + } + FileSystem fs = TEST_UTIL.getTestFileSystem(); if (fs.exists(CFDIR) && !fs.delete(CFDIR, true)) { throw new IOException("Cannot delete test directory " + CFDIR); @@ -81,7 +94,7 @@ public class TestStripeStoreFileManager { @Test public void testInsertFilesIntoL0() throws Exception { - StripeStoreFileManager manager = createManager(); + manager = createManager(); MockStoreFile sf = createFile(); manager.insertNewFiles(al(sf)); assertEquals(1, manager.getStorefileCount()); @@ -551,7 +564,7 @@ public class TestStripeStoreFileManager { long size, long seqNum, byte[] startKey, byte[] endKey) throws Exception { FileSystem fs = TEST_UTIL.getTestFileSystem(); Path testFilePath = StoreFile.getUniqueFile(fs, CFDIR); - fs.create(testFilePath); + fs.create(testFilePath).close(); MockStoreFile sf = new MockStoreFile(TEST_UTIL, testFilePath, size, 0, false, seqNum); if (startKey != null) { sf.setMetadataValue(StripeStoreFileManager.STRIPE_START_KEY, startKey);