chia7712 commented on code in PR #15821: URL: https://github.com/apache/kafka/pull/15821#discussion_r1615797305
########## tools/src/test/java/org/apache/kafka/tools/consumer/group/ListConsumerGroupTest.java: ########## @@ -17,449 +17,502 @@ package org.apache.kafka.tools.consumer.group; import joptsimple.OptionException; +import kafka.test.ClusterConfig; +import kafka.test.ClusterInstance; +import kafka.test.annotation.ClusterTemplate; +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.AdminClientConfig; import org.apache.kafka.clients.admin.ConsumerGroupListing; +import org.apache.kafka.clients.admin.NewTopic; +import org.apache.kafka.clients.consumer.GroupProtocol; +import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.apache.kafka.clients.consumer.RangeAssignor; import org.apache.kafka.common.ConsumerGroupState; import org.apache.kafka.common.GroupType; +import org.apache.kafka.common.TopicPartition; +import org.apache.kafka.common.serialization.StringDeserializer; +import static org.apache.kafka.clients.consumer.ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG; +import static org.apache.kafka.clients.consumer.ConsumerConfig.GROUP_ID_CONFIG; +import static org.apache.kafka.clients.consumer.ConsumerConfig.GROUP_PROTOCOL_CONFIG; +import static org.apache.kafka.clients.consumer.ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG; +import static org.apache.kafka.clients.consumer.ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG; +import static org.apache.kafka.clients.consumer.ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG; + +import org.apache.kafka.coordinator.group.GroupCoordinatorConfig; import org.apache.kafka.test.TestUtils; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.apache.kafka.tools.ToolsTestUtils; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.EnumSet; +import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.Properties; import java.util.List; import java.util.Set; +import java.util.stream.Stream; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; -import static org.apache.kafka.tools.ToolsTestUtils.TEST_WITH_PARAMETERIZED_QUORUM_AND_GROUP_PROTOCOL_NAMES; +import static java.util.Collections.emptyMap; import static org.apache.kafka.common.utils.Utils.mkSet; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -public class ListConsumerGroupTest extends ConsumerGroupCommandTest { - @ParameterizedTest(name = TEST_WITH_PARAMETERIZED_QUORUM_AND_GROUP_PROTOCOL_NAMES) - @MethodSource("getTestQuorumAndGroupProtocolParametersAll") - public void testListConsumerGroupsWithoutFilters(String quorum, String groupProtocol) throws Exception { - String simpleGroup = "simple-group"; - - createOffsetsTopic(listenerName(), new Properties()); - - addSimpleGroupExecutor(simpleGroup); - addConsumerGroupExecutor(1); - addConsumerGroupExecutor(1, PROTOCOL_GROUP, groupProtocol); +@Tag("integration") +@ExtendWith(ClusterTestExtensions.class) +public class ListConsumerGroupTest { + private final static String TOPIC = "foo"; + private final static String SIMPLE_GROUP = "test.simple.group"; + private final static String DEFAULT_GROUP = "test.default.group"; + private final static String PROTOCOL_GROUP = "test.protocol.group"; + private final ClusterInstance clusterInstance; + + ListConsumerGroupTest(ClusterInstance clusterInstance) { + this.clusterInstance = clusterInstance; + } - String[] cgcArgs = new String[]{"--bootstrap-server", bootstrapServers(listenerName()), "--list"}; - ConsumerGroupCommand.ConsumerGroupService service = getConsumerGroupService(cgcArgs); + private static List<ClusterConfig> defaultGenerator() { + return ConsumerGroupCommandTestUtils.generator(); + } - Set<String> expectedGroups = set(Arrays.asList(GROUP, simpleGroup, PROTOCOL_GROUP)); - final AtomicReference<Set> foundGroups = new AtomicReference<>(); + private static List<ClusterConfig> consumerProtocolOnlyGenerator() { Review Comment: How about moving this helper to `ConsumerGroupCommandTestUtils` and reuse it to rewrite `ConsumerGroupCommandTestUtils.generator`? -- 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