balodesecurity commented on code in PR #8324:
URL: https://github.com/apache/hadoop/pull/8324#discussion_r3068004941


##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/command/TestDiskBalancerCommand.java:
##########
@@ -756,6 +756,33 @@ public void testHelpCommand() throws Exception {
     runCommand(cmdLine);
   }
 
+  /**
+   * HDFS-17809: "-help <command>" must display command-specific help text,
+   * not just the generic usage summary.
+   */
+  @Test
+  @Timeout(value = 60)
+  public void testHelpCommandWithSubCommand() throws Exception {
+    // Each sub-command help should contain its own option/keyword.
+    String[][] subCommands = {
+        {PLAN,    "plan"},
+        {EXECUTE, "execute"},
+        {QUERY,   "query"},
+        {CANCEL,  "cancel"},
+        {REPORT,  "report"},
+    };
+    for (String[] pair : subCommands) {
+      String subCmd = pair[0];
+      String expectedToken = pair[1];
+      String cmdLine = String.format("hdfs diskbalancer -%s %s", HELP, subCmd);
+      List<String> output = runCommand(cmdLine);
+      String joined = String.join("\n", output).toLowerCase();
+      assertTrue(joined.contains(expectedToken),

Review Comment:
   sure, adding a negative test case for an unknown sub-command (-help 
unknowncmd). 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to