Przeglądaj źródła

HADOOP-3240. Fix a testcase to not create files in the current directory. Instead the file is created in the test directory. Contributed by Mahadev Konar.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@663841 13f79535-47bb-0310-9956-ffa450edef68
Devaraj Das 17 lat temu
rodzic
commit
91389d0bec

+ 3 - 0
CHANGES.txt

@@ -483,6 +483,9 @@ Trunk (unreleased changes)
     HADOOP-3455. Fix NPE in ipc.Client in case of connection failure and
     HADOOP-3455. Fix NPE in ipc.Client in case of connection failure and
     improve its synchronization. (hairong)
     improve its synchronization. (hairong)
 
 
+    HADOOP-3240. Fix a testcase to not create files in the current directory.
+    Instead the file is created in the test directory (Mahadev Konar via ddas)
+
 Release 0.17.0 - 2008-05-18
 Release 0.17.0 - 2008-05-18
 
 
   INCOMPATIBLE CHANGES
   INCOMPATIBLE CHANGES

+ 7 - 2
src/test/org/apache/hadoop/mapred/TestCommandLineJobSubmission.java

@@ -38,6 +38,7 @@ public class TestCommandLineJobSubmission extends TestCase {
   // params 
   // params 
   static final Path input = new Path("/test/input/");
   static final Path input = new Path("/test/input/");
   static final Path output = new Path("/test/output");
   static final Path output = new Path("/test/output");
+  File buildDir = new File(System.getProperty("test.build.data", "/tmp"));
   public void testJobShell() throws Exception {
   public void testJobShell() throws Exception {
     MiniDFSCluster dfs = null;
     MiniDFSCluster dfs = null;
     MiniMRCluster mr = null;
     MiniMRCluster mr = null;
@@ -52,13 +53,15 @@ public class TestCommandLineJobSubmission extends TestCase {
       stream.write("teststring".getBytes());
       stream.write("teststring".getBytes());
       stream.close();
       stream.close();
       mr = new MiniMRCluster(2, fs.getUri().toString(), 1);
       mr = new MiniMRCluster(2, fs.getUri().toString(), 1);
-      File f = new File("files_tmp");
+      File thisbuildDir = new File(buildDir, "jobCommand");
+      assertTrue("create build dir", thisbuildDir.mkdirs()); 
+      File f = new File(thisbuildDir, "files_tmp");
       FileOutputStream fstream = new FileOutputStream(f);
       FileOutputStream fstream = new FileOutputStream(f);
       fstream.write("somestrings".getBytes());
       fstream.write("somestrings".getBytes());
       fstream.close();
       fstream.close();
       String[] args = new String[6];
       String[] args = new String[6];
       args[0] = "-files";
       args[0] = "-files";
-      args[1] = "files_tmp";
+      args[1] = f.toString();
       args[2] = "-libjars";
       args[2] = "-libjars";
       // the testjob.jar as a temporary jar file 
       // the testjob.jar as a temporary jar file 
       // rather than creating its own
       // rather than creating its own
@@ -68,6 +71,8 @@ public class TestCommandLineJobSubmission extends TestCase {
       int ret = ToolRunner.run(mr.createJobConf(),
       int ret = ToolRunner.run(mr.createJobConf(),
                                new testshell.ExternalMapReduce(), args);
                                new testshell.ExternalMapReduce(), args);
       assertTrue("not failed ", ret != -1);
       assertTrue("not failed ", ret != -1);
+      f.delete();
+      thisbuildDir.delete();
     } finally {
     } finally {
       if (dfs != null) {dfs.shutdown();};
       if (dfs != null) {dfs.shutdown();};
       if (mr != null) {mr.shutdown();};
       if (mr != null) {mr.shutdown();};