You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by sh...@apache.org on 2021/10/13 22:06:03 UTC
[hadoop] branch branch-3.3 updated: HADOOP-16532. Fix
TestViewFsTrash to use the correct homeDir. Contributed by Xing Lin.
(#3514)
This is an automated email from the ASF dual-hosted git repository.
shv pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.3 by this push:
new af920f1 HADOOP-16532. Fix TestViewFsTrash to use the correct homeDir. Contributed by Xing Lin. (#3514)
af920f1 is described below
commit af920f138b1f8dcd2417f6af77ab96672f2bc4bc
Author: Xing Lin <xi...@linkedin.com>
AuthorDate: Wed Oct 13 13:43:47 2021 -0700
HADOOP-16532. Fix TestViewFsTrash to use the correct homeDir. Contributed by Xing Lin. (#3514)
(cherry picked from commit 97c0f968792e1a45a1569a3184af7b114fc8c022)
---
.../test/java/org/apache/hadoop/fs/TestTrash.java | 7 ++--
.../apache/hadoop/fs/viewfs/TestViewFsTrash.java | 39 +++++++++-------------
2 files changed, 19 insertions(+), 27 deletions(-)
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java
index e8e0287..7228778 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java
@@ -123,9 +123,10 @@ public class TestTrash {
/**
* Test trash for the shell's delete command for the default file system
- * specified in the paramter conf
- * @param conf
+ * specified in the parameter conf
+ * @param conf - configuration object for the filesystem
* @param base - the base path where files are created
+ * @param trashRootFs - the filesystem object to test trash
* @param trashRoot - the expected place where the trashbin resides
* @throws IOException
*/
@@ -793,7 +794,7 @@ public class TestTrash {
}
}
- static class TestLFS extends LocalFileSystem {
+ public static class TestLFS extends LocalFileSystem {
private URI uriName = null;
Path home;
TestLFS() {
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java
index 94c3262..8e5fa72 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java
@@ -17,14 +17,10 @@
*/
package org.apache.hadoop.fs.viewfs;
-
-import java.io.IOException;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FileSystemTestHelper;
import org.apache.hadoop.fs.FsConstants;
-import org.apache.hadoop.fs.LocalFileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.TestTrash;
import org.junit.After;
@@ -35,31 +31,26 @@ public class TestViewFsTrash {
FileSystem fsTarget; // the target file system - the mount will point here
FileSystem fsView;
Configuration conf;
- FileSystemTestHelper fileSystemTestHelper = new FileSystemTestHelper();
-
- class TestLFS extends LocalFileSystem {
- Path home;
- TestLFS() throws IOException {
- this(new Path(fileSystemTestHelper.getTestRootDir()));
- }
- TestLFS(Path home) throws IOException {
- super();
- this.home = home;
- }
- @Override
- public Path getHomeDirectory() {
- return home;
- }
- }
+ private FileSystemTestHelper fileSystemTestHelper;
@Before
public void setUp() throws Exception {
- fsTarget = FileSystem.getLocal(new Configuration());
- fsTarget.mkdirs(new Path(fileSystemTestHelper.
- getTestRootPath(fsTarget), "dir1"));
+ Configuration targetFSConf = new Configuration();
+ targetFSConf.setClass("fs.file.impl", TestTrash.TestLFS.class, FileSystem.class);
+
+ fsTarget = FileSystem.getLocal(targetFSConf);
+ fileSystemTestHelper = new FileSystemTestHelper(fsTarget.getHomeDirectory().toUri().getPath());
+
conf = ViewFileSystemTestSetup.createConfig();
fsView = ViewFileSystemTestSetup.setupForViewFileSystem(conf, fileSystemTestHelper, fsTarget);
conf.set("fs.defaultFS", FsConstants.VIEWFS_URI.toString());
+
+ /*
+ * Need to set the fs.file.impl to TestViewFsTrash.TestLFS. Otherwise, it will load
+ * LocalFileSystem implementation which uses System.getProperty("user.home") for homeDirectory.
+ */
+ conf.setClass("fs.file.impl", TestTrash.TestLFS.class, FileSystem.class);
+
}
@After
@@ -72,7 +63,7 @@ public class TestViewFsTrash {
@Test
public void testTrash() throws Exception {
TestTrash.trashShell(conf, fileSystemTestHelper.getTestRootPath(fsView),
- fsTarget, new Path(fsTarget.getHomeDirectory(), ".Trash/Current"));
+ fsView, new Path(fileSystemTestHelper.getTestRootPath(fsView), ".Trash/Current"));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org