Index: src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java =================================================================== --- src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java (revision 1374100) +++ src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java (working copy) @@ -44,6 +44,9 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; import static org.junit.Assert.assertEquals; @Category(MediumTests.class) @@ -81,6 +84,27 @@ } /** + * When running on Hadoop 2, we need to add configuration values for keys + * that start with "yarn." (from the map reduce mini cluster) to the + * configuration that will be used during the test (from the HBase mini + * cluster). YARN configuration values are set properly in the map reduce + * mini cluster, but not necessarily in the HBase mini cluster. + * @param conf the HBase mini cluster configuration that may be added to. + */ + private void addConfigurationValues(Configuration conf) { + Configuration c = UTIL.getConfiguration(); + Iterator> it = c.iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + String key = entry.getKey(); + String value = entry.getValue(); + if (key.startsWith("yarn.") && !value.isEmpty()) { + conf.set(key, value); + } + } + } + + /** * Test simple replication case with column mapping * @throws Exception */ @@ -107,6 +131,7 @@ GenericOptionsParser opts = new GenericOptionsParser(new Configuration(cluster.getConfiguration()), args); Configuration conf = opts.getConfiguration(); + addConfigurationValues(conf); args = opts.getRemainingArgs(); Job job = Export.createSubmittableJob(conf, args); @@ -125,6 +150,7 @@ opts = new GenericOptionsParser(new Configuration(cluster.getConfiguration()), args); conf = opts.getConfiguration(); + addConfigurationValues(conf); args = opts.getRemainingArgs(); job = Import.createSubmittableJob(conf, args); @@ -176,6 +202,7 @@ GenericOptionsParser opts = new GenericOptionsParser(new Configuration(cluster.getConfiguration()), args); Configuration conf = opts.getConfiguration(); + addConfigurationValues(conf); args = opts.getRemainingArgs(); Job job = Export.createSubmittableJob(conf, args); @@ -200,6 +227,7 @@ opts = new GenericOptionsParser(new Configuration(cluster.getConfiguration()), args); conf = opts.getConfiguration(); + addConfigurationValues(conf); args = opts.getRemainingArgs(); job = Import.createSubmittableJob(conf, args);