fvaleri commented on code in PR #24247:
URL: https://github.com/apache/kafka/pull/24247#discussion_r4629235818


##########
clients/src/test/java/org/apache/kafka/common/requests/DescribeConfigsResponseTest.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.common.requests;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class DescribeConfigsResponseTest {
+
+    @Test

Review Comment:
   You can use the EnumSource annotation here. The benefit is that you see the 
result of any single test, rather than one including all annotations.



##########
tools/src/main/java/org/apache/kafka/tools/ConfigCommand.java:
##########
@@ -248,13 +250,19 @@ static void alterConfig(Admin adminClient, 
ConfigCommandOptions opts) throws IOE
                     validateBrokerId(entityName, entityType);
                 }
                 configResourceType = ConfigResource.Type.BROKER;
-            } else {
+            } else if (GROUP_TYPE.equals(entityType)) {
                 configResourceType = ConfigResource.Type.GROUP;
+            } else {
+                configResourceType = ConfigResource.Type.CLUSTER_MIRROR;
             }
             try {

Review Comment:
   If someone adds a new type to the outer if condition but forgets to add its 
own branch inside, it silently falls through to CLUSTER_MIRROR. The same file 
already uses `else { throw new IllegalArgumentException(...) }` as a catch-all 
in describeResourceConfig. This should follow the same pattern.



##########
metadata/src/test/java/org/apache/kafka/metadata/KafkaConfigSchemaTest.java:
##########
@@ -102,10 +102,19 @@ public void testTranslateConfigSources() {
             DescribeConfigsResponse.ConfigSource.CLIENT_METRICS_CONFIG);
         
testTranslateConfigSource(ConfigEntry.ConfigSource.DYNAMIC_GROUP_CONFIG,
             DescribeConfigsResponse.ConfigSource.GROUP_CONFIG);
+        
testTranslateConfigSource(ConfigEntry.ConfigSource.DYNAMIC_CLUSTER_MIRROR_CONFIG,
+            DescribeConfigsResponse.ConfigSource.CLUSTER_MIRROR_CONFIG);
         testTranslateConfigSource(ConfigEntry.ConfigSource.DEFAULT_CONFIG,
             DescribeConfigsResponse.ConfigSource.DEFAULT_CONFIG);
     }
 
+    @Test
+    public void testEveryConfigSourceHasWireRepresentation() {
+        for (ConfigEntry.ConfigSource source : 
ConfigEntry.ConfigSource.values()) {
+            assertEquals(source, 
KafkaConfigSchema.translateConfigSource(source).source(), source.name());
+        }
+    }
+

Review Comment:
   Same comment about using EnumSource annotation.
   
   Also, this is catching a scenario where someone adds a new 
ConfigEntry.ConfigSource and its wire counterpart but forgets to add the pair 
to testTranslateConfigSources. Maybe add a short comment about that.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to