HDFS-4615. Fix TestDFSShell failures on Windows. Contributed by Arpit Agarwal
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1459586 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e976294d35
commit
c2e186bae6
@ -442,6 +442,9 @@ Release 2.0.5-beta - UNRELEASED
|
|||||||
HDFS-4609. TestAuditLogs should release log handles between tests.
|
HDFS-4609. TestAuditLogs should release log handles between tests.
|
||||||
(Ivan Mitic via szetszwo)
|
(Ivan Mitic via szetszwo)
|
||||||
|
|
||||||
|
HDFS-4615. Fix TestDFSShell failures on Windows. (Arpit Agarwal
|
||||||
|
via szetszwo)
|
||||||
|
|
||||||
Release 2.0.4-alpha - UNRELEASED
|
Release 2.0.4-alpha - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.zip.DeflaterOutputStream;
|
import java.util.zip.DeflaterOutputStream;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
@ -68,7 +69,8 @@
|
|||||||
*/
|
*/
|
||||||
public class TestDFSShell {
|
public class TestDFSShell {
|
||||||
private static final Log LOG = LogFactory.getLog(TestDFSShell.class);
|
private static final Log LOG = LogFactory.getLog(TestDFSShell.class);
|
||||||
|
private static AtomicInteger counter = new AtomicInteger();
|
||||||
|
|
||||||
static final String TEST_ROOT_DIR =
|
static final String TEST_ROOT_DIR =
|
||||||
new Path(System.getProperty("test.build.data","/tmp"))
|
new Path(System.getProperty("test.build.data","/tmp"))
|
||||||
.toString().replace(' ', '+');
|
.toString().replace(' ', '+');
|
||||||
@ -512,7 +514,7 @@ public void testURIPaths() throws Exception {
|
|||||||
createLocalFile(furi);
|
createLocalFile(furi);
|
||||||
argv = new String[3];
|
argv = new String[3];
|
||||||
argv[0] = "-put";
|
argv[0] = "-put";
|
||||||
argv[1] = furi.toString();
|
argv[1] = furi.toURI().toString();
|
||||||
argv[2] = dstFs.getUri().toString() + "/furi";
|
argv[2] = dstFs.getUri().toString() + "/furi";
|
||||||
ret = ToolRunner.run(shell, argv);
|
ret = ToolRunner.run(shell, argv);
|
||||||
assertEquals(" put is working ", 0, ret);
|
assertEquals(" put is working ", 0, ret);
|
||||||
@ -867,52 +869,59 @@ void testChmod(Configuration conf, FileSystem fs, String chmodDir)
|
|||||||
shell.setConf(conf);
|
shell.setConf(conf);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//first make dir
|
//first make dir
|
||||||
Path dir = new Path(chmodDir);
|
Path dir = new Path(chmodDir);
|
||||||
fs.delete(dir, true);
|
fs.delete(dir, true);
|
||||||
fs.mkdirs(dir);
|
fs.mkdirs(dir);
|
||||||
|
|
||||||
confirmPermissionChange(/* Setting */ "u+rwx,g=rw,o-rwx",
|
confirmPermissionChange(/* Setting */ "u+rwx,g=rw,o-rwx",
|
||||||
/* Should give */ "rwxrw----", fs, shell, dir);
|
/* Should give */ "rwxrw----", fs, shell, dir);
|
||||||
|
|
||||||
//create an empty file
|
|
||||||
Path file = new Path(chmodDir, "file");
|
|
||||||
TestDFSShell.writeFile(fs, file);
|
|
||||||
|
|
||||||
//test octal mode
|
//create an empty file
|
||||||
confirmPermissionChange( "644", "rw-r--r--", fs, shell, file);
|
Path file = new Path(chmodDir, "file");
|
||||||
|
TestDFSShell.writeFile(fs, file);
|
||||||
|
|
||||||
//test recursive
|
//test octal mode
|
||||||
runCmd(shell, "-chmod", "-R", "a+rwX", chmodDir);
|
confirmPermissionChange("644", "rw-r--r--", fs, shell, file);
|
||||||
assertEquals("rwxrwxrwx",
|
|
||||||
fs.getFileStatus(dir).getPermission().toString());
|
|
||||||
assertEquals("rw-rw-rw-",
|
|
||||||
fs.getFileStatus(file).getPermission().toString());
|
|
||||||
|
|
||||||
// test sticky bit on directories
|
//test recursive
|
||||||
Path dir2 = new Path(dir, "stickybit" );
|
runCmd(shell, "-chmod", "-R", "a+rwX", chmodDir);
|
||||||
fs.mkdirs(dir2 );
|
assertEquals("rwxrwxrwx",
|
||||||
LOG.info("Testing sticky bit on: " + dir2);
|
fs.getFileStatus(dir).getPermission().toString());
|
||||||
LOG.info("Sticky bit directory initial mode: " +
|
assertEquals("rw-rw-rw-",
|
||||||
fs.getFileStatus(dir2).getPermission());
|
fs.getFileStatus(file).getPermission().toString());
|
||||||
|
|
||||||
confirmPermissionChange("u=rwx,g=rx,o=rx", "rwxr-xr-x", fs, shell, dir2);
|
|
||||||
|
|
||||||
confirmPermissionChange("+t", "rwxr-xr-t", fs, shell, dir2);
|
|
||||||
|
|
||||||
confirmPermissionChange("-t", "rwxr-xr-x", fs, shell, dir2);
|
// Skip "sticky bit" tests on Windows.
|
||||||
|
//
|
||||||
|
if (!Path.WINDOWS) {
|
||||||
|
// test sticky bit on directories
|
||||||
|
Path dir2 = new Path(dir, "stickybit");
|
||||||
|
fs.mkdirs(dir2);
|
||||||
|
LOG.info("Testing sticky bit on: " + dir2);
|
||||||
|
LOG.info("Sticky bit directory initial mode: " +
|
||||||
|
fs.getFileStatus(dir2).getPermission());
|
||||||
|
|
||||||
confirmPermissionChange("=t", "--------T", fs, shell, dir2);
|
confirmPermissionChange("u=rwx,g=rx,o=rx", "rwxr-xr-x", fs, shell, dir2);
|
||||||
|
|
||||||
confirmPermissionChange("0000", "---------", fs, shell, dir2);
|
confirmPermissionChange("+t", "rwxr-xr-t", fs, shell, dir2);
|
||||||
|
|
||||||
confirmPermissionChange("1666", "rw-rw-rwT", fs, shell, dir2);
|
confirmPermissionChange("-t", "rwxr-xr-x", fs, shell, dir2);
|
||||||
|
|
||||||
|
confirmPermissionChange("=t", "--------T", fs, shell, dir2);
|
||||||
|
|
||||||
|
confirmPermissionChange("0000", "---------", fs, shell, dir2);
|
||||||
|
|
||||||
|
confirmPermissionChange("1666", "rw-rw-rwT", fs, shell, dir2);
|
||||||
|
|
||||||
|
confirmPermissionChange("777", "rwxrwxrwt", fs, shell, dir2);
|
||||||
|
|
||||||
|
fs.delete(dir2, true);
|
||||||
|
} else {
|
||||||
|
LOG.info("Skipped sticky bit tests on Windows");
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.delete(dir, true);
|
||||||
|
|
||||||
confirmPermissionChange("777", "rwxrwxrwt", fs, shell, dir2);
|
|
||||||
|
|
||||||
fs.delete(dir2, true);
|
|
||||||
fs.delete(dir, true);
|
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
fs.close();
|
fs.close();
|
||||||
@ -1595,27 +1604,29 @@ public void testInvalidShell() throws Exception {
|
|||||||
// force Copy Option is -f
|
// force Copy Option is -f
|
||||||
@Test (timeout = 30000)
|
@Test (timeout = 30000)
|
||||||
public void testCopyCommandsWithForceOption() throws Exception {
|
public void testCopyCommandsWithForceOption() throws Exception {
|
||||||
|
final int SUCCESS = 0;
|
||||||
|
final int ERROR = 1;
|
||||||
|
|
||||||
Configuration conf = new Configuration();
|
Configuration conf = new Configuration();
|
||||||
MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1)
|
MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1)
|
||||||
.format(true).build();
|
.format(true).build();
|
||||||
FsShell shell = null;
|
FsShell shell = null;
|
||||||
FileSystem fs = null;
|
FileSystem fs = null;
|
||||||
final File localFile = new File(TEST_ROOT_DIR, "testFileForPut");
|
final File localFile = new File(TEST_ROOT_DIR, "testFileForPut");
|
||||||
final String localfilepath = localFile.getAbsolutePath();
|
final String localfilepath = new Path(localFile.getAbsolutePath()).toUri().toString();
|
||||||
final String testdir = TEST_ROOT_DIR + "/ForceTestDir";
|
final String testdir = "/tmp/TestDFSShell-testCopyCommandsWithForceOption-"
|
||||||
|
+ counter.getAndIncrement();
|
||||||
final Path hdfsTestDir = new Path(testdir);
|
final Path hdfsTestDir = new Path(testdir);
|
||||||
try {
|
try {
|
||||||
fs = cluster.getFileSystem();
|
fs = cluster.getFileSystem();
|
||||||
fs.mkdirs(hdfsTestDir);
|
fs.mkdirs(hdfsTestDir);
|
||||||
localFile.createNewFile();
|
localFile.createNewFile();
|
||||||
writeFile(fs, new Path(TEST_ROOT_DIR, "testFileForPut"));
|
writeFile(fs, new Path(testdir, "testFileForPut"));
|
||||||
shell = new FsShell();
|
shell = new FsShell();
|
||||||
|
|
||||||
// Tests for put
|
// Tests for put
|
||||||
String[] argv = new String[] { "-put", "-f", localfilepath, testdir };
|
String[] argv = new String[] { "-put", "-f", localfilepath, testdir };
|
||||||
int res = ToolRunner.run(shell, argv);
|
int res = ToolRunner.run(shell, argv);
|
||||||
int SUCCESS = 0;
|
|
||||||
int ERROR = 1;
|
|
||||||
assertEquals("put -f is not working", SUCCESS, res);
|
assertEquals("put -f is not working", SUCCESS, res);
|
||||||
|
|
||||||
argv = new String[] { "-put", localfilepath, testdir };
|
argv = new String[] { "-put", localfilepath, testdir };
|
||||||
@ -1687,8 +1698,13 @@ private void deleteFileUsingTrash(
|
|||||||
try {
|
try {
|
||||||
// Create and delete a file
|
// Create and delete a file
|
||||||
fs = cluster.getFileSystem();
|
fs = cluster.getFileSystem();
|
||||||
writeFile(fs, new Path(TEST_ROOT_DIR, "foo"));
|
|
||||||
final String testFile = TEST_ROOT_DIR + "/foo";
|
// Use a separate tmp dir for each invocation.
|
||||||
|
final String testdir = "/tmp/TestDFSShell-deleteFileUsingTrash-" +
|
||||||
|
counter.getAndIncrement();
|
||||||
|
|
||||||
|
writeFile(fs, new Path(testdir, "foo"));
|
||||||
|
final String testFile = testdir + "/foo";
|
||||||
final String trashFile = shell.getCurrentTrashDir() + "/" + testFile;
|
final String trashFile = shell.getCurrentTrashDir() + "/" + testFile;
|
||||||
String[] argv = new String[] { "-rm", testFile };
|
String[] argv = new String[] { "-rm", testFile };
|
||||||
int res = ToolRunner.run(shell, argv);
|
int res = ToolRunner.run(shell, argv);
|
||||||
|
Loading…
Reference in New Issue
Block a user