chia7712 commented on code in PR #16493: URL: https://github.com/apache/kafka/pull/16493#discussion_r1726357478
########## core/src/test/java/kafka/test/ClusterInstance.java: ########## @@ -204,4 +210,28 @@ default void waitForTopic(String topic, int partitions) throws InterruptedExcept 60000L, "Timeout waiting for controller metadata propagating to brokers"); } } + + default List<Authorizer> authorizers() { + List<Authorizer> authorizers = new ArrayList<>(); + authorizers.addAll(brokers().values().stream() + .filter(server -> server.authorizer().isDefined()) + .map(server -> server.authorizer().get()).collect(Collectors.toList())); + authorizers.addAll(controllers().values().stream() + .filter(server -> server.authorizer().isDefined()) + .map(server -> server.authorizer().get()).collect(Collectors.toList())); + return authorizers; + } + + default void waitAcls(AclBindingFilter filter, Collection<AccessControlEntry> entries) throws InterruptedException { + for (Authorizer authorizer : authorizers()) { + AtomicReference<Set<AccessControlEntry>> actualEntries = new AtomicReference<>(new HashSet<>()); + TestUtils.waitForCondition(() -> { + Set<AccessControlEntry> accessControlEntrySet = new HashSet<>(); + authorizer.acls(filter).forEach(aclBinding -> accessControlEntrySet.add(aclBinding.entry())); + actualEntries.set(accessControlEntrySet); + return accessControlEntrySet.containsAll(entries) && entries.containsAll(accessControlEntrySet); + }, () -> "except acls: " + entries + ", actual acls: " + actualEntries.get()); Review Comment: `expected acls: ########## core/src/main/scala/kafka/admin/AclCommand.scala: ########## @@ -626,18 +637,22 @@ object AclCommand extends Logging { options = parser.parse(args: _*) def checkArgs(): Unit = { - if (options.has(bootstrapServerOpt) && options.has(authorizerOpt)) - CommandLineUtils.printUsageAndExit(parser, "Only one of --bootstrap-server or --authorizer must be specified") + if (options.has(bootstrapServerOpt) && options.has(bootstrapControllerOpt)) + CommandLineUtils.printUsageAndExit(parser, "Only one of --bootstrap-server or --bootstrap-controller must be specified") + + val hasServerOrController = options.has(bootstrapServerOpt) || options.has(bootstrapControllerOpt) + if (hasServerOrController && options.has(authorizerOpt)) + CommandLineUtils.printUsageAndExit(parser, "The --authorizer option can only be used without --bootstrap-server or --bootstrap-controller") - if (!options.has(bootstrapServerOpt)) { + if (!hasServerOrController) { CommandLineUtils.checkRequiredArgs(parser, options, authorizerPropertiesOpt) System.err.println(AclCommand.AuthorizerDeprecationMessage) } - if (options.has(commandConfigOpt) && !options.has(bootstrapServerOpt)) - CommandLineUtils.printUsageAndExit(parser, "The --command-config option can only be used with --bootstrap-server option") + if (options.has(commandConfigOpt) && (!hasServerOrController)) + CommandLineUtils.printUsageAndExit(parser, "The --command-config option can only be used with --bootstrap-server or --bootstrap-controller option") - if (options.has(authorizerPropertiesOpt) && options.has(bootstrapServerOpt)) + if (options.has(authorizerPropertiesOpt) && (hasServerOrController)) Review Comment: nit: `if (options.has(authorizerPropertiesOpt) && hasServerOrController)` -- 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