diff --git src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java index 9332e89..868e8cf 100644 --- src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java +++ src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java @@ -1420,6 +1420,9 @@ public class HBaseTestingUtility { */ public void startMiniMapReduceCluster(final int servers) throws IOException { LOG.info("Starting mini mapreduce cluster..."); + if (dataTestDir == null) { + setupDataTestDir(); + } // These are needed for the new and improved Map/Reduce framework Configuration c = getConfiguration(); String logDir = c.get("hadoop.log.dir"); @@ -1434,8 +1437,10 @@ public class HBaseTestingUtility { // we up the VM usable so that processes don't get killed. conf.setFloat("yarn.nodemanager.vmem-pmem-ratio", 8.0f); - mrCluster = new MiniMRCluster(servers, - FileSystem.get(conf).getUri().toString(), 1); + mrCluster = new MiniMRCluster(0, 0, servers, + FileSystem.get(conf).getUri().toString(), 1, null, null, null, new JobConf(conf)); + mrCluster.getJobTrackerRunner().getJobTracker().getConf().set("mapred.local.dir", + conf.get("mapred.local.dir")); //Hadoop MiniMR overwrites this while it should not LOG.info("Mini mapreduce cluster started"); JobConf mrClusterJobConf = mrCluster.createJobConf(); c.set("mapred.job.tracker", mrClusterJobConf.get("mapred.job.tracker")); diff --git src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorInterface.java src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorInterface.java index 88becfc..c03be92 100644 --- src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorInterface.java +++ src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorInterface.java @@ -20,6 +20,8 @@ package org.apache.hadoop.hbase.coprocessor; +import static org.mockito.Mockito.when; + import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -45,14 +47,12 @@ import org.apache.hadoop.hbase.util.PairOfSameType; import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import static org.mockito.Mockito.when; - @Category(SmallTests.class) public class TestCoprocessorInterface extends HBaseTestCase { static final Log LOG = LogFactory.getLog(TestCoprocessorInterface.class); - static final String DIR = "test/build/data/TestCoprocessorInterface/"; private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); + static final Path DIR = TEST_UTIL.getDataTestDir(); private static class CustomScanner implements RegionScanner { @@ -66,9 +66,9 @@ public class TestCoprocessorInterface extends HBaseTestCase { public boolean next(List results) throws IOException { return delegate.next(results); } - + @Override - public boolean next(List results, String metric) + public boolean next(List results, String metric) throws IOException { return delegate.next(results, metric); } @@ -77,9 +77,9 @@ public class TestCoprocessorInterface extends HBaseTestCase { public boolean next(List result, int limit) throws IOException { return delegate.next(result, limit); } - + @Override - public boolean next(List result, int limit, String metric) + public boolean next(List result, int limit, String metric) throws IOException { return delegate.next(result, limit, metric); } diff --git src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverInterface.java src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverInterface.java index bba0365..9d8f0fc 100644 --- src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverInterface.java +++ src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverInterface.java @@ -20,6 +20,11 @@ package org.apache.hadoop.hbase.coprocessor; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.io.IOException; import java.lang.reflect.Method; import java.util.ArrayList; @@ -44,18 +49,14 @@ import org.apache.hadoop.hbase.regionserver.StoreFile; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.JVMClusterUtil; - import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; -import static org.junit.Assert.*; - @Category(MediumTests.class) public class TestRegionObserverInterface { static final Log LOG = LogFactory.getLog(TestRegionObserverInterface.class); - static final String DIR = "test/build/data/TestRegionObserver/"; public static final byte[] TEST_TABLE = Bytes.toBytes("TestTable"); public final static byte[] A = Bytes.toBytes("a"); @@ -304,21 +305,21 @@ public class TestRegionObserverInterface { public boolean next(List results) throws IOException { return next(results, -1); } - + @Override - public boolean next(List results, String metric) + public boolean next(List results, String metric) throws IOException { return next(results, -1, metric); } @Override - public boolean next(List results, int limit) + public boolean next(List results, int limit) throws IOException{ return next(results, limit, null); } @Override - public boolean next(List results, int limit, String metric) + public boolean next(List results, int limit, String metric) throws IOException { List internalResults = new ArrayList(); boolean hasMore; diff --git src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverStacking.java src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverStacking.java index 002d611..ffa5de4 100644 --- src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverStacking.java +++ src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverStacking.java @@ -21,24 +21,30 @@ package org.apache.hadoop.hbase.coprocessor; import java.io.IOException; -import java.util.List; -import java.util.Map; + +import junit.framework.TestCase; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.*; +import org.apache.hadoop.hbase.Coprocessor; +import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hbase.HColumnDescriptor; +import org.apache.hadoop.hbase.HRegionInfo; +import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.SmallTests; import org.apache.hadoop.hbase.client.Put; +import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost; import org.apache.hadoop.hbase.regionserver.wal.WALEdit; -import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hbase.util.Bytes; - -import junit.framework.TestCase; import org.junit.experimental.categories.Category; @Category(SmallTests.class) public class TestRegionObserverStacking extends TestCase { - static final String DIR = "test/build/data/TestRegionObserverStacking/"; + private static HBaseTestingUtility TEST_UTIL + = new HBaseTestingUtility(); + static final Path DIR = TEST_UTIL.getDataTestDir(); public static class ObserverA extends BaseRegionObserver { long id; diff --git src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java index 5bf8bbd..2bf0c1b 100644 --- src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java +++ src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java @@ -275,7 +275,7 @@ public class TestHFileOutputFormat { // verify that the file has the proper FileInfo. writer.close(context); - // the generated file lives 1 directory down from the attempt directory + // the generated file lives 1 directory down from the attempt directory // and is the only file, e.g. // _attempt__0000_r_000000_0/b/1979617994050536795 FileSystem fs = FileSystem.get(conf); @@ -344,7 +344,8 @@ public class TestHFileOutputFormat { @Test public void testJobConfiguration() throws Exception { - Job job = new Job(); + Job job = new Job(util.getConfiguration()); + job.setWorkingDirectory(util.getDataTestDir("testJobConfiguration")); HTable table = Mockito.mock(HTable.class); setupMockStartKeys(table); HFileOutputFormat.configureIncrementalLoad(job, table); @@ -469,6 +470,7 @@ public class TestHFileOutputFormat { Configuration conf, HTable table, Path outDir) throws Exception { Job job = new Job(conf, "testLocalMRIncrementalLoad"); + job.setWorkingDirectory(util.getDataTestDir("runIncrementalPELoad")); setupRandomGeneratorMapper(job); HFileOutputFormat.configureIncrementalLoad(job, table); FileOutputFormat.setOutputPath(job, outDir); @@ -583,6 +585,7 @@ public class TestHFileOutputFormat { // pollutes the GZip codec pool with an incompatible compressor. conf.set("io.seqfile.compression.type", "NONE"); Job job = new Job(conf, "testLocalMRIncrementalLoad"); + job.setWorkingDirectory(util.getDataTestDir("testColumnFamilyCompression")); setupRandomGeneratorMapper(job); HFileOutputFormat.configureIncrementalLoad(job, table); FileOutputFormat.setOutputPath(job, dir); diff --git src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java index 6dfba41..1753875 100644 --- src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java +++ src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java @@ -21,16 +21,13 @@ package org.apache.hadoop.hbase.regionserver; 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 org.apache.hadoop.hbase.*; +import org.apache.hadoop.hbase.HRegionInfo; +import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.SmallTests; import org.apache.hadoop.hbase.util.Bytes; -import org.apache.hadoop.hbase.util.FSTableDescriptors; -import org.apache.hadoop.hbase.util.FSUtils; import org.apache.hadoop.hbase.util.MD5Hash; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -60,32 +57,7 @@ public class TestHRegionInfo { + id + "." + md5HashInHex + ".", nameStr); } - - @Test - public void testGetSetOfHTD() throws IOException { - HBaseTestingUtility HTU = new HBaseTestingUtility(); - final String tablename = "testGetSetOfHTD"; - - // Delete the temporary table directory that might still be there from the - // previous test run. - FSTableDescriptors.deleteTableDescriptorIfExists(tablename, - HTU.getConfiguration()); - HTableDescriptor htd = new HTableDescriptor(tablename); - FSTableDescriptors.createTableDescriptor(htd, HTU.getConfiguration()); - HRegionInfo hri = new HRegionInfo(Bytes.toBytes("testGetSetOfHTD"), - HConstants.EMPTY_START_ROW, HConstants.EMPTY_END_ROW); - HTableDescriptor htd2 = hri.getTableDesc(); - assertTrue(htd.equals(htd2)); - final String key = "SOME_KEY"; - assertNull(htd.getValue(key)); - final String value = "VALUE"; - htd.setValue(key, value); - hri.setTableDesc(htd); - HTableDescriptor htd3 = hri.getTableDesc(); - assertTrue(htd.equals(htd3)); - } - @Test public void testContainsRange() { HTableDescriptor tableDesc = new HTableDescriptor("testtable"); @@ -105,7 +77,7 @@ public class TestHRegionInfo { assertFalse(hri.containsRange(Bytes.toBytes("g"), Bytes.toBytes("g"))); // Single row range entirely outside assertFalse(hri.containsRange(Bytes.toBytes("z"), Bytes.toBytes("z"))); - + // Degenerate range try { hri.containsRange(Bytes.toBytes("z"), Bytes.toBytes("a")); @@ -134,14 +106,14 @@ public class TestHRegionInfo { public void testComparator() { byte[] tablename = Bytes.toBytes("comparatorTablename"); byte[] empty = new byte[0]; - HRegionInfo older = new HRegionInfo(tablename, empty, empty, false, 0L); - HRegionInfo newer = new HRegionInfo(tablename, empty, empty, false, 1L); + HRegionInfo older = new HRegionInfo(tablename, empty, empty, false, 0L); + HRegionInfo newer = new HRegionInfo(tablename, empty, empty, false, 1L); assertTrue(older.compareTo(newer) < 0); assertTrue(newer.compareTo(older) > 0); assertTrue(older.compareTo(older) == 0); assertTrue(newer.compareTo(newer) == 0); } - + @org.junit.Rule public org.apache.hadoop.hbase.ResourceCheckerJUnitRule cu = new org.apache.hadoop.hbase.ResourceCheckerJUnitRule();