Return-Path: X-Original-To: apmail-hadoop-hdfs-commits-archive@minotaur.apache.org Delivered-To: apmail-hadoop-hdfs-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3AA796EE3 for ; Fri, 15 Jul 2011 15:10:07 +0000 (UTC) Received: (qmail 17175 invoked by uid 500); 15 Jul 2011 15:10:07 -0000 Delivered-To: apmail-hadoop-hdfs-commits-archive@hadoop.apache.org Received: (qmail 17048 invoked by uid 500); 15 Jul 2011 15:10:06 -0000 Mailing-List: contact hdfs-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hdfs-dev@hadoop.apache.org Delivered-To: mailing list hdfs-commits@hadoop.apache.org Received: (qmail 17038 invoked by uid 99); 15 Jul 2011 15:10:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Jul 2011 15:10:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Jul 2011 15:10:04 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 3D053238896F; Fri, 15 Jul 2011 15:09:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: hdfs-commits@hadoop.apache.org From: szetszwo@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110715150944.3D053238896F@eris.apache.org> 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);