HADOOP-12164. Fix TestMove and TestFsShellReturnCode failed to get command name using reflection. (Lei Xu)
This commit is contained in:
parent
b8e792cba2
commit
532e38cb7f
|
@ -916,6 +916,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
HADOOP-12116. Fix unrecommended syntax usages in hadoop/hdfs/yarn script for
|
HADOOP-12116. Fix unrecommended syntax usages in hadoop/hdfs/yarn script for
|
||||||
cygwin in branch-2. (Li Lu via cnauroth)
|
cygwin in branch-2. (Li Lu via cnauroth)
|
||||||
|
|
||||||
|
HADOOP-12164. Fix TestMove and TestFsShellReturnCode failed to get command
|
||||||
|
name using reflection. (Lei (Eddy) Xu)
|
||||||
|
|
||||||
Release 2.7.2 - UNRELEASED
|
Release 2.7.2 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
package org.apache.hadoop.fs;
|
package org.apache.hadoop.fs;
|
||||||
|
|
||||||
|
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SHELL_MISSING_DEFAULT_FS_WARNING_KEY;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
@ -402,7 +403,7 @@ public class TestFsShellReturnCode {
|
||||||
// processing a file throws an interrupt, it should blow on first file
|
// processing a file throws an interrupt, it should blow on first file
|
||||||
assertEquals(1, InterruptCommand.processed);
|
assertEquals(1, InterruptCommand.processed);
|
||||||
assertEquals(130, exitCode);
|
assertEquals(130, exitCode);
|
||||||
|
|
||||||
exitCode = shell.run(
|
exitCode = shell.run(
|
||||||
new String[]{ "-testInterrupt", d.toString() });
|
new String[]{ "-testInterrupt", d.toString() });
|
||||||
// processing a file throws an interrupt, it should blow on file
|
// processing a file throws an interrupt, it should blow on file
|
||||||
|
@ -411,18 +412,33 @@ public class TestFsShellReturnCode {
|
||||||
assertEquals(130, exitCode);
|
assertEquals(130, exitCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Faked Chown class for {@link testChownUserAndGroupValidity()}.
|
||||||
|
*
|
||||||
|
* The test only covers argument parsing, so override to skip processing.
|
||||||
|
*/
|
||||||
|
private static class FakeChown extends FsShellPermissions.Chown {
|
||||||
|
public static String NAME = "chown";
|
||||||
|
@Override
|
||||||
|
protected void processArgument(PathData item) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests combinations of valid and invalid user and group arguments to chown.
|
* Tests combinations of valid and invalid user and group arguments to chown.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testChownUserAndGroupValidity() {
|
public void testChownUserAndGroupValidity() {
|
||||||
// This test only covers argument parsing, so override to skip processing.
|
testChownUserAndGroupValidity(true);
|
||||||
FsCommand chown = new FsShellPermissions.Chown() {
|
testChownUserAndGroupValidity(false);
|
||||||
@Override
|
}
|
||||||
protected void processArgument(PathData item) {
|
|
||||||
}
|
private void testChownUserAndGroupValidity(boolean enableWarning) {
|
||||||
};
|
Configuration conf = new Configuration();
|
||||||
chown.setConf(new Configuration());
|
conf.setBoolean(
|
||||||
|
HADOOP_SHELL_MISSING_DEFAULT_FS_WARNING_KEY, enableWarning);
|
||||||
|
FsCommand chown = new FakeChown();
|
||||||
|
chown.setConf(conf);
|
||||||
|
|
||||||
// The following are valid (no exception expected).
|
// The following are valid (no exception expected).
|
||||||
chown.run("user", "/path");
|
chown.run("user", "/path");
|
||||||
|
@ -446,18 +462,32 @@ public class TestFsShellReturnCode {
|
||||||
assertIllegalArguments(chown, ":gr%oup", "/path");
|
assertIllegalArguments(chown, ":gr%oup", "/path");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Faked Chgrp class for {@link testChgrpGroupValidity()}.
|
||||||
|
* The test only covers argument parsing, so override to skip processing.
|
||||||
|
*/
|
||||||
|
private static class FakeChgrp extends FsShellPermissions.Chgrp {
|
||||||
|
public static String NAME = "chgrp";
|
||||||
|
@Override
|
||||||
|
protected void processArgument(PathData item) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests valid and invalid group arguments to chgrp.
|
* Tests valid and invalid group arguments to chgrp.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testChgrpGroupValidity() {
|
public void testChgrpGroupValidity() {
|
||||||
// This test only covers argument parsing, so override to skip processing.
|
testChgrpGroupValidity(true);
|
||||||
FsCommand chgrp = new FsShellPermissions.Chgrp() {
|
testChgrpGroupValidity(false);
|
||||||
@Override
|
}
|
||||||
protected void processArgument(PathData item) {
|
|
||||||
}
|
private void testChgrpGroupValidity(boolean enableWarning) {
|
||||||
};
|
Configuration conf = new Configuration();
|
||||||
chgrp.setConf(new Configuration());
|
conf.setBoolean(
|
||||||
|
HADOOP_SHELL_MISSING_DEFAULT_FS_WARNING_KEY, enableWarning);
|
||||||
|
FsShellPermissions.Chgrp chgrp = new FakeChgrp();
|
||||||
|
chgrp.setConf(conf);
|
||||||
|
|
||||||
// The following are valid (no exception expected).
|
// The following are valid (no exception expected).
|
||||||
chgrp.run("group", "/path");
|
chgrp.run("group", "/path");
|
||||||
|
|
|
@ -114,6 +114,7 @@ public class TestMove {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class InstrumentedRenameCommand extends MoveCommands.Rename {
|
private static class InstrumentedRenameCommand extends MoveCommands.Rename {
|
||||||
|
public static String NAME = "InstrumentedRename";
|
||||||
private Exception error = null;
|
private Exception error = null;
|
||||||
@Override
|
@Override
|
||||||
public void displayError(Exception e) {
|
public void displayError(Exception e) {
|
||||||
|
|
Loading…
Reference in New Issue