You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by el...@apache.org on 2012/07/16 20:29:25 UTC
svn commit: r1362177 - in
/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs: CHANGES.txt
src/test/java/org/apache/hadoop/fs/TestFcHdfsSymlink.java
Author: eli
Date: Mon Jul 16 18:29:25 2012
New Revision: 1362177
URL: http://svn.apache.org/viewvc?rev=1362177&view=rev
Log:
HDFS-3665. Add a test for renaming across file systems via a symlink. Contributed by Eli Collins
Modified:
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSymlink.java
Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1362177&r1=1362176&r2=1362177&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Mon Jul 16 18:29:25 2012
@@ -336,6 +336,8 @@ Branch-2 ( Unreleased changes )
HDFS-3537. Move libhdfs and fuse-dfs source to native subdirectories.
(Colin Patrick McCabe via eli)
+ HDFS-3665. Add a test for renaming across file systems via a symlink. (eli)
+
OPTIMIZATIONS
HDFS-2982. Startup performance suffers when there are many edit log
Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSymlink.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSymlink.java?rev=1362177&r1=1362176&r2=1362177&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSymlink.java (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSymlink.java Mon Jul 16 18:29:25 2012
@@ -97,7 +97,7 @@ public class TestFcHdfsSymlink extends F
}
@Test
- /** Link from Hdfs to LocalFs */
+ /** Access a file using a link that spans Hdfs to LocalFs */
public void testLinkAcrossFileSystems() throws IOException {
Path localDir = new Path("file://"+getAbsoluteTestRootDir(fc)+"/test");
Path localFile = new Path("file://"+getAbsoluteTestRootDir(fc)+"/test/file");
@@ -112,7 +112,42 @@ public class TestFcHdfsSymlink extends F
readFile(link);
assertEquals(fileSize, fc.getFileStatus(link).getLen());
}
-
+
+ @Test
+ /** Test renaming a file across two file systems using a link */
+ public void testRenameAcrossFileSystemsViaLink() throws IOException {
+ Path localDir = new Path("file://"+getAbsoluteTestRootDir(fc)+"/test");
+ Path hdfsFile = new Path(testBaseDir1(), "file");
+ Path link = new Path(testBaseDir1(), "link");
+ Path hdfsFileNew = new Path(testBaseDir1(), "fileNew");
+ Path hdfsFileNewViaLink = new Path(link, "fileNew");
+ FileContext localFc = FileContext.getLocalFSFileContext();
+ localFc.delete(localDir, true);
+ localFc.mkdir(localDir, FileContext.DEFAULT_PERM, true);
+ localFc.setWorkingDirectory(localDir);
+ createAndWriteFile(fc, hdfsFile);
+ fc.createSymlink(localDir, link, false);
+ // Rename hdfs://test1/file to hdfs://test1/link/fileNew
+ // which renames to file://TEST_ROOT/test/fileNew which
+ // spans AbstractFileSystems and therefore fails.
+ try {
+ fc.rename(hdfsFile, hdfsFileNewViaLink);
+ fail("Renamed across file systems");
+ } catch (InvalidPathException ipe) {
+ // Expected
+ }
+ // Now rename hdfs://test1/link/fileNew to hdfs://test1/fileNew
+ // which renames file://TEST_ROOT/test/fileNew to hdfs://test1/fileNew
+ // which spans AbstractFileSystems and therefore fails.
+ createAndWriteFile(fc, hdfsFileNewViaLink);
+ try {
+ fc.rename(hdfsFileNewViaLink, hdfsFileNew);
+ fail("Renamed across file systems");
+ } catch (InvalidPathException ipe) {
+ // Expected
+ }
+ }
+
@Test
/** Test access a symlink using AbstractFileSystem */
public void testAccessLinkFromAbstractFileSystem() throws IOException {