hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r1147184 - in /hadoop/common/trunk/hdfs: CHANGES.txt src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java
Date Fri, 15 Jul 2011 15:09:44 GMT
Author: szetszwo
Date: Fri Jul 15 15:09:43 2011
New Revision: 1147184

URL: http://svn.apache.org/viewvc?rev=1147184&view=rev
Log:
HDFS-2154. In TestDFSShell, use TEST_ROOT_DIR and fix some deprecated warnings.

Modified:
    hadoop/common/trunk/hdfs/CHANGES.txt
    hadoop/common/trunk/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java

Modified: hadoop/common/trunk/hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hdfs/CHANGES.txt?rev=1147184&r1=1147183&r2=1147184&view=diff
==============================================================================
--- hadoop/common/trunk/hdfs/CHANGES.txt (original)
+++ hadoop/common/trunk/hdfs/CHANGES.txt Fri Jul 15 15:09:43 2011
@@ -554,6 +554,9 @@ Trunk (unreleased changes)
 
     HDFS-2140. Move Host2NodesMap to the blockmanagement package.  (szetszwo)
 
+    HDFS-2154. In TestDFSShell, use TEST_ROOT_DIR and fix some deprecated
+    warnings.  (szetszwo)
+
   OPTIMIZATIONS
 
     HDFS-1458. Improve checkpoint performance by avoiding unnecessary image

Modified: hadoop/common/trunk/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java?rev=1147184&r1=1147183&r2=1147184&view=diff
==============================================================================
--- hadoop/common/trunk/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java (original)
+++ hadoop/common/trunk/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java Fri Jul
15 15:09:43 2011
@@ -43,7 +43,6 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FsShell;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
-import org.apache.hadoop.fs.shell.Count;
 import org.apache.hadoop.hdfs.protocol.Block;
 import org.apache.hadoop.hdfs.server.datanode.DataNode;
 import org.apache.hadoop.hdfs.server.datanode.FSDataset;
@@ -701,10 +700,10 @@ public class TestDFSShell extends TestCa
       String root = createTree(dfs, "count");
 
       // Verify the counts
-      runCount(root, 2, 4, conf);
-      runCount(root + "2", 2, 1, conf);
-      runCount(root + "2/f1", 0, 1, conf);
-      runCount(root + "2/sub", 1, 0, conf);
+      runCount(root, 2, 4, shell);
+      runCount(root + "2", 2, 1, shell);
+      runCount(root + "2/f1", 0, 1, shell);
+      runCount(root + "2/sub", 1, 0, shell);
 
       final FileSystem localfs = FileSystem.getLocal(conf);
       Path localpath = new Path(TEST_ROOT_DIR, "testcount");
@@ -714,8 +713,8 @@ public class TestDFSShell extends TestCa
       
       final String localstr = localpath.toString();
       System.out.println("localstr=" + localstr);
-      runCount(localstr, 1, 0, conf);
-      assertEquals(0, new Count(new String[]{root, localstr}, 0, conf).runAll());
+      runCount(localstr, 1, 0, shell);
+      assertEquals(0, runCmd(shell, "-count", root, localstr));
     } finally {
       try {
         dfs.close();
@@ -724,7 +723,7 @@ public class TestDFSShell extends TestCa
       cluster.shutdown();
     }
   }
-  private void runCount(String path, long dirs, long files, Configuration conf
+  private static void runCount(String path, long dirs, long files, FsShell shell
     ) throws IOException {
     ByteArrayOutputStream bytes = new ByteArrayOutputStream(); 
     PrintStream out = new PrintStream(bytes);
@@ -733,7 +732,7 @@ public class TestDFSShell extends TestCa
     Scanner in = null;
     String results = null;
     try {
-      new Count(new String[]{path}, 0, conf).runAll();
+      runCmd(shell, "-count", path);
       results = bytes.toString();
       in = new Scanner(results);
       assertEquals(dirs, in.nextLong());
@@ -747,7 +746,7 @@ public class TestDFSShell extends TestCa
   }
 
   //throws IOException instead of Exception as shell.run() does.
-  private int runCmd(FsShell shell, String... args) throws IOException {
+  private static int runCmd(FsShell shell, String... args) throws IOException {
     StringBuilder cmdline = new StringBuilder("RUN:");
     for (String arg : args) cmdline.append(" " + arg);
     LOG.info(cmdline.toString());
@@ -1362,48 +1361,46 @@ public class TestDFSShell extends TestCa
         .format(true).build();
     FsShell shell = null;
     FileSystem fs = null;
-    File localFile = new File("testFileForPut");
-    Path hdfsTestDir = new Path("ForceTestDir");
+    final File localFile = new File(TEST_ROOT_DIR, "testFileForPut");
+    final String localfilepath = localFile.getAbsolutePath();
+    final String testdir = TEST_ROOT_DIR + "/ForceTestDir";
+    final Path hdfsTestDir = new Path(testdir);
     try {
       fs = cluster.getFileSystem();
       fs.mkdirs(hdfsTestDir);
       localFile.createNewFile();
-      writeFile(fs, new Path("testFileForPut"));
+      writeFile(fs, new Path(TEST_ROOT_DIR, "testFileForPut"));
       shell = new FsShell();
 
       // Tests for put
-      String[] argv = new String[] { "-put", "-f", localFile.getName(),
-          "ForceTestDir" };
+      String[] argv = new String[] { "-put", "-f", localfilepath, testdir };
       int res = ToolRunner.run(shell, argv);
       int SUCCESS = 0;
       int ERROR = 1;
       assertEquals("put -f is not working", SUCCESS, res);
 
-      argv = new String[] { "-put", localFile.getName(), "ForceTestDir" };
+      argv = new String[] { "-put", localfilepath, testdir };
       res = ToolRunner.run(shell, argv);
       assertEquals("put command itself is able to overwrite the file", ERROR,
           res);
 
       // Tests for copyFromLocal
-      argv = new String[] { "-copyFromLocal", "-f", localFile.getName(),
-          "ForceTestDir" };
+      argv = new String[] { "-copyFromLocal", "-f", localfilepath, testdir };
       res = ToolRunner.run(shell, argv);
       assertEquals("copyFromLocal -f is not working", SUCCESS, res);
 
-      argv = new String[] { "-copyFromLocal", localFile.getName(),
-          "ForceTestDir" };
+      argv = new String[] { "-copyFromLocal", localfilepath, testdir };
       res = ToolRunner.run(shell, argv);
       assertEquals(
           "copyFromLocal command itself is able to overwrite the file", ERROR,
           res);
 
       // Tests for cp
-      argv = new String[] { "-cp", "-f", localFile.getName(), "ForceTestDir" };
+      argv = new String[] { "-cp", "-f", localfilepath, testdir };
       res = ToolRunner.run(shell, argv);
       assertEquals("cp -f is not working", SUCCESS, res);
 
-      argv = new String[] { "-cp", localFile.getName(),
-          "ForceTestDir" };
+      argv = new String[] { "-cp", localfilepath, testdir };
       res = ToolRunner.run(shell, argv);
       assertEquals("cp command itself is able to overwrite the file", ERROR,
           res);



Mime
View raw message