clarkwtc commented on code in PR #19046:
URL: https://github.com/apache/kafka/pull/19046#discussion_r1973779776


##########
core/src/test/java/kafka/test/api/ProducerRebootstrapTest.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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 kafka.test.api;
+
+import kafka.server.KafkaBroker;
+import org.apache.kafka.clients.admin.Admin;
+import org.apache.kafka.clients.admin.NewTopic;
+import org.apache.kafka.clients.producer.ProducerConfig;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.kafka.clients.producer.RecordMetadata;
+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.coordinator.group.GroupCoordinatorConfig;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.stream.Stream;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class ProducerRebootstrapTest {
+    private static final int BROKER_COUNT = 2;
+
+    static List<ClusterConfig> generator() {
+        Map<String, String> serverProperties = new HashMap<>();
+        // Enable unclean leader election for the test topic
+        
serverProperties.put(TopicConfig.UNCLEAN_LEADER_ELECTION_ENABLE_CONFIG, "true");
+        
serverProperties.put(GroupCoordinatorConfig.OFFSETS_TOPIC_REPLICATION_FACTOR_CONFIG,
 String.valueOf(BROKER_COUNT));
+
+        return Stream.of(false, true)
+                .map(ProducerRebootstrapTest::getRebootstrapConfig)
+                .map(rebootstrapProperties -> 
ProducerRebootstrapTest.buildConfig(serverProperties, rebootstrapProperties))
+                .toList();
+    }
+
+    static Map<String, String> getRebootstrapConfig(boolean 
useRebootstrapTriggerMs) {
+        Map<String, String> properties = new HashMap<>();
+        if (useRebootstrapTriggerMs) {
+            properties.put("metadata.recovery.rebootstrap.trigger.ms", "5000");
+        } else {
+            properties.put("metadata.recovery.rebootstrap.trigger.ms", 
"3600000");
+            properties.put("socket.connection.setup.timeout.ms", "5000");
+            properties.put("socket.connection.setup.timeout.max.ms", "5000");
+            properties.put("reconnect.backoff.ms", "1000");
+            properties.put("reconnect.backoff.max.ms", "1000");
+        }
+        properties.put("metadata.recovery.strategy", "rebootstrap");

Review Comment:
   I can't do it because the styleAction check blocks the reference 
by`CommonClientConfigs` in test.
   I only just wrote it in plaintext.



##########
core/src/test/java/kafka/test/api/ProducerRebootstrapTest.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * 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 kafka.test.api;
+
+import kafka.server.KafkaBroker;
+import org.apache.kafka.clients.admin.Admin;
+import org.apache.kafka.clients.admin.NewTopic;
+import org.apache.kafka.clients.producer.ProducerConfig;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.kafka.clients.producer.RecordMetadata;
+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.coordinator.group.GroupCoordinatorConfig;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.stream.Stream;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class ProducerRebootstrapTest {
+    private static final int BROKER_COUNT = 2;
+
+    static List<ClusterConfig> generator() {
+        Map<String, String> serverProperties = new HashMap<>();
+        // Enable unclean leader election for the test topic
+        
serverProperties.put(TopicConfig.UNCLEAN_LEADER_ELECTION_ENABLE_CONFIG, "true");
+        
serverProperties.put(GroupCoordinatorConfig.OFFSETS_TOPIC_REPLICATION_FACTOR_CONFIG,
 String.valueOf(BROKER_COUNT));
+
+        return Stream.of(false, true)
+                .map(ProducerRebootstrapTest::getRebootstrapConfig)
+                .map(rebootstrapProperties -> 
ProducerRebootstrapTest.buildConfig(serverProperties, rebootstrapProperties))
+                .toList();
+    }
+
+    static Map<String, String> getRebootstrapConfig(boolean 
useRebootstrapTriggerMs) {
+        Map<String, String> properties = new HashMap<>();
+        if (useRebootstrapTriggerMs) {
+            properties.put("metadata.recovery.rebootstrap.trigger.ms", "5000");
+        } else {
+            properties.put("metadata.recovery.rebootstrap.trigger.ms", 
"3600000");
+            properties.put("socket.connection.setup.timeout.ms", "5000");
+            properties.put("socket.connection.setup.timeout.max.ms", "5000");
+            properties.put("reconnect.backoff.ms", "1000");
+            properties.put("reconnect.backoff.max.ms", "1000");
+        }
+        properties.put("metadata.recovery.strategy", "rebootstrap");

Review Comment:
   I can't do it because the styleAction check blocks the reference 
by`CommonClientConfigs` in tests.
   I only just wrote it in plaintext.



-- 
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