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 C1CF99E3A for ; Fri, 6 Apr 2012 20:16:32 +0000 (UTC) Received: (qmail 69016 invoked by uid 500); 6 Apr 2012 20:16:32 -0000 Delivered-To: apmail-hadoop-hdfs-commits-archive@hadoop.apache.org Received: (qmail 68909 invoked by uid 500); 6 Apr 2012 20:16:32 -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 68900 invoked by uid 99); 6 Apr 2012 20:16:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Apr 2012 20:16:32 +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, 06 Apr 2012 20:16:31 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E8BC5238890B; Fri, 6 Apr 2012 20:16:10 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1310570 - in /hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs: ./ CHANGES.txt src/main/java/ src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsFileStatusHdfs.java Date: Fri, 06 Apr 2012 20:16:10 -0000 To: hdfs-commits@hadoop.apache.org From: szetszwo@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120406201610.E8BC5238890B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: szetszwo Date: Fri Apr 6 20:16:10 2012 New Revision: 1310570 URL: http://svn.apache.org/viewvc?rev=1310570&view=rev Log: svn merge -c 1310522 from trunk for HDFS-2505. Add a test to verify getFileChecksum(..) with ViewFS. Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/ (props changed) hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/ (props changed) hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsFileStatusHdfs.java Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/ ------------------------------------------------------------------------------ Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs:r1310522 Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1310570&r1=1310569&r2=1310570&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original) +++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Fri Apr 6 20:16:10 2012 @@ -658,6 +658,9 @@ Release 0.23.3 - UNRELEASED IMPROVEMENTS + HDFS-2505. Add a test to verify getFileChecksum(..) with ViewFS. (Ravi + Prakash via szetszwo) + OPTIMIZATIONS BUG FIXES Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/ ------------------------------------------------------------------------------ Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java:r1310522 Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsFileStatusHdfs.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsFileStatusHdfs.java?rev=1310570&r1=1310569&r2=1310570&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsFileStatusHdfs.java (original) +++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsFileStatusHdfs.java Fri Apr 6 20:16:10 2012 @@ -30,6 +30,7 @@ import java.net.URISyntaxException; import javax.security.auth.login.LoginException; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileChecksum; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileSystemTestHelper; @@ -48,13 +49,13 @@ import static org.junit.Assert.*; public class TestViewFsFileStatusHdfs { static final String testfilename = "/tmp/testFileStatusSerialziation"; + static final String someFile = "/hdfstmp/someFileForTestGetFileChecksum"; - - private static MiniDFSCluster cluster; private static Path defaultWorkingDirectory; private static Configuration CONF = new Configuration(); private static FileSystem fHdfs; + private static FileSystem vfs; @BeforeClass public static void clusterSetupAtBegining() throws IOException, @@ -65,18 +66,19 @@ public class TestViewFsFileStatusHdfs { defaultWorkingDirectory = fHdfs.makeQualified( new Path("/user/" + UserGroupInformation.getCurrentUser().getShortUserName())); fHdfs.mkdirs(defaultWorkingDirectory); + + // Setup the ViewFS to be used for all tests. + Configuration conf = ViewFileSystemTestSetup.createConfig(); + ConfigUtil.addLink(conf, "/vfstmp", new URI(fHdfs.getUri() + "/hdfstmp")); + ConfigUtil.addLink(conf, "/tmp", new URI(fHdfs.getUri() + "/tmp")); + vfs = FileSystem.get(FsConstants.VIEWFS_URI, conf); + assertEquals(ViewFileSystem.class, vfs.getClass()); } @Test public void testFileStatusSerialziation() throws IOException, URISyntaxException { - long len = FileSystemTestHelper.createFile(fHdfs, testfilename); - - Configuration conf = ViewFileSystemTestSetup.createConfig(); - ConfigUtil.addLink(conf, "/tmp", new URI(fHdfs.getUri().toString() + "/tmp")); - FileSystem vfs = FileSystem.get(FsConstants.VIEWFS_URI, conf); - assertEquals(ViewFileSystem.class, vfs.getClass()); FileStatus stat = vfs.getFileStatus(new Path(testfilename)); assertEquals(len, stat.getLen()); // check serialization/deserialization @@ -89,9 +91,34 @@ public class TestViewFsFileStatusHdfs { assertEquals(len, deSer.getLen()); } + @Test + public void testGetFileChecksum() throws IOException, URISyntaxException { + // Create two different files in HDFS + FileSystemTestHelper.createFile(fHdfs, someFile); + FileSystemTestHelper.createFile(fHdfs, FileSystemTestHelper + .getTestRootPath(fHdfs, someFile + "other"), 1, 512); + // Get checksum through ViewFS + FileChecksum viewFSCheckSum = vfs.getFileChecksum( + new Path("/vfstmp/someFileForTestGetFileChecksum")); + // Get checksum through HDFS. + FileChecksum hdfsCheckSum = fHdfs.getFileChecksum( + new Path(someFile)); + // Get checksum of different file in HDFS + FileChecksum otherHdfsFileCheckSum = fHdfs.getFileChecksum( + new Path(someFile+"other")); + // Checksums of the same file (got through HDFS and ViewFS should be same) + assertEquals("HDFS and ViewFS checksums were not the same", viewFSCheckSum, + hdfsCheckSum); + // Checksum of different files should be different. + assertFalse("Some other HDFS file which should not have had the same " + + "checksum as viewFS did!", viewFSCheckSum.equals(otherHdfsFileCheckSum)); + } + @AfterClass public static void cleanup() throws IOException { fHdfs.delete(new Path(testfilename), true); + fHdfs.delete(new Path(someFile), true); + fHdfs.delete(new Path(someFile + "other"), true); } }