chia7712 commented on code in PR #16493: URL: https://github.com/apache/kafka/pull/16493#discussion_r1743152201
########## core/src/test/java/kafka/admin/AclCommandTest.java: ########## @@ -246,32 +275,54 @@ public void testProducerConsumerCliWithAuthorizer(ClusterInstance cluster) { @ClusterConfigProperty(key = AUTHORIZER_CLASS_NAME_CONFIG, value = STANDARD_AUTHORIZER) }) }) - public void testProducerConsumerCliWithAdminAPI(ClusterInstance cluster) { + public void testProducerConsumerCliWithAdminAPI(ClusterInstance cluster) throws InterruptedException { testProducerConsumerCli(cluster, adminArgs(cluster.bootstrapServers(), Optional.empty())); } + @ClusterTest(types = {Type.KRAFT}, serverProperties = { + @ClusterConfigProperty(key = AUTHORIZER_CLASS_NAME_CONFIG, value = STANDARD_AUTHORIZER) + }) + public void testProducerConsumerCliWithAdminAPIAndBootstrapController(ClusterInstance cluster) throws InterruptedException { + testProducerConsumerCli(cluster, adminArgsWithBootstrapController(cluster.bootstrapControllers(), Optional.empty())); + } + @ClusterTests({ @ClusterTest(types = {Type.ZK}), @ClusterTest(types = {Type.KRAFT}, serverProperties = { @ClusterConfigProperty(key = AUTHORIZER_CLASS_NAME_CONFIG, value = STANDARD_AUTHORIZER) }) }) public void testAclCliWithClientId(ClusterInstance cluster) { - LogCaptureAppender appender = LogCaptureAppender.createAndRegister(); - appender.setClassLogger(AppInfoParser.class, Level.WARN); - try { + try (LogCaptureAppender appender = LogCaptureAppender.createAndRegister()) { + appender.setClassLogger(AppInfoParser.class, Level.WARN); testAclCli(cluster, adminArgs(cluster.bootstrapServers(), Optional.of(TestUtils.tempFile("client.id=my-client")))); - } finally { - appender.close(); + assertEquals(0, appender.getEvents().stream() + .filter(e -> e.getLevel().equals(Level.WARN.toString())) + .filter(e -> e.getThrowableClassName().filter(name -> name.equals(InstanceAlreadyExistsException.class.getName())).isPresent()) + .count(), "There should be no warnings about multiple registration of mbeans"); + } catch (InterruptedException | IOException e) { Review Comment: we don't need to catch the exception. Instead, we can add the exception to the method signature. ########## core/src/test/java/kafka/admin/AclCommandTest.java: ########## @@ -246,32 +275,54 @@ public void testProducerConsumerCliWithAuthorizer(ClusterInstance cluster) { @ClusterConfigProperty(key = AUTHORIZER_CLASS_NAME_CONFIG, value = STANDARD_AUTHORIZER) }) }) - public void testProducerConsumerCliWithAdminAPI(ClusterInstance cluster) { + public void testProducerConsumerCliWithAdminAPI(ClusterInstance cluster) throws InterruptedException { testProducerConsumerCli(cluster, adminArgs(cluster.bootstrapServers(), Optional.empty())); } + @ClusterTest(types = {Type.KRAFT}, serverProperties = { + @ClusterConfigProperty(key = AUTHORIZER_CLASS_NAME_CONFIG, value = STANDARD_AUTHORIZER) + }) + public void testProducerConsumerCliWithAdminAPIAndBootstrapController(ClusterInstance cluster) throws InterruptedException { + testProducerConsumerCli(cluster, adminArgsWithBootstrapController(cluster.bootstrapControllers(), Optional.empty())); + } + @ClusterTests({ @ClusterTest(types = {Type.ZK}), @ClusterTest(types = {Type.KRAFT}, serverProperties = { @ClusterConfigProperty(key = AUTHORIZER_CLASS_NAME_CONFIG, value = STANDARD_AUTHORIZER) }) }) public void testAclCliWithClientId(ClusterInstance cluster) { - LogCaptureAppender appender = LogCaptureAppender.createAndRegister(); - appender.setClassLogger(AppInfoParser.class, Level.WARN); - try { + try (LogCaptureAppender appender = LogCaptureAppender.createAndRegister()) { + appender.setClassLogger(AppInfoParser.class, Level.WARN); testAclCli(cluster, adminArgs(cluster.bootstrapServers(), Optional.of(TestUtils.tempFile("client.id=my-client")))); - } finally { - appender.close(); + assertEquals(0, appender.getEvents().stream() + .filter(e -> e.getLevel().equals(Level.WARN.toString())) + .filter(e -> e.getThrowableClassName().filter(name -> name.equals(InstanceAlreadyExistsException.class.getName())).isPresent()) + .count(), "There should be no warnings about multiple registration of mbeans"); + } catch (InterruptedException | IOException e) { + throw new RuntimeException(e); + } + } + + @ClusterTest(types = {Type.KRAFT}, serverProperties = { + @ClusterConfigProperty(key = AUTHORIZER_CLASS_NAME_CONFIG, value = STANDARD_AUTHORIZER) + }) + public void testAclCliWithClientIdAndBootstrapController(ClusterInstance cluster) { + try (LogCaptureAppender appender = LogCaptureAppender.createAndRegister()) { + appender.setClassLogger(AppInfoParser.class, Level.WARN); + testAclCli(cluster, adminArgsWithBootstrapController(cluster.bootstrapControllers(), Optional.of(TestUtils.tempFile("client.id=my-client")))); + assertEquals(0, appender.getEvents().stream() + .filter(e -> e.getLevel().equals(Level.WARN.toString())) + .filter(e -> e.getThrowableClassName().filter(name -> name.equals(InstanceAlreadyExistsException.class.getName())).isPresent()) + .count(), "There should be no warnings about multiple registration of mbeans"); + } catch (InterruptedException | IOException e) { Review Comment: ditto -- 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