This is an automated email from the ASF dual-hosted git repository.

chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 7b865f2b228 KAFKA-17347 Add missing client-metrics option to 
kafka-configs.sh (#17046)
7b865f2b228 is described below

commit 7b865f2b228a44feacd17d869d60fde7c2c1d73d
Author: Andrew Schofield <[email protected]>
AuthorDate: Wed Sep 11 10:01:03 2024 -0700

    KAFKA-17347 Add missing client-metrics option to kafka-configs.sh (#17046)
    
    When KIP-714 was developed, the entity type of client-metrics was added to 
the kafka-configs.sh tool. The idea was to have two forms of specifying the 
name and type of a client metrics config resource, either --entity-type 
client-metrics --entity-name NAME or --client-metrics NAME. This style of alias 
is used for all of the entity types. Unfortunately, the --client-metrics form 
was not implemented. This PR corrects that and adds more tests.
    
    Reviewers: Apoorv Mittal <[email protected]>, DL1231 
<[email protected]>, Chia-Ping Tsai <[email protected]>
---
 .../src/main/scala/kafka/admin/ConfigCommand.scala |  27 ++++--
 .../kafka/admin/ConfigCommandIntegrationTest.java  |  90 +++++++++++++++++
 .../test/java/kafka/admin/ConfigCommandTest.java   | 108 ++++++++++++++++++---
 3 files changed, 208 insertions(+), 17 deletions(-)

diff --git a/core/src/main/scala/kafka/admin/ConfigCommand.scala 
b/core/src/main/scala/kafka/admin/ConfigCommand.scala
index 2c5439f05c2..6602d879759 100644
--- a/core/src/main/scala/kafka/admin/ConfigCommand.scala
+++ b/core/src/main/scala/kafka/admin/ConfigCommand.scala
@@ -438,11 +438,13 @@ object ConfigCommand extends Logging {
             throw new IllegalStateException(s"Altering user SCRAM credentials 
should never occur for more zero or multiple users: $entityNames")
           alterUserScramCredentialConfigs(adminClient, entityNames.head, 
scramConfigsToAddMap, scramConfigsToDelete)
         }
+
       case ConfigType.IP =>
         val unknownConfigs = (configsToBeAdded.keys ++ 
configsToBeDeleted).filterNot(key => DynamicConfig.Ip.names.contains(key))
         if (unknownConfigs.nonEmpty)
           throw new IllegalArgumentException(s"Only connection quota configs 
can be added for '${ConfigType.IP}' using --bootstrap-server. Unexpected config 
names: ${unknownConfigs.mkString(",")}")
         alterQuotaConfigs(adminClient, entityTypes, entityNames, 
configsToBeAddedMap, configsToBeDeleted)
+
       case ConfigType.CLIENT_METRICS =>
         alterResourceConfig(adminClient, entityTypeHead, entityNameHead, 
configsToBeDeleted, configsToBeAdded, ConfigResource.Type.CLIENT_METRICS)
 
@@ -819,7 +821,7 @@ object ConfigCommand extends Logging {
       .ofType(classOf[String])
     val alterOpt: OptionSpecBuilder = parser.accepts("alter", "Alter the 
configuration for the entity.")
     val describeOpt: OptionSpecBuilder = parser.accepts("describe", "List 
configs for the given entity.")
-    val allOpt: OptionSpecBuilder = parser.accepts("all", "List all configs 
for the given topic, broker, or broker-logger entity (includes static 
configuration when the entity type is brokers)")
+    val allOpt: OptionSpecBuilder = parser.accepts("all", "List all configs 
for the given entity, including static configs if available.")
 
     val entityType: OptionSpec[String] = parser.accepts("entity-type", "Type 
of entity 
(topics/clients/users/brokers/broker-loggers/ips/client-metrics/groups)")
       .withRequiredArg
@@ -827,7 +829,7 @@ object ConfigCommand extends Logging {
     val entityName: OptionSpec[String] = parser.accepts("entity-name", "Name 
of entity (topic name/client id/user principal name/broker id/ip/client 
metrics/group id)")
       .withRequiredArg
       .ofType(classOf[String])
-    private val entityDefault: OptionSpecBuilder = 
parser.accepts("entity-default", "Default entity name for 
clients/users/brokers/ips (applies to corresponding entity type in command 
line)")
+    private val entityDefault: OptionSpecBuilder = 
parser.accepts("entity-default", "Default entity name for 
clients/users/brokers/ips (applies to corresponding entity type)")
 
     val nl: String = System.lineSeparator()
     val addConfig: OptionSpec[String] = parser.accepts("add-config", "Key 
Value pairs of configs to add. Square brackets can be used to group values 
which contain commas: 'k1=v1,k2=[v1,v2,v2],k3=v3'. The following is a list of 
valid configurations: " +
@@ -874,6 +876,9 @@ object ConfigCommand extends Logging {
     val group: OptionSpec[String] = parser.accepts("group", "The group's ID.")
       .withRequiredArg
       .ofType(classOf[String])
+    val clientMetrics: OptionSpec[String] = parser.accepts("client-metrics", 
"The client metrics config resource name.")
+      .withRequiredArg
+      .ofType(classOf[String])
     val zkTlsConfigFile: OptionSpec[String] = 
parser.accepts("zk-tls-config-file",
       "Identifies the file where ZooKeeper client TLS connectivity properties 
are defined.  Any properties other than " +
         
ZkConfigs.ZK_SSL_CONFIG_TO_SYSTEM_PROPERTY_MAP.asScala.keys.toList.sorted.mkString(",
 ") + " are ignored.")
@@ -886,6 +891,7 @@ object ConfigCommand extends Logging {
       (broker, ConfigType.BROKER),
       (brokerLogger, BrokerLoggerConfigType),
       (ip, ConfigType.IP),
+      (clientMetrics, ConfigType.CLIENT_METRICS),
       (group, ConfigType.GROUP))
 
     private val entityDefaultsFlags = List((clientDefaults, ConfigType.CLIENT),
@@ -975,8 +981,17 @@ object ConfigCommand extends Logging {
         }
       }
 
-      if (options.has(describeOpt) && 
entityTypeVals.contains(BrokerLoggerConfigType) && !hasEntityName)
-        throw new IllegalArgumentException(s"an entity name must be specified 
with --describe of ${entityTypeVals.mkString(",")}")
+      if (options.has(describeOpt)) {
+        if (!(entityTypeVals.contains(ConfigType.USER) ||
+          entityTypeVals.contains(ConfigType.CLIENT) ||
+          entityTypeVals.contains(ConfigType.BROKER) ||
+          entityTypeVals.contains(ConfigType.IP)) && 
options.has(entityDefault)) {
+          throw new IllegalArgumentException(s"--entity-default must not be 
specified with --describe of ${entityTypeVals.mkString(",")}")
+        }
+
+        if (entityTypeVals.contains(BrokerLoggerConfigType) && !hasEntityName)
+          throw new IllegalArgumentException(s"An entity name must be 
specified with --describe of ${entityTypeVals.mkString(",")}")
+      }
 
       if (options.has(alterOpt)) {
         if (entityTypeVals.contains(ConfigType.USER) ||
@@ -984,9 +999,9 @@ object ConfigCommand extends Logging {
             entityTypeVals.contains(ConfigType.BROKER) ||
             entityTypeVals.contains(ConfigType.IP)) {
           if (!hasEntityName && !hasEntityDefault)
-            throw new IllegalArgumentException("an entity-name or default 
entity must be specified with --alter of users, clients, brokers or ips")
+            throw new IllegalArgumentException("An entity-name or default 
entity must be specified with --alter of users, clients, brokers or ips")
         } else if (!hasEntityName)
-          throw new IllegalArgumentException(s"an entity name must be 
specified with --alter of ${entityTypeVals.mkString(",")}")
+          throw new IllegalArgumentException(s"An entity name must be 
specified with --alter of ${entityTypeVals.mkString(",")}")
 
         val isAddConfigPresent = options.has(addConfig)
         val isAddConfigFilePresent = options.has(addConfigFile)
diff --git a/core/src/test/java/kafka/admin/ConfigCommandIntegrationTest.java 
b/core/src/test/java/kafka/admin/ConfigCommandIntegrationTest.java
index 36fd2252658..c2941847b27 100644
--- a/core/src/test/java/kafka/admin/ConfigCommandIntegrationTest.java
+++ b/core/src/test/java/kafka/admin/ConfigCommandIntegrationTest.java
@@ -79,6 +79,7 @@ public class ConfigCommandIntegrationTest {
     private List<String> alterOpts;
     private final String defaultBrokerId = "0";
     private final String defaultGroupName = "group";
+    private final String defaultClientMetricsName = "cm";
     private final ClusterInstance cluster;
 
     private static Runnable run(Stream<String> command) {
@@ -131,6 +132,21 @@ public class ConfigCommandIntegrationTest {
             errOut -> assertTrue(errOut.contains("Invalid entity type groups, 
the entity type must be one of users, brokers with a --zookeeper argument"), 
errOut));
     }
 
+    @ClusterTest(types = {Type.ZK})
+    public void testExitWithNonZeroStatusOnZkCommandAlterClientMetrics() {
+        assertNonZeroStatusExit(Stream.concat(quorumArgs(), Stream.of(
+                        "--entity-type", "client-metrics",
+                        "--entity-name", "cm",
+                        "--alter", "--add-config", "metrics=org.apache")),
+                errOut -> assertTrue(errOut.contains("Invalid entity type 
client-metrics, the entity type must be one of users, brokers with a 
--zookeeper argument"), errOut));
+
+        // Test for the --client-metrics alias
+        assertNonZeroStatusExit(Stream.concat(quorumArgs(), Stream.of(
+                        "--client-metrics", "cm",
+                        "--alter", "--add-config", 
"consumer.session.timeout.ms=50000")),
+                errOut -> assertTrue(errOut.contains("Invalid entity type 
client-metrics, the entity type must be one of users, brokers with a 
--zookeeper argument"), errOut));
+    }
+
     @ClusterTest(types = {Type.CO_KRAFT, Type.KRAFT})
     public void testNullStatusOnKraftCommandAlterUserQuota() {
         Stream<String> command = Stream.concat(quorumArgs(), Stream.of(
@@ -159,6 +175,23 @@ public class ConfigCommandIntegrationTest {
         assertTrue(StringUtils.isBlank(message), message);
     }
 
+    @ClusterTest(types = {Type.CO_KRAFT, Type.KRAFT})
+    public void testNullStatusOnKraftCommandAlterClientMetrics() {
+        Stream<String> command = Stream.concat(quorumArgs(), Stream.of(
+                "--entity-type", "client-metrics",
+                "--entity-name", "cm",
+                "--alter", "--add-config", "metrics=org.apache"));
+        String message = captureStandardMsg(run(command));
+        assertTrue(StringUtils.isBlank(message), message);
+
+        // Test for the --client-metrics alias
+        command = Stream.concat(quorumArgs(), Stream.of(
+                "--client-metrics", "cm",
+                "--alter", "--add-config", "metrics=org.apache"));
+        message = captureStandardMsg(run(command));
+        assertTrue(StringUtils.isBlank(message), message);
+    }
+
     @ClusterTest(types = Type.ZK)
     public void testDynamicBrokerConfigUpdateUsingZooKeeper() throws Exception 
{
         cluster.shutdownBroker(0);
@@ -319,6 +352,35 @@ public class ConfigCommandIntegrationTest {
         }
     }
 
+
+    @ClusterTest(types = {Type.KRAFT})
+    public void testClientMetricsConfigUpdate() throws Exception {
+        alterOpts = asList("--bootstrap-server", cluster.bootstrapServers(), 
"--entity-type", "client-metrics", "--alter");
+        verifyClientMetricsConfigUpdate();
+
+        // Test for the --client-metrics alias
+        alterOpts = asList("--bootstrap-server", cluster.bootstrapServers(), 
"--client-metrics", "--alter");
+        verifyClientMetricsConfigUpdate();
+    }
+
+    private void verifyClientMetricsConfigUpdate() throws Exception {
+        try (Admin client = cluster.createAdminClient()) {
+            // Add config
+            Map<String, String> configs = new HashMap<>();
+            configs.put("metrics", "");
+            configs.put("interval.ms", "6000");
+            alterAndVerifyClientMetricsConfig(client, 
defaultClientMetricsName, configs);
+
+            // Delete config
+            deleteAndVerifyClientMetricsConfigValue(client, 
defaultClientMetricsName, configs.keySet());
+
+            // Unknown config configured should fail
+            assertThrows(ExecutionException.class,
+                () -> alterConfigWithKraft(client, 
Optional.of(defaultClientMetricsName),
+                    singletonMap("unknown.config", "20000")));
+        }
+    }
+
     @ClusterTest(types = {Type.ZK})
     public void testAlterReadOnlyConfigInZookeeperThenShouldFail() {
         cluster.shutdownBroker(0);
@@ -556,6 +618,11 @@ public class ConfigCommandIntegrationTest {
         verifyGroupConfig(client, groupName, config);
     }
 
+    private void alterAndVerifyClientMetricsConfig(Admin client, String 
clientMetricsName, Map<String, String> config) throws Exception {
+        alterConfigWithKraft(client, Optional.of(clientMetricsName), config);
+        verifyClientMetricsConfig(client, clientMetricsName, config);
+    }
+
     private void alterConfigWithKraft(Admin client, Optional<String> 
resourceName, Map<String, String> config) {
         String configStr = transferConfigMapToString(config);
         ConfigCommand.ConfigCommandOptions addOpts =
@@ -583,6 +650,18 @@ public class ConfigCommandIntegrationTest {
         }, 10000, config + " are not updated");
     }
 
+    private void verifyClientMetricsConfig(Admin client, String 
clientMetricsName, Map<String, String> config) throws Exception {
+        ConfigResource configResource = new 
ConfigResource(ConfigResource.Type.CLIENT_METRICS, clientMetricsName);
+        TestUtils.waitForCondition(() -> {
+            Map<String, String> current = getConfigEntryStream(client, 
configResource)
+                    .filter(configEntry -> 
Objects.nonNull(configEntry.value()))
+                    .collect(Collectors.toMap(ConfigEntry::name, 
ConfigEntry::value));
+            if (config.isEmpty())
+                return current.isEmpty();
+            return config.entrySet().stream().allMatch(e -> 
e.getValue().equals(current.get(e.getKey())));
+        }, 10000, config + " are not updated");
+    }
+
     private Stream<ConfigEntry> getConfigEntryStream(Admin client,
                                                      ConfigResource 
configResource) throws InterruptedException, ExecutionException {
         return client.describeConfigs(singletonList(configResource))
@@ -614,6 +693,17 @@ public class ConfigCommandIntegrationTest {
         verifyGroupConfig(client, groupName, defaultConfigs);
     }
 
+    private void deleteAndVerifyClientMetricsConfigValue(Admin client,
+                                                         String 
clientMetricsName,
+                                                         Set<String> 
defaultConfigs) throws Exception {
+        ConfigCommand.ConfigCommandOptions deleteOpts =
+            new ConfigCommand.ConfigCommandOptions(toArray(alterOpts, 
asList("--entity-name", clientMetricsName),
+                asList("--delete-config", String.join(",", defaultConfigs))));
+        ConfigCommand.alterConfig(client, deleteOpts);
+        // There are no default configs returned for client metrics
+        verifyClientMetricsConfig(client, clientMetricsName, 
Collections.emptyMap());
+    }
+
     private void verifyPerBrokerConfigValue(Admin client,
                                             String brokerId,
                                             Set<String> config,
diff --git a/core/src/test/java/kafka/admin/ConfigCommandTest.java 
b/core/src/test/java/kafka/admin/ConfigCommandTest.java
index 82426c8939c..3535374b6e0 100644
--- a/core/src/test/java/kafka/admin/ConfigCommandTest.java
+++ b/core/src/test/java/kafka/admin/ConfigCommandTest.java
@@ -416,6 +416,65 @@ public class ConfigCommandTest {
         assertThrows(IllegalArgumentException.class, createOpts::checkArgs);
     }
 
+    @Test
+    public void testEntityDefaultForType() {
+        ConfigCommand.ConfigCommandOptions createOpts = new 
ConfigCommand.ConfigCommandOptions(toArray("--bootstrap-server", 
"localhost:9092",
+            "--entity-default",
+            "--entity-type", "topics",
+            "--describe"
+        ));
+        assertThrows(IllegalArgumentException.class, createOpts::checkArgs);
+
+        createOpts = new 
ConfigCommand.ConfigCommandOptions(toArray("--bootstrap-server", 
"localhost:9092",
+            "--entity-default",
+            "--entity-type", "clients",
+            "--describe"
+        ));
+        createOpts.checkArgs();
+
+        createOpts = new 
ConfigCommand.ConfigCommandOptions(toArray("--bootstrap-server", 
"localhost:9092",
+            "--entity-default",
+            "--entity-type", "users",
+            "--describe"
+        ));
+        createOpts.checkArgs();
+
+        createOpts = new 
ConfigCommand.ConfigCommandOptions(toArray("--bootstrap-server", 
"localhost:9092",
+            "--entity-default",
+            "--entity-type", "brokers",
+            "--describe"
+        ));
+        createOpts.checkArgs();
+
+        createOpts = new 
ConfigCommand.ConfigCommandOptions(toArray("--bootstrap-server", 
"localhost:9092",
+            "--entity-default",
+            "--entity-type", "broker-loggers",
+            "--describe"
+        ));
+        assertThrows(IllegalArgumentException.class, createOpts::checkArgs);
+
+        createOpts = new 
ConfigCommand.ConfigCommandOptions(toArray("--bootstrap-server", 
"localhost:9092",
+            "--entity-default",
+            "--entity-type", "ips",
+            "--describe"
+        ));
+        createOpts.checkArgs();
+
+        createOpts = new 
ConfigCommand.ConfigCommandOptions(toArray("--bootstrap-server", 
"localhost:9092",
+            "--entity-default",
+            "--entity-type", "client-metrics",
+            "--describe"
+        ));
+        assertThrows(IllegalArgumentException.class, createOpts::checkArgs);
+
+        createOpts = new 
ConfigCommand.ConfigCommandOptions(toArray("--bootstrap-server", 
"localhost:9092",
+            "--entity-default",
+            "--entity-type", "groups",
+            "--describe"
+        ));
+        assertThrows(IllegalArgumentException.class, createOpts::checkArgs);
+    }
+
     @Test
     public void testParseConfigsToBeAddedForAddConfigFile() throws IOException 
{
         String fileContents =
@@ -459,6 +518,7 @@ public class ConfigCommandTest {
         if (!zkConfig) {
             
testExpectedEntityTypeNames(Collections.singletonList(ConfigType.TOPIC), 
Collections.singletonList("A"), connectOpts, "--entity-type", "topics", 
"--entity-name", "A");
             
testExpectedEntityTypeNames(Collections.singletonList(ConfigType.IP), 
Collections.singletonList("1.2.3.4"), connectOpts, "--entity-name", "1.2.3.4", 
"--entity-type", "ips");
+            
testExpectedEntityTypeNames(Collections.singletonList(ConfigType.CLIENT_METRICS),
 Collections.singletonList("A"), connectOpts, "--entity-type", 
"client-metrics", "--entity-name", "A");
             
testExpectedEntityTypeNames(Collections.singletonList(ConfigType.GROUP), 
Collections.singletonList("A"), connectOpts, "--entity-type", "groups", 
"--entity-name", "A");
             testExpectedEntityTypeNames(Arrays.asList(ConfigType.USER, 
ConfigType.CLIENT), Arrays.asList("A", ""), connectOpts,
                 "--entity-type", "users", "--entity-type", "clients", 
"--entity-name", "A", "--entity-default");
@@ -474,6 +534,7 @@ public class ConfigCommandTest {
             
testExpectedEntityTypeNames(Collections.singletonList(ConfigType.TOPIC), 
Collections.emptyList(), connectOpts, "--entity-type", "topics");
             
testExpectedEntityTypeNames(Collections.singletonList(ConfigType.IP), 
Collections.emptyList(), connectOpts, "--entity-type", "ips");
             
testExpectedEntityTypeNames(Collections.singletonList(ConfigType.GROUP), 
Collections.emptyList(), connectOpts, "--entity-type", "groups");
+            
testExpectedEntityTypeNames(Collections.singletonList(ConfigType.CLIENT_METRICS),
 Collections.emptyList(), connectOpts, "--entity-type", "client-metrics");
         }
 
         
testExpectedEntityTypeNames(Collections.singletonList(ConfigType.BROKER), 
Collections.singletonList("0"), connectOpts, "--entity-name", "0", 
"--entity-type", "brokers");
@@ -1802,12 +1863,15 @@ public class ConfigCommandTest {
     @Test
     public void shouldAlterClientMetricsConfig() {
         Node node = new Node(1, "localhost", 9092);
-        verifyAlterClientMetricsConfig(node, "1", 
Arrays.asList("--entity-name", "1"));
+        verifyAlterClientMetricsConfig(node, "1", 
Arrays.asList("--entity-type", "client-metrics", "--entity-name", "1"));
+
+        // Test for the --client-metrics alias
+        node = new Node(1, "localhost", 9092);
+        verifyAlterClientMetricsConfig(node, "1", 
Arrays.asList("--client-metrics", "1"));
     }
 
     private void verifyAlterClientMetricsConfig(Node node, String 
resourceName, List<String> resourceOpts) {
         List<String> optsList = concat(Arrays.asList("--bootstrap-server", 
"localhost:9092",
-            "--entity-type", "client-metrics",
             "--alter",
             "--delete-config", "interval.ms",
             "--add-config", "metrics=org.apache.kafka.consumer.," +
@@ -1905,7 +1969,7 @@ public class ConfigCommandTest {
             "--add-config", "interval.ms=1000"));
 
         IllegalArgumentException exception = 
assertThrows(IllegalArgumentException.class, alterOpts::checkArgs);
-        assertEquals("an entity name must be specified with --alter of 
client-metrics", exception.getMessage());
+        assertEquals("An entity name must be specified with --alter of 
client-metrics", exception.getMessage());
     }
 
     @Test
@@ -1918,6 +1982,15 @@ public class ConfigCommandTest {
 
         IllegalArgumentException exception = 
assertThrows(IllegalArgumentException.class, alterOpts::checkArgs);
         assertEquals("Invalid entity type client-metrics, the entity type must 
be one of users, brokers with a --zookeeper argument", exception.getMessage());
+
+        // Test for the --client-metrics alias
+        alterOpts = new 
ConfigCommand.ConfigCommandOptions(toArray("--zookeeper", ZK_CONNECT,
+                "--client-metrics", "sub",
+                "--alter",
+                "--add-config", "interval.ms=1000"));
+
+        exception = assertThrows(IllegalArgumentException.class, 
alterOpts::checkArgs);
+        assertEquals("Invalid entity type client-metrics, the entity type must 
be one of users, brokers with a --zookeeper argument", exception.getMessage());
     }
 
     @Test
@@ -1929,6 +2002,14 @@ public class ConfigCommandTest {
 
         IllegalArgumentException exception = 
assertThrows(IllegalArgumentException.class, describeOpts::checkArgs);
         assertEquals("Invalid entity type client-metrics, the entity type must 
be one of users, brokers with a --zookeeper argument", exception.getMessage());
+
+        // Test for the --client-metrics alias
+        describeOpts = new 
ConfigCommand.ConfigCommandOptions(toArray("--zookeeper", ZK_CONNECT,
+                "--client-metrics", "sub",
+                "--describe"));
+
+        exception = assertThrows(IllegalArgumentException.class, 
describeOpts::checkArgs);
+        assertEquals("Invalid entity type client-metrics, the entity type must 
be one of users, brokers with a --zookeeper argument", exception.getMessage());
     }
 
     @Test
@@ -1939,8 +2020,17 @@ public class ConfigCommandTest {
             "--alter",
             "--add-config", "interval.ms=1000"));
 
-        IllegalArgumentException exception = 
assertThrows(IllegalArgumentException.class, () -> 
ConfigCommand.alterConfigWithZk(null, alterOpts, DUMMY_ADMIN_ZK_CLIENT));
-        assertEquals("client-metrics is not a known entityType. Should be one 
of List(topics, clients, users, brokers, ips)", exception.getMessage());
+        IllegalArgumentException exception = 
assertThrows(IllegalArgumentException.class, alterOpts::checkArgs);
+        assertEquals("Invalid entity type client-metrics, the entity type must 
be one of users, brokers with a --zookeeper argument", exception.getMessage());
+
+        // Test for the --client-metrics alias
+        alterOpts = new 
ConfigCommand.ConfigCommandOptions(toArray("--zookeeper", ZK_CONNECT,
+                "--client-metrics", "sub",
+                "--alter",
+                "--add-config", "interval.ms=1000"));
+
+        exception = assertThrows(IllegalArgumentException.class, 
alterOpts::checkArgs);
+        assertEquals("Invalid entity type client-metrics, the entity type must 
be one of users, brokers with a --zookeeper argument", exception.getMessage());
     }
 
     @Test
@@ -2014,13 +2104,9 @@ public class ConfigCommandTest {
     public void shouldDescribeGroupConfigWithoutEntityName() {
         ConfigCommand.ConfigCommandOptions describeOpts = new 
ConfigCommand.ConfigCommandOptions(toArray("--bootstrap-server", 
"localhost:9092",
             "--entity-type", "groups",
-            "--entity-name", "group",
             "--describe"));
-        verifyDescribeGroupConfig(describeOpts, "group");
 
-        // Test for the --group alias
-        describeOpts = new 
ConfigCommand.ConfigCommandOptions(toArray("--bootstrap-server", 
"localhost:9092", "--group", "groupUsingAlias", "--describe"));
-        verifyDescribeGroupConfig(describeOpts, "groupUsingAlias");
+        verifyDescribeGroupConfig(describeOpts, "group");
     }
 
     private void verifyDescribeGroupConfig(ConfigCommand.ConfigCommandOptions 
describeOpts, String resourceName) {
@@ -2057,7 +2143,7 @@ public class ConfigCommandTest {
             "--add-config", "consumer.heartbeat.interval.ms=6000"));
 
         IllegalArgumentException exception = 
assertThrows(IllegalArgumentException.class, alterOpts::checkArgs);
-        assertEquals("an entity name must be specified with --alter of 
groups", exception.getMessage());
+        assertEquals("An entity name must be specified with --alter of 
groups", exception.getMessage());
     }
 
     @Test

Reply via email to