HADOOP-16532. Fix TestViewFsTrash to use the correct homeDir. Contributed by Xing Lin. (#3514)
This commit is contained in:
parent
107fe227eb
commit
97c0f96879
@ -123,9 +123,10 @@ public static void trashShell(final FileSystem fs, final Path base)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test trash for the shell's delete command for the default file system
|
* Test trash for the shell's delete command for the default file system
|
||||||
* specified in the paramter conf
|
* specified in the parameter conf
|
||||||
* @param conf
|
* @param conf - configuration object for the filesystem
|
||||||
* @param base - the base path where files are created
|
* @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
|
* @param trashRoot - the expected place where the trashbin resides
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@ -793,7 +794,7 @@ public void tearDown() throws IOException {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class TestLFS extends LocalFileSystem {
|
public static class TestLFS extends LocalFileSystem {
|
||||||
private URI uriName = null;
|
private URI uriName = null;
|
||||||
Path home;
|
Path home;
|
||||||
TestLFS() {
|
TestLFS() {
|
||||||
|
@ -17,14 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.hadoop.fs.viewfs;
|
package org.apache.hadoop.fs.viewfs;
|
||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
import org.apache.hadoop.fs.FileSystemTestHelper;
|
import org.apache.hadoop.fs.FileSystemTestHelper;
|
||||||
import org.apache.hadoop.fs.FsConstants;
|
import org.apache.hadoop.fs.FsConstants;
|
||||||
import org.apache.hadoop.fs.LocalFileSystem;
|
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.fs.TestTrash;
|
import org.apache.hadoop.fs.TestTrash;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@ -35,31 +31,26 @@ public class TestViewFsTrash {
|
|||||||
FileSystem fsTarget; // the target file system - the mount will point here
|
FileSystem fsTarget; // the target file system - the mount will point here
|
||||||
FileSystem fsView;
|
FileSystem fsView;
|
||||||
Configuration conf;
|
Configuration conf;
|
||||||
FileSystemTestHelper fileSystemTestHelper = new FileSystemTestHelper();
|
private FileSystemTestHelper 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
fsTarget = FileSystem.getLocal(new Configuration());
|
Configuration targetFSConf = new Configuration();
|
||||||
fsTarget.mkdirs(new Path(fileSystemTestHelper.
|
targetFSConf.setClass("fs.file.impl", TestTrash.TestLFS.class, FileSystem.class);
|
||||||
getTestRootPath(fsTarget), "dir1"));
|
|
||||||
|
fsTarget = FileSystem.getLocal(targetFSConf);
|
||||||
|
fileSystemTestHelper = new FileSystemTestHelper(fsTarget.getHomeDirectory().toUri().getPath());
|
||||||
|
|
||||||
conf = ViewFileSystemTestSetup.createConfig();
|
conf = ViewFileSystemTestSetup.createConfig();
|
||||||
fsView = ViewFileSystemTestSetup.setupForViewFileSystem(conf, fileSystemTestHelper, fsTarget);
|
fsView = ViewFileSystemTestSetup.setupForViewFileSystem(conf, fileSystemTestHelper, fsTarget);
|
||||||
conf.set("fs.defaultFS", FsConstants.VIEWFS_URI.toString());
|
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
|
@After
|
||||||
@ -72,7 +63,7 @@ public void tearDown() throws Exception {
|
|||||||
@Test
|
@Test
|
||||||
public void testTrash() throws Exception {
|
public void testTrash() throws Exception {
|
||||||
TestTrash.trashShell(conf, fileSystemTestHelper.getTestRootPath(fsView),
|
TestTrash.trashShell(conf, fileSystemTestHelper.getTestRootPath(fsView),
|
||||||
fsTarget, new Path(fsTarget.getHomeDirectory(), ".Trash/Current"));
|
fsView, new Path(fileSystemTestHelper.getTestRootPath(fsView), ".Trash/Current"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user