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 vi...@apache.org on 2015/09/26 18:08:01 UTC
[1/2] hadoop git commit: HADOOP-12442. Display help if the command
option to 'hdfs dfs' is not valid (Contributed by nijel)
Repository: hadoop
Updated Branches:
refs/heads/branch-2 e5dc723d4 -> b46e4ceaf
refs/heads/trunk 7a3c381b3 -> 861b52db2
HADOOP-12442. Display help if the command option to 'hdfs dfs' is not valid (Contributed by nijel)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/861b52db
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/861b52db
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/861b52db
Branch: refs/heads/trunk
Commit: 861b52db242f238d7e36ad75c158025be959a696
Parents: 7a3c381
Author: Vinayakumar B <vi...@apache.org>
Authored: Sat Sep 26 21:36:17 2015 +0530
Committer: Vinayakumar B <vi...@apache.org>
Committed: Sat Sep 26 21:36:17 2015 +0530
----------------------------------------------------------------------
hadoop-common-project/hadoop-common/CHANGES.txt | 3 ++
.../main/java/org/apache/hadoop/fs/FsShell.java | 1 +
.../java/org/apache/hadoop/fs/TestFsShell.java | 33 ++++++++++++++++++++
3 files changed, 37 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/861b52db/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 2803a90..77929dc 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -1156,6 +1156,9 @@ Release 2.8.0 - UNRELEASED
HADOOP-12437. Allow SecurityUtil to lookup alternate hostnames.
(Arpit Agarwal)
+ HADOOP-12442. Display help if the command option to 'hdfs dfs' is not valid
+ (nijel via vinayakumarb)
+
Release 2.7.2 - UNRELEASED
INCOMPATIBLE CHANGES
http://git-wip-us.apache.org/repos/asf/hadoop/blob/861b52db/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java
index a0510be..35608e2 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java
@@ -313,6 +313,7 @@ public class FsShell extends Configured implements Tool {
}
} catch (IllegalArgumentException e) {
displayError(cmd, e.getLocalizedMessage());
+ printUsage(System.err);
if (instance != null) {
printInstanceUsage(System.err, instance);
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/861b52db/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShell.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShell.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShell.java
index 59fcbe5..cc93d68 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShell.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShell.java
@@ -17,8 +17,12 @@
*/
package org.apache.hadoop.fs;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
import junit.framework.AssertionFailedError;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.tracing.SetSpanReceiver;
import org.apache.hadoop.tracing.SpanReceiverHost;
import org.apache.hadoop.util.ToolRunner;
@@ -67,4 +71,33 @@ public class TestFsShell {
SetSpanReceiver.getMap()
.get("help").get(0).getKVAnnotations().get("args"));
}
+
+ @Test
+ public void testDFSWithInvalidCommmand() throws Throwable {
+ Configuration conf = new Configuration();
+ FsShell shell = new FsShell(conf);
+ String[] args = new String[1];
+ args[0] = "dfs -mkdirs";
+ final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ final PrintStream out = new PrintStream(bytes);
+ final PrintStream oldErr = System.err;
+ try {
+ System.setErr(out);
+ ToolRunner.run(shell, args);
+ String errorValue=new String(bytes.toString());
+ Assert
+ .assertTrue(
+ "FSShell dfs command did not print the error " +
+ "message when invalid command is passed",
+ errorValue.contains("-mkdirs: Unknown command"));
+ Assert
+ .assertTrue(
+ "FSShell dfs command did not print help " +
+ "message when invalid command is passed",
+ errorValue.contains("Usage: hadoop fs [generic options]"));
+ } finally {
+ IOUtils.closeStream(out);
+ System.setErr(oldErr);
+ }
+ }
}
[2/2] hadoop git commit: HADOOP-12442. Display help if the command
option to 'hdfs dfs' is not valid (Contributed by nijel)
Posted by vi...@apache.org.
HADOOP-12442. Display help if the command option to 'hdfs dfs' is not valid (Contributed by nijel)
(cherry picked from commit 861b52db242f238d7e36ad75c158025be959a696)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/b46e4cea
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b46e4cea
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b46e4cea
Branch: refs/heads/branch-2
Commit: b46e4ceafd2648527bf8985bd9a78f274bd5a408
Parents: e5dc723
Author: Vinayakumar B <vi...@apache.org>
Authored: Sat Sep 26 21:36:17 2015 +0530
Committer: Vinayakumar B <vi...@apache.org>
Committed: Sat Sep 26 21:37:24 2015 +0530
----------------------------------------------------------------------
hadoop-common-project/hadoop-common/CHANGES.txt | 3 ++
.../main/java/org/apache/hadoop/fs/FsShell.java | 1 +
.../java/org/apache/hadoop/fs/TestFsShell.java | 33 ++++++++++++++++++++
3 files changed, 37 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/b46e4cea/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 3641882..f9d516a 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -651,6 +651,9 @@ Release 2.8.0 - UNRELEASED
HADOOP-12437. Allow SecurityUtil to lookup alternate hostnames.
(Arpit Agarwal)
+ HADOOP-12442. Display help if the command option to 'hdfs dfs' is not valid
+ (nijel via vinayakumarb)
+
Release 2.7.2 - UNRELEASED
INCOMPATIBLE CHANGES
http://git-wip-us.apache.org/repos/asf/hadoop/blob/b46e4cea/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java
index a0510be..35608e2 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java
@@ -313,6 +313,7 @@ public class FsShell extends Configured implements Tool {
}
} catch (IllegalArgumentException e) {
displayError(cmd, e.getLocalizedMessage());
+ printUsage(System.err);
if (instance != null) {
printInstanceUsage(System.err, instance);
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/b46e4cea/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShell.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShell.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShell.java
index 59fcbe5..cc93d68 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShell.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShell.java
@@ -17,8 +17,12 @@
*/
package org.apache.hadoop.fs;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
import junit.framework.AssertionFailedError;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.tracing.SetSpanReceiver;
import org.apache.hadoop.tracing.SpanReceiverHost;
import org.apache.hadoop.util.ToolRunner;
@@ -67,4 +71,33 @@ public class TestFsShell {
SetSpanReceiver.getMap()
.get("help").get(0).getKVAnnotations().get("args"));
}
+
+ @Test
+ public void testDFSWithInvalidCommmand() throws Throwable {
+ Configuration conf = new Configuration();
+ FsShell shell = new FsShell(conf);
+ String[] args = new String[1];
+ args[0] = "dfs -mkdirs";
+ final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ final PrintStream out = new PrintStream(bytes);
+ final PrintStream oldErr = System.err;
+ try {
+ System.setErr(out);
+ ToolRunner.run(shell, args);
+ String errorValue=new String(bytes.toString());
+ Assert
+ .assertTrue(
+ "FSShell dfs command did not print the error " +
+ "message when invalid command is passed",
+ errorValue.contains("-mkdirs: Unknown command"));
+ Assert
+ .assertTrue(
+ "FSShell dfs command did not print help " +
+ "message when invalid command is passed",
+ errorValue.contains("Usage: hadoop fs [generic options]"));
+ } finally {
+ IOUtils.closeStream(out);
+ System.setErr(oldErr);
+ }
+ }
}