mjsax commented on code in PR #20293: URL: https://github.com/apache/kafka/pull/20293#discussion_r2308814874
########## tools/src/test/java/org/apache/kafka/tools/streams/DeleteStreamsGroupOffsetTest.java: ########## @@ -436,4 +440,26 @@ private StreamsGroupCommand.StreamsGroupService getStreamsGroupService(String[] opts, cluster.createAdminClient()); } + + /** + * Executes the StreamsGroupCommand with the given arguments and validates the exit code. + * <p> + * This helper method is used to test scenarios where the command is expected to exit + * with a specific status code (e.g., 0 for success, 1 for an error). It captures the + * exit code by using a mock {@link Exit.Procedure} and asserts that it matches the + * expected value. + * + * @param args The command-line arguments to pass to the StreamsGroupCommand. + * @param expectedExitCode The expected exit code from the command execution. + */ + private static void validateDeleteOffsetsExitCode(String[] args, int expectedExitCode) { Review Comment: This could be much simpler, if we refactor `StreamsGroupCommand` similar to what we do in `StreamsResetter`: ``` public static void main(final String[] args) { Exit.exit(new StreamsResetter().execute(args)); } ``` We move all code from `main()` into a helper `execute()` and can use `execute()` in test to get the return code programmatically as its return value instead of jumping though all these hoops of this helper method. ########## tools/src/main/java/org/apache/kafka/tools/streams/StreamsGroupCommand.java: ########## @@ -98,12 +99,19 @@ public static void main(String[] args) { CommandLineUtils.printUsageAndExit(opts.parser, "Command must include exactly one action: --list, --describe, --delete, --reset-offsets, or --delete-offsets."); run(opts); - } catch (OptionException e) { Review Comment: Why do we now catch `OptionException` any longer? -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org