diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java index a686e3306a..1a8468fdf2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java @@ -346,6 +346,7 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility { htu.getConfiguration().set("fs.defaultFS","file:///"); htu.getConfiguration().set(HConstants.HBASE_DIR, "file://" + dataTestDir); LOG.debug("Setting " + HConstants.HBASE_DIR + " to " + dataTestDir); + htu.getConfiguration().setBoolean("hbase.unsafe.stream.capability.enforce",false); htu.localMode = true; return htu; } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactingMemStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactingMemStore.java index c0ba621008..6abe0cb115 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactingMemStore.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactingMemStore.java @@ -94,11 +94,13 @@ public class TestCompactingMemStore extends TestDefaultMemStore { protected void compactingSetUp() throws Exception { super.internalSetUp(); - Configuration conf = new Configuration(); + + HBaseTestingUtility hbaseUtility = HBaseTestingUtility.createLocalHTU(); + Configuration conf = hbaseUtility.getConfiguration(); + conf.setBoolean(MemStoreLAB.USEMSLAB_KEY, true); conf.setFloat(MemStoreLAB.CHUNK_POOL_MAXSIZE_KEY, 0.2f); conf.setInt(HRegion.MEMSTORE_PERIODIC_FLUSH_INTERVAL, 1000); - HBaseTestingUtility hbaseUtility = HBaseTestingUtility.createLocalHTU(conf); HColumnDescriptor hcd = new HColumnDescriptor(FAMILY); HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("foobar")); htd.addFamily(hcd); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java index b89fb0e194..d20a3171a9 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java @@ -92,6 +92,9 @@ public class TestDefaultMemStore { return this.name.getMethodName(); } + private HBaseTestingUtility util; + private Configuration conf; + @Before public void setUp() throws Exception { internalSetUp(); @@ -107,6 +110,8 @@ public class TestDefaultMemStore { } protected void internalSetUp() throws Exception { + this.util = HBaseTestingUtility.createLocalHTU(); + this.conf = util.getConfiguration(); this.mvcc = new MultiVersionConcurrencyControl(); } @@ -162,7 +167,6 @@ public class TestDefaultMemStore { List memstorescanners = this.memstore.getScanners(0); Scan scan = new Scan(); List result = new ArrayList<>(); - Configuration conf = HBaseConfiguration.create(); ScanInfo scanInfo = new ScanInfo(conf, null, 0, 1, HConstants.LATEST_TIMESTAMP, KeepDeletedCells.FALSE, HConstants.DEFAULT_BLOCKSIZE, 0, this.memstore.getComparator(), false); int count = 0; @@ -536,7 +540,7 @@ public class TestDefaultMemStore { @Test public void testMultipleVersionsSimple() throws Exception { - DefaultMemStore m = new DefaultMemStore(new Configuration(), CellComparatorImpl.COMPARATOR); + DefaultMemStore m = new DefaultMemStore(conf, CellComparatorImpl.COMPARATOR); byte [] row = Bytes.toBytes("testRow"); byte [] family = Bytes.toBytes("testFamily"); byte [] qf = Bytes.toBytes("testQualifier"); @@ -582,7 +586,6 @@ public class TestDefaultMemStore { } } //starting from each row, validate results should contain the starting row - Configuration conf = HBaseConfiguration.create(); for (int startRowId = 0; startRowId < ROW_COUNT; startRowId++) { ScanInfo scanInfo = new ScanInfo(conf, FAMILY, 0, 1, Integer.MAX_VALUE, KeepDeletedCells.FALSE, @@ -818,7 +821,6 @@ public class TestDefaultMemStore { */ @Test public void testUpsertMemstoreSize() throws Exception { - Configuration conf = HBaseConfiguration.create(); memstore = new DefaultMemStore(conf, CellComparatorImpl.COMPARATOR); MemStoreSize oldSize = memstore.size(); @@ -901,7 +903,6 @@ public class TestDefaultMemStore { */ @Test public void testShouldFlush() throws Exception { - Configuration conf = new Configuration(); conf.setInt(HRegion.MEMSTORE_PERIODIC_FLUSH_INTERVAL, 1000); checkShouldFlush(conf, true); // test disable flush @@ -913,10 +914,8 @@ public class TestDefaultMemStore { try { EnvironmentEdgeForMemstoreTest edge = new EnvironmentEdgeForMemstoreTest(); EnvironmentEdgeManager.injectEdge(edge); - HBaseTestingUtility hbaseUtility = HBaseTestingUtility.createLocalHTU(conf); String cf = "foo"; - HRegion region = - hbaseUtility.createTestRegion("foobar", ColumnFamilyDescriptorBuilder.of(cf)); + HRegion region = util.createTestRegion("foobar", ColumnFamilyDescriptorBuilder.of(cf)); edge.setCurrentTimeMillis(1234); Put p = new Put(Bytes.toBytes("r")); @@ -937,10 +936,8 @@ public class TestDefaultMemStore { // write an edit in the META and ensure the shouldFlush (that the periodic memstore // flusher invokes) returns true after SYSTEM_CACHE_FLUSH_INTERVAL (even though // the MEMSTORE_PERIODIC_FLUSH_INTERVAL is set to a higher value) - Configuration conf = new Configuration(); conf.setInt(HRegion.MEMSTORE_PERIODIC_FLUSH_INTERVAL, HRegion.SYSTEM_CACHE_FLUSH_INTERVAL * 10); - HBaseTestingUtility hbaseUtility = HBaseTestingUtility.createLocalHTU(conf); - Path testDir = hbaseUtility.getDataTestDir(); + Path testDir = util.getDataTestDir(); EnvironmentEdgeForMemstoreTest edge = new EnvironmentEdgeForMemstoreTest(); EnvironmentEdgeManager.injectEdge(edge); edge.setCurrentTimeMillis(1234); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java index b8d3ec7a59..2e7e3b5af7 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java @@ -146,7 +146,7 @@ public class TestHStore { long id = System.currentTimeMillis(); Get get = new Get(row); - private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); + private static final HBaseTestingUtility TEST_UTIL = HBaseTestingUtility.createLocalHTU(); private static final String DIR = TEST_UTIL.getDataTestDir("TestStore").toString(); @@ -234,7 +234,7 @@ public class TestHStore { public void testFlushSizeSizing() throws Exception { LOG.info("Setting up a faulty file system that cannot write in " + this.name.getMethodName()); - final Configuration conf = HBaseConfiguration.create(); + final Configuration conf = HBaseConfiguration.create(TEST_UTIL.getConfiguration()); // Only retry once. conf.setInt("hbase.hstore.flush.retries.number", 1); User user = User.createUserForTesting(conf, this.name.getMethodName(), @@ -661,7 +661,7 @@ public class TestHStore { public void testHandleErrorsInFlush() throws Exception { LOG.info("Setting up a faulty file system that cannot write"); - final Configuration conf = HBaseConfiguration.create(); + final Configuration conf = HBaseConfiguration.create(TEST_UTIL.getConfiguration()); User user = User.createUserForTesting(conf, "testhandleerrorsinflush", new String[]{"foo"}); // Inject our faulty LocalFileSystem diff --git a/hbase-server/src/test/resources/hbase-site.xml b/hbase-server/src/test/resources/hbase-site.xml index dbdf7765d7..64a1964435 100644 --- a/hbase-server/src/test/resources/hbase-site.xml +++ b/hbase-server/src/test/resources/hbase-site.xml @@ -158,13 +158,4 @@ hbase.hconnection.threads.keepalivetime 3 - - hbase.unsafe.stream.capability.enforce - false - - Controls whether HBase will check for stream capabilities (hflush/hsync). - Disable this if you intend to run on LocalFileSystem. - WARNING: Doing so may expose you to additional risk of data loss! - -