dengziming commented on code in PR #13562: URL: https://github.com/apache/kafka/pull/13562#discussion_r1197869315
########## tools/src/test/java/org/apache/kafka/tools/GetOffsetShellTest.java: ########## @@ -0,0 +1,160 @@ +/* + * 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.tools; + +import kafka.test.ClusterInstance; +import kafka.test.annotation.ClusterTest; +import kafka.test.annotation.ClusterTestDefaults; +import kafka.test.annotation.Type; +import kafka.test.junit.ClusterTestExtensions; +import org.apache.kafka.clients.CommonClientConfigs; +import org.apache.kafka.clients.admin.Admin; +import org.apache.kafka.clients.admin.NewTopic; +import org.apache.kafka.clients.producer.KafkaProducer; +import org.apache.kafka.clients.producer.ProducerConfig; +import org.apache.kafka.clients.producer.ProducerRecord; +import org.apache.kafka.common.serialization.StringSerializer; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.extension.ExtendWith; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.Properties; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@ExtendWith(value = ClusterTestExtensions.class) +@ClusterTestDefaults(clusterType = Type.ZK) +@Tag("integration") +public class GetOffsetShellTest { + private final int topicCount = 4; + private final int offsetTopicPartitionCount = 4; + private final ClusterInstance cluster; + + public GetOffsetShellTest(ClusterInstance cluster) { + this.cluster = cluster; + } + + private String getTopicName(int i) { + return "topic" + i; + } + + @BeforeEach + public void setUp() { Review Comment: Yes, we can't create topic in Setup since `setup` is invoked before we init a cluster, we can only overwrite some config to control the action of it, for exmaple: ``` clusterConfig.serverProperties().put("auto.create.topics.enable", false); clusterConfig.serverProperties().put("offsets.topic.replication.factor", "1"); clusterConfig.serverProperties().put("offsets.topic.num.partitions", String.valueOf(offsetTopicPartitionCount)); ``` with these configs, you can create __consumers_offset as you want, if you really want to control when to create it, you should overwrite `setUp` in `ZkClusterInvocationContext.getAdditionalExtensions.IntegrationTestHarness` and change `doSetup(testInfo, createOffsetsTopic = true)` to `doSetup(testInfo, createOffsetsTopic = false)`, but I think it's unnecessary. -- 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