Sfoglia il codice sorgente

MAPREDUCE-3156. Allow TestMRCLI to be run against a cluster. Contributed by Tom White, Konstantin Boudnik.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.22@1182207 13f79535-47bb-0310-9956-ffa450edef68
Konstantin Boudnik 13 anni fa
parent
commit
abb4f3a9f0

+ 2 - 0
mapreduce/CHANGES.txt

@@ -624,6 +624,8 @@ Release 0.22.0 - Unreleased
 
     MAPREDUCE-3151. Contrib tests failing (Joep Rottinghuis via cos)
 
+    MAPREDUCE-3156. Allow TestMRCLI to be run against a cluster (cos)
+
 Release 0.21.1 - Unreleased
 
   NEW FEATURES

+ 3 - 0
mapreduce/build.xml

@@ -688,6 +688,9 @@
         <syspropertyset id="FaultProbabilityProperties">
           <propertyref regex="fi.*"/>
         </syspropertyset>
+        <syspropertyset id="TestCLIProperties">
+          <propertyref regex="test.cli.*" />
+        </syspropertyset>
         <sysproperty key="test.system.hdrc.deployed.hadoopconfdir"
                      value="@{hadoop.conf.dir.deployed}" />
         <classpath refid="@{classpath}"/>

+ 17 - 4
mapreduce/src/test/mapred/org/apache/hadoop/cli/TestMRCLI.java

@@ -30,6 +30,8 @@ import org.apache.hadoop.security.authorize.HadoopPolicyProvider;
 import org.apache.hadoop.security.authorize.PolicyProvider;
 import org.apache.hadoop.util.ToolRunner;
 
+import static org.junit.Assert.assertTrue;
+
 public class TestMRCLI extends TestHDFSCLI{
 
   protected MiniMRCluster mrCluster = null;
@@ -41,17 +43,28 @@ public class TestMRCLI extends TestHDFSCLI{
     super.setUp();
     conf.setClass(PolicyProvider.POLICY_PROVIDER_CONFIG,
         HadoopPolicyProvider.class, PolicyProvider.class);
+    jobtracker = System.getProperty("test.cli.mapred.job.tracker");
     JobConf mrConf = new JobConf(conf);
-    mrCluster = new MiniMRCluster(1, dfsCluster.getFileSystem().getUri().toString(), 1, 
-                           null, null, mrConf);
-    jobtracker = mrCluster.createJobConf().get(JTConfig.JT_IPC_ADDRESS, "local");
+    if (jobtracker == null) {
+      // Start up mini mr cluster
+      mrCluster = new MiniMRCluster(1, dfsCluster.getFileSystem().getUri().toString(), 1,
+                            null, null, mrConf);
+      jobtracker = mrCluster.createJobConf().get(JTConfig.JT_IPC_ADDRESS, "local");
+    } else {
+      conf.set(JTConfig.JT_IPC_ADDRESS, jobtracker);
+    }
     cmdExecutor = new MRCmdExecutor(jobtracker);
     archiveCmdExecutor = new ArchiveCmdExecutor(namenode, mrConf);
   }
 
   
   public void tearDown() throws Exception {
-    mrCluster.shutdown();
+    boolean success = false;
+    if (mrCluster != null) {
+      mrCluster.shutdown();
+      success = true;
+    }
+    assertTrue("Error tearing down Mini MR cluster", success);
     super.tearDown();
   }