Index: hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java =================================================================== --- hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java (revision 1387312) +++ hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java (working copy) @@ -45,6 +45,8 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; +import java.util.Iterator; +import java.util.Map; @Category(MediumTests.class) public class TestImportExport { @@ -82,6 +84,27 @@ } /** + * When running on Hadoop 2, we need to copy (or add) configuration values for keys + * that start with "yarn." (from the map reduce minicluster) to the + * configuration that will be used during the test (from the HBase minicluster). + * YARN configuration values are set properly in the map reduce minicluster, + * but not necessarily in the HBase mini cluster. + * @param srcConf the configuration to copy from (the map reduce minicluster version) + * @param destConf the configuration to copy to (the HBase minicluster version) + */ + private void copyConfigurationValues(Configuration srcConf, Configuration destConf) { + Iterator> it = srcConf.iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + String key = entry.getKey(); + String value = entry.getValue(); + if (key.startsWith("yarn.") && !value.isEmpty()) { + destConf.set(key, value); + } + } + } + + /** * Test simple replication case with column mapping * @throws Exception */ @@ -109,6 +132,9 @@ GenericOptionsParser opts = new GenericOptionsParser(new Configuration(cluster.getConfiguration()), args); Configuration conf = opts.getConfiguration(); + + // copy or add the necessary configuration values from the map reduce config to the hbase config + copyConfigurationValues(UTIL.getConfiguration(), conf); args = opts.getRemainingArgs(); Job job = Export.createSubmittableJob(conf, args); @@ -127,6 +153,9 @@ opts = new GenericOptionsParser(new Configuration(cluster.getConfiguration()), args); conf = opts.getConfiguration(); + + // copy or add the necessary configuration values from the map reduce config to the hbase config + copyConfigurationValues(UTIL.getConfiguration(), conf); args = opts.getRemainingArgs(); job = Import.createSubmittableJob(conf, args); @@ -156,6 +185,9 @@ GenericOptionsParser opts = new GenericOptionsParser(new Configuration( cluster.getConfiguration()), args); Configuration conf = opts.getConfiguration(); + + // copy or add the necessary configuration values from the map reduce config to the hbase config + copyConfigurationValues(UTIL.getConfiguration(), conf); args = opts.getRemainingArgs(); Job job = Export.createSubmittableJob(conf, args); @@ -199,6 +231,9 @@ GenericOptionsParser opts = new GenericOptionsParser(new Configuration(cluster.getConfiguration()), args); Configuration conf = opts.getConfiguration(); + + // copy or add the necessary configuration values from the map reduce config to the hbase config + copyConfigurationValues(UTIL.getConfiguration(), conf); args = opts.getRemainingArgs(); Job job = Export.createSubmittableJob(conf, args); @@ -223,6 +258,9 @@ opts = new GenericOptionsParser(new Configuration(cluster.getConfiguration()), args); conf = opts.getConfiguration(); + + // copy or add the necessary configuration values from the map reduce config to the hbase config + copyConfigurationValues(UTIL.getConfiguration(), conf); args = opts.getRemainingArgs(); job = Import.createSubmittableJob(conf, args);