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 B918E4DE8 for ; Wed, 13 Jul 2011 03:01:56 +0000 (UTC) Received: (qmail 98654 invoked by uid 500); 13 Jul 2011 03:01:56 -0000 Delivered-To: apmail-hadoop-hdfs-commits-archive@hadoop.apache.org Received: (qmail 98522 invoked by uid 500); 13 Jul 2011 03:01:51 -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 98514 invoked by uid 99); 13 Jul 2011 03:01:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jul 2011 03:01:50 +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; Wed, 13 Jul 2011 03:01:47 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8D5C123889EA; Wed, 13 Jul 2011 03:01:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1145843 - in /hadoop/common/trunk/hdfs: CHANGES.txt src/test/hdfs/org/apache/hadoop/cli/testHDFSConf.xml src/test/hdfs/org/apache/hadoop/hdfs/TestDFSShell.java Date: Wed, 13 Jul 2011 03:01:25 -0000 To: hdfs-commits@hadoop.apache.org From: szetszwo@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110713030125.8D5C123889EA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: szetszwo Date: Wed Jul 13 03:01:25 2011 New Revision: 1145843 URL: http://svn.apache.org/viewvc?rev=1145843&view=rev Log: HDFS-2131. Add new tests for the -overwrite/-f option in put and copyFromLocal by HADOOP-7361. Contributed by Uma Maheswara Rao G Modified: hadoop/common/trunk/hdfs/CHANGES.txt hadoop/common/trunk/hdfs/src/test/hdfs/org/apache/hadoop/cli/testHDFSConf.xml 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=1145843&r1=1145842&r2=1145843&view=diff ============================================================================== --- hadoop/common/trunk/hdfs/CHANGES.txt (original) +++ hadoop/common/trunk/hdfs/CHANGES.txt Wed Jul 13 03:01:25 2011 @@ -549,6 +549,9 @@ Trunk (unreleased changes) HDFS-1977. Stop using StringUtils.stringifyException(). (Bharath Mundlapudi via jitendra) + HDFS-2131. Add new tests for the -overwrite/-f option in put and + copyFromLocal by HADOOP-7361. (Uma Maheswara Rao G via szetszwo) + OPTIMIZATIONS HDFS-1458. Improve checkpoint performance by avoiding unnecessary image Modified: hadoop/common/trunk/hdfs/src/test/hdfs/org/apache/hadoop/cli/testHDFSConf.xml URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hdfs/src/test/hdfs/org/apache/hadoop/cli/testHDFSConf.xml?rev=1145843&r1=1145842&r2=1145843&view=diff ============================================================================== --- hadoop/common/trunk/hdfs/src/test/hdfs/org/apache/hadoop/cli/testHDFSConf.xml (original) +++ hadoop/common/trunk/hdfs/src/test/hdfs/org/apache/hadoop/cli/testHDFSConf.xml Wed Jul 13 03:01:25 2011 @@ -2671,6 +2671,24 @@ + cp: putting file into an already existing destination with -f option(absolute path) + + -fs NAMENODE -touchz /user/file0 + -fs NAMENODE -cp -f CLITEST_DATA/data120bytes /user/file0 + -fs NAMENODE -cat /user/file0 + + + -fs NAMENODE -rm -r /user + + + + RegexpComparator + 12345678901234 + + + + + cp: copying directory to directory in hdfs:// path -fs NAMENODE -mkdir hdfs:///dir0 @@ -4077,6 +4095,24 @@ + put: putting file into an already existing destination with -f option(absolute path) + + -fs NAMENODE -touchz /user/file0 + -fs NAMENODE -put -f CLITEST_DATA/data120bytes /user/file0 + -fs NAMENODE -cat /user/file0 + + + -fs NAMENODE -rm -r /user + + + + RegexpComparator + 12345678901234 + + + + + put: putting file into an already existing destination(relative path) -fs NAMENODE -touchz file0 @@ -4593,6 +4629,25 @@ + copyFromLocal: copying file into an already existing destination with -f option(absolute path) + + -fs NAMENODE -touchz /user/file0 + -fs NAMENODE -copyFromLocal -f CLITEST_DATA/data120bytes /user/file0 + -fs NAMENODE -cat /user/file0 + + + -fs NAMENODE -rm -r /user + + + + RegexpComparator + 12345678901234 + + + + + + copyFromLocal: copying file into an already existing destination(relative path) -fs NAMENODE -touchz file0 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=1145843&r1=1145842&r2=1145843&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 Wed Jul 13 03:01:25 2011 @@ -1354,4 +1354,73 @@ public class TestDFSShell extends TestCa int res = admin.run(new String[] {"-refreshNodes"}); assertEquals("expected to fail -1", res , -1); } + + // force Copy Option is -f + public void testCopyCommandsWithForceOption() throws Exception { + Configuration conf = new Configuration(); + MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1) + .format(true).build(); + FsShell shell = null; + FileSystem fs = null; + File localFile = new File("testFileForPut"); + Path hdfsTestDir = new Path("ForceTestDir"); + try { + fs = cluster.getFileSystem(); + fs.mkdirs(hdfsTestDir); + localFile.createNewFile(); + writeFile(fs, new Path("testFileForPut")); + shell = new FsShell(); + + // Tests for put + String[] argv = new String[] { "-put", "-f", localFile.getName(), + "ForceTestDir" }; + 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" }; + 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" }; + res = ToolRunner.run(shell, argv); + assertEquals("copyFromLocal -f is not working", SUCCESS, res); + + argv = new String[] { "-copyFromLocal", localFile.getName(), + "ForceTestDir" }; + 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" }; + res = ToolRunner.run(shell, argv); + assertEquals("cp -f is not working", SUCCESS, res); + + argv = new String[] { "-cp", localFile.getName(), + "ForceTestDir" }; + res = ToolRunner.run(shell, argv); + assertEquals("cp command itself is able to overwrite the file", ERROR, + res); + } finally { + if (null != shell) + shell.close(); + + if (localFile.exists()) + localFile.delete(); + + if (null != fs) { + fs.delete(hdfsTestDir, true); + fs.close(); + } + cluster.shutdown(); + } + + } + }