apoorvmittal10 commented on code in PR #14933: URL: https://github.com/apache/kafka/pull/14933#discussion_r1416631582
########## core/src/test/scala/unit/kafka/admin/ConfigCommandTest.scala: ########## @@ -1690,13 +1690,33 @@ class ConfigCommandTest extends Logging { } @Test - def shouldNotDescribeClientMetricsConfigWithoutEntityName(): Unit = { + def shouldDescribeClientMetricsConfigWithoutEntityName(): Unit = { val describeOpts = new ConfigCommandOptions(Array("--bootstrap-server", "localhost:9092", "--entity-type", "client-metrics", "--describe")) - val exception = assertThrows(classOf[IllegalArgumentException], () => describeOpts.checkArgs()) - assertEquals("an entity name must be specified with --describe of client-metrics", exception.getMessage) + val resourceCustom = new ConfigResource(ConfigResource.Type.CLIENT_METRICS, "1") + val configEntry = new ConfigEntry("metrics", "*") + val future = new KafkaFutureImpl[util.Map[ConfigResource, Config]] + val describeResult: DescribeConfigsResult = mock(classOf[DescribeConfigsResult]) + when(describeResult.all()).thenReturn(future) + + val node = new Node(1, "localhost", 9092) + val mockAdminClient = new MockAdminClient(util.Collections.singletonList(node), node) { + override def describeConfigs(resources: util.Collection[ConfigResource], options: DescribeConfigsOptions): DescribeConfigsResult = { Review Comment: When the entity-name is not provided then first all names are fetched by calling `listClientMetricsResources` and then later `describeConfigs` gets called on every entity to get the details. I have implemented `listClientMetricsResources` in `MockAdminClient` and calls `mockAdminClient.incrementalAlterConfigs` to set the client metrics resource in `MockAdminClient`. The test calls `listClientMetricsResources` from ConfigCommand.scala and result of which is passed in `describeConfigs` for validation. Later I also verify if `describeConfigs` was called. -- 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