chia7712 commented on code in PR #18463:
URL: https://github.com/apache/kafka/pull/18463#discussion_r1997658910


##########
clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/StaticBrokerConfigTest.java:
##########
@@ -0,0 +1,146 @@
+/*
+ * 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.clients.admin;
+
+
+import org.apache.kafka.common.config.ConfigResource;
+import org.apache.kafka.common.config.TopicConfig;
+import org.apache.kafka.common.test.ClusterInstance;
+import org.apache.kafka.common.test.api.ClusterConfig;
+import org.apache.kafka.common.test.api.ClusterTemplate;
+import org.apache.kafka.common.test.api.Type;
+import org.apache.kafka.common.test.junit.ClusterTestExtensions;
+import org.apache.kafka.coordinator.group.GroupCoordinatorConfig;
+
+import org.junit.jupiter.api.extension.ExtendWith;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+@ExtendWith(value = ClusterTestExtensions.class)
+public class StaticBrokerConfigTest {
+    private static final String TOPIC = "topic";
+    private static final String CUSTOM_VALUE = "1048576";
+
+    /**
+     * synonyms of `segment.bytes`
+     */
+    private static final String LOG_SEGMENT_BYTES = "log.segment.bytes";
+
+    @ClusterTemplate("controllerTestConfig")
+    public void 
testDescribeConfigsShouldNotReturnTopicRelatedQuorumControllerConfigs(ClusterInstance
 cluster)
+        throws ExecutionException, InterruptedException {
+        try (Admin admin = cluster.admin()) {
+            CreateTopicsResult createResult = admin.createTopics(List.of(new 
NewTopic(TOPIC, 1, (short) 1)));
+            ConfigEntry config = 
createResult.config(TOPIC).get().get(TopicConfig.SEGMENT_BYTES_CONFIG);
+            assertNotNull(config, "Create Topic result should include static 
topic config");
+            assertEquals(CUSTOM_VALUE, config.value(), "Config value should be 
custom value since controller have related static config");
+
+            ConfigResource resource = new 
ConfigResource(ConfigResource.Type.BROKER, "0");
+            Config keyToConfigEntry = 
admin.describeConfigs(List.of(resource)).all().get().get(resource);
+            assertNotEquals(CUSTOM_VALUE, 
keyToConfigEntry.get(LOG_SEGMENT_BYTES).value(),
+                "Config value should not be custom value since broker don't 
have related static config");
+        }
+    }
+
+    @ClusterTemplate("controllerTestConfig")
+    public void 
testDescribeConfigsShouldReturnTopicRelatedQuorumControllerConfigsWhenUsingBootstrapController(ClusterInstance
 cluster)
+        throws ExecutionException, InterruptedException {
+        try (
+            Admin admin = cluster.admin();
+            Admin adminUsingBootstrapController = cluster.admin(Map.of(), 
true);
+        ) {
+            CreateTopicsResult createResult = admin.createTopics(List.of(new 
NewTopic(TOPIC, 1, (short) 1)));
+            ConfigEntry config = 
createResult.config(TOPIC).get().get(TopicConfig.SEGMENT_BYTES_CONFIG);
+            assertNotNull(config, "Create Topic result should include static 
topic config");
+            assertEquals(CUSTOM_VALUE, config.value(), "Config value should be 
custom value since controller have related static config");
+
+            ConfigResource resource = new 
ConfigResource(ConfigResource.Type.BROKER, "3000");
+            Config keyToConfigEntry = 
adminUsingBootstrapController.describeConfigs(List.of(resource)).all().get().get(resource);
+            assertEquals(CUSTOM_VALUE, 
keyToConfigEntry.get(LOG_SEGMENT_BYTES).value(),
+                "Config value should be custom value since controller have 
related static config");
+        }
+    }
+
+    @ClusterTemplate("brokerTestConfig")
+    public void 
testDescribeConfigsShouldReturnTopicRelatedBrokerConfigsEvenIfNotInTopicCreation(ClusterInstance
 cluster)

Review Comment:
   Could you please merge 
`testDescribeConfigsShouldReturnTopicRelatedBrokerConfigsEvenIfNotInTopicCreation`
 with 
`testDescribeConfigsShouldNotReturnTopicRelatedBrokerConfigsWhenUsingBootstrapController`
 to remove the duplicate code? for example:
   ```
       @ClusterTest(types = {Type.KRAFT},
           serverProperties = {
               @ClusterConfigProperty(key = 
GroupCoordinatorConfig.OFFSETS_TOPIC_PARTITIONS_CONFIG, value = "1"),
               @ClusterConfigProperty(id = 0, key = LOG_SEGMENT_BYTES, value = 
CUSTOM_VALUE)
           })
       public void testTopicConfigsGetImpactedByStaticConfigs(ClusterInstance 
cluster) throws ExecutionException, InterruptedException {
           try (
               Admin admin = cluster.admin();
               Admin adminUsingBootstrapController = cluster.admin(Map.of(), 
true);
           ) {
               var value = admin.createTopics(List.of(new NewTopic(TOPIC, 1, 
(short) 1))).config(TOPIC).get().get(TopicConfig.SEGMENT_BYTES_CONFIG).value();
               assertNotEquals(CUSTOM_VALUE, value, "Config value should not be 
custom value since controller don't have static config");
   
               var brokerResource = new 
ConfigResource(ConfigResource.Type.BROKER, "0");
               var valueFromBroker = 
admin.describeConfigs(List.of(brokerResource)).all().get().get(brokerResource).get(LOG_SEGMENT_BYTES).value();
               assertEquals(CUSTOM_VALUE, valueFromBroker, "Config value should 
be custom value since broker have related static config");
   
               var controllerResource = new 
ConfigResource(ConfigResource.Type.BROKER, "3000");
               var valueFromController = 
adminUsingBootstrapController.describeConfigs(List.of(controllerResource)).all().get().get(controllerResource).get(LOG_SEGMENT_BYTES).value();
               assertNotEquals(CUSTOM_VALUE, valueFromController, "Config value 
should not be custom value since controller don't have related static config");
           }
       }
   ```



##########
clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/StaticBrokerConfigTest.java:
##########
@@ -0,0 +1,146 @@
+/*
+ * 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.clients.admin;
+
+
+import org.apache.kafka.common.config.ConfigResource;
+import org.apache.kafka.common.config.TopicConfig;
+import org.apache.kafka.common.test.ClusterInstance;
+import org.apache.kafka.common.test.api.ClusterConfig;
+import org.apache.kafka.common.test.api.ClusterTemplate;
+import org.apache.kafka.common.test.api.Type;
+import org.apache.kafka.common.test.junit.ClusterTestExtensions;
+import org.apache.kafka.coordinator.group.GroupCoordinatorConfig;
+
+import org.junit.jupiter.api.extension.ExtendWith;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+@ExtendWith(value = ClusterTestExtensions.class)
+public class StaticBrokerConfigTest {
+    private static final String TOPIC = "topic";
+    private static final String CUSTOM_VALUE = "1048576";
+
+    /**
+     * synonyms of `segment.bytes`
+     */
+    private static final String LOG_SEGMENT_BYTES = "log.segment.bytes";
+
+    @ClusterTemplate("controllerTestConfig")
+    public void 
testDescribeConfigsShouldNotReturnTopicRelatedQuorumControllerConfigs(ClusterInstance
 cluster)

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

Reply via email to