瀏覽代碼

MAPREDUCE-4673. Fix TestRawHistoryFile and TestJobHistoryServer to not write to /tmp. Contributed by Arpit Gupta.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1@1389528 13f79535-47bb-0310-9956-ffa450edef68
Vinod Kumar Vavilapalli 13 年之前
父節點
當前提交
d1efb165f6

+ 3 - 0
CHANGES.txt

@@ -579,6 +579,9 @@ Release 1.1.0 - unreleased
     HDFS-3966. TestFileCreation should use JUnit4 to make assumeTrue work.
     (Jing Zhao via suresh)
 
+    MAPREDUCE-4673. Fix TestRawHistoryFile and TestJobHistoryServer to not write
+    to /tmp. (Arpit Gupta via vinodkv)
+
 Release 1.0.4 - Unreleased
 
   NEW FEATURES

+ 6 - 8
src/test/org/apache/hadoop/mapred/TestJobHistoryServer.java

@@ -23,7 +23,6 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.io.LongWritable;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.fs.Path;
@@ -34,14 +33,13 @@ import org.junit.Assert;
 import junit.framework.TestCase;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.MalformedURLException;
 
 public class TestJobHistoryServer extends TestCase {
   private static final Log LOG = LogFactory.getLog(TestJobHistoryServer.class);
-
+  private String inputPath = System.getProperty("test.build.data",
+      "build/test/data") + "/TestJobHistoryServer";
+  
   public void testHistoryServerEmbedded() {
 
     MiniMRCluster mrCluster = null;
@@ -61,7 +59,7 @@ public class TestJobHistoryServer extends TestCase {
       LOG.info("******** History Address: " + historyAddress);
 
       conf = mrCluster.createJobConf();
-      createInputFile(conf, "/tmp/input");
+      createInputFile(conf, inputPath);
 
       RunningJob job = runJob(conf);
       LOG.info("Job details: " + job);
@@ -100,7 +98,7 @@ public class TestJobHistoryServer extends TestCase {
       LOG.info("******** History Address: " + historyAddress);
 
       conf = mrCluster.createJobConf();
-      createInputFile(conf, "/tmp/input");
+      createInputFile(conf, inputPath);
 
       RunningJob job = runJob(conf);
       LOG.info("Job details: " + job);
@@ -145,7 +143,7 @@ public class TestJobHistoryServer extends TestCase {
     conf.setMapperClass(org.apache.hadoop.mapred.lib.IdentityMapper.class);
     conf.setReducerClass(org.apache.hadoop.mapred.lib.IdentityReducer.class);
 
-    FileInputFormat.setInputPaths(conf, "/tmp/input");
+    FileInputFormat.setInputPaths(conf, inputPath);
 
     return JobClient.runJob(conf);
   }

+ 6 - 5
src/test/org/apache/hadoop/mapred/TestRawHistoryFile.java

@@ -35,14 +35,15 @@ import org.junit.Assert;
 import java.io.IOException;
 import java.io.File;
 import java.io.FileOutputStream;
-import java.io.InputStream;
 import java.net.HttpURLConnection;
 
 import junit.framework.TestCase;
 
 public class TestRawHistoryFile extends TestCase {
   private static final Log LOG = LogFactory.getLog(TestRawHistoryFile.class);
-
+  private String inputPath = System.getProperty("test.build.data",
+      "build/test/data") + "/TestRawHistoryFile";
+  
   public void testRetrieveHistoryFile() {
 
     MiniMRCluster mrCluster = null;
@@ -58,7 +59,7 @@ public class TestRawHistoryFile extends TestCase {
           null, null, conf);
 
       conf = mrCluster.createJobConf();
-      createInputFile(conf, "/tmp/input");
+      createInputFile(conf, inputPath);
 
       RunningJob job = runJob(conf);
       LOG.info("Job details: " + job);
@@ -98,7 +99,7 @@ public class TestRawHistoryFile extends TestCase {
           null, null, conf);
 
       conf = mrCluster.createJobConf();
-      createInputFile(conf, "/tmp/input");
+      createInputFile(conf, inputPath);
 
       RunningJob job = submitJob(conf);
       LOG.info("Job details: " + job);
@@ -190,7 +191,7 @@ public class TestRawHistoryFile extends TestCase {
     conf.setMapperClass(org.apache.hadoop.mapred.lib.IdentityMapper.class);
     conf.setReducerClass(org.apache.hadoop.mapred.lib.IdentityReducer.class);
 
-    FileInputFormat.setInputPaths(conf, "/tmp/input");
+    FileInputFormat.setInputPaths(conf, inputPath);
   }
 
   private String saveHistoryFile(String url) throws IOException {