rreddy-22 commented on code in PR #15150: URL: https://github.com/apache/kafka/pull/15150#discussion_r1483318793
########## core/src/test/scala/unit/kafka/admin/ListConsumerGroupTest.scala: ########## @@ -111,37 +263,124 @@ class ListConsumerGroupTest extends ConsumerGroupCommandTest { assertThrows(classOf[IllegalArgumentException], () => ConsumerGroupCommand.consumerGroupStatesFromString(" , ,")) } - @ParameterizedTest - @ValueSource(strings = Array("zk", "kraft")) - def testListGroupCommand(quorum: String): Unit = { + @ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames) + @MethodSource(Array("getTestQuorumAndGroupProtocolParametersAll")) + def testConsumerGroupTypesFromString(quorum: String, groupProtocol: String): Unit = { + var result = ConsumerGroupCommand.consumerGroupTypesFromString("consumer") + assertEquals(Set(GroupType.CONSUMER), result) + + result = ConsumerGroupCommand.consumerGroupTypesFromString("consumer, classic") + assertEquals(Set(GroupType.CONSUMER, GroupType.CLASSIC), result) + + result = ConsumerGroupCommand.consumerGroupTypesFromString("Consumer, Classic") + assertEquals(Set(GroupType.CONSUMER, GroupType.CLASSIC), result) + + assertThrows(classOf[IllegalArgumentException], () => ConsumerGroupCommand.consumerGroupTypesFromString("bad, wrong")) + + assertThrows(classOf[IllegalArgumentException], () => ConsumerGroupCommand.consumerGroupTypesFromString(" bad, generic")) + + assertThrows(classOf[IllegalArgumentException], () => ConsumerGroupCommand.consumerGroupTypesFromString(" , ,")) + } + + @ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames) + @MethodSource(Array("getTestQuorumAndGroupProtocolParametersClassicGroupProtocolOnly")) + def testListGroupCommandClassicProtocol(quorum: String, groupProtocol: String): Unit = { val simpleGroup = "simple-group" + val protocolGroup = "protocol-group" + addSimpleGroupExecutor(group = simpleGroup) addConsumerGroupExecutor(numConsumers = 1) + addConsumerGroupExecutor(numConsumers = 1, group = protocolGroup, groupProtocol = groupProtocol) var out = "" var cgcArgs = Array("--bootstrap-server", bootstrapServers(), "--list") TestUtils.waitUntilTrue(() => { out = TestUtils.grabConsoleOutput(ConsumerGroupCommand.main(cgcArgs)) - !out.contains("STATE") && out.contains(simpleGroup) && out.contains(group) - }, s"Expected to find $simpleGroup, $group and no header, but found $out") + !out.contains("STATE") && out.contains(simpleGroup) && out.contains(group) && out.contains(protocolGroup) + }, s"Expected to find $simpleGroup, $group, $protocolGroup and no header, but found $out") cgcArgs = Array("--bootstrap-server", bootstrapServers(), "--list", "--state") TestUtils.waitUntilTrue(() => { out = TestUtils.grabConsoleOutput(ConsumerGroupCommand.main(cgcArgs)) - out.contains("STATE") && out.contains(simpleGroup) && out.contains(group) - }, s"Expected to find $simpleGroup, $group and the header, but found $out") + out.contains("STATE") && !out.contains("TYPE") && out.contains(simpleGroup) && out.contains(group) && out.contains(protocolGroup) + }, s"Expected to find $simpleGroup, $group, $protocolGroup and the header, but found $out") + + cgcArgs = Array("--bootstrap-server", bootstrapServers(), "--list", "--type") + TestUtils.waitUntilTrue(() => { + out = TestUtils.grabConsoleOutput(ConsumerGroupCommand.main(cgcArgs)) + out.contains("TYPE") && !out.contains("STATE") && out.contains(simpleGroup) && out.contains(group) && out.contains(protocolGroup) + }, s"Expected to find $simpleGroup, $group, $protocolGroup and the header, but found $out") + + cgcArgs = Array("--bootstrap-server", bootstrapServers(), "--list", "--state", "--type") + TestUtils.waitUntilTrue(() => { + out = TestUtils.grabConsoleOutput(ConsumerGroupCommand.main(cgcArgs)) + out.contains("TYPE") && out.contains("STATE") && out.contains(simpleGroup) && out.contains(group) && out.contains(protocolGroup) + }, s"Expected to find $simpleGroup, $group, $protocolGroup and the header, but found $out") cgcArgs = Array("--bootstrap-server", bootstrapServers(), "--list", "--state", "Stable") TestUtils.waitUntilTrue(() => { out = TestUtils.grabConsoleOutput(ConsumerGroupCommand.main(cgcArgs)) - out.contains("STATE") && out.contains(group) && out.contains("Stable") - }, s"Expected to find $group in state Stable and the header, but found $out") + out.contains("STATE") && out.contains(group) && out.contains("Stable") && out.contains(protocolGroup) + }, s"Expected to find $group, $protocolGroup in state Stable and the header, but found $out") cgcArgs = Array("--bootstrap-server", bootstrapServers(), "--list", "--state", "stable") TestUtils.waitUntilTrue(() => { out = TestUtils.grabConsoleOutput(ConsumerGroupCommand.main(cgcArgs)) - out.contains("STATE") && out.contains(group) && out.contains("Stable") - }, s"Expected to find $group in state Stable and the header, but found $out") + out.contains("STATE") && out.contains(group) && out.contains("Stable") && out.contains(protocolGroup) + }, s"Expected to find $group, $protocolGroup in state Stable and the header, but found $out") + + cgcArgs = Array("--bootstrap-server", bootstrapServers(), "--list", "--type", "Classic") + TestUtils.waitUntilTrue(() => { + out = TestUtils.grabConsoleOutput(ConsumerGroupCommand.main(cgcArgs)) + out.contains("TYPE") && out.contains("Classic") && !out.contains("STATE") && out.contains(simpleGroup) && out.contains(group) && out.contains(protocolGroup) + }, s"Expected to find $simpleGroup, $group, $protocolGroup and the header, but found $out") + + cgcArgs = Array("--bootstrap-server", bootstrapServers(), "--list", "--type", "classic") + TestUtils.waitUntilTrue(() => { + out = TestUtils.grabConsoleOutput(ConsumerGroupCommand.main(cgcArgs)) + out.contains("TYPE") && out.contains("Classic") && !out.contains("STATE") && out.contains(simpleGroup) && out.contains(group) && out.contains(protocolGroup) + }, s"Expected to find $simpleGroup, $group, $protocolGroup and the header, but found $out") } + @ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames) + @CsvSource(Array("kraft+kip848,consumer")) + def testListGroupCommandConsumerProtocol(quorum: String, groupProtocol: String): Unit = { + val simpleGroup = "simple-group" Review Comment: Oh hmmm that makes sense! Let me add that and try re-running them without the patch -- 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