Index: src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java =================================================================== --- src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java (revision 1374456) +++ src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java (working copy) @@ -81,6 +81,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 */ @@ -107,6 +128,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); @@ -125,6 +149,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); @@ -176,6 +203,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); @@ -200,6 +230,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);