rreddy-22 commented on code in PR #15150:
URL: https://github.com/apache/kafka/pull/15150#discussion_r1484632678
##########
core/src/test/scala/unit/kafka/admin/ListConsumerGroupTest.scala:
##########
@@ -111,37 +233,138 @@ class ListConsumerGroupTest extends
ConsumerGroupCommandTest {
assertThrows(classOf[IllegalArgumentException], () =>
ConsumerGroupCommand.consumerGroupStatesFromString(" , ,"))
}
- @ParameterizedTest
- @ValueSource(strings = Array("zk", "kraft"))
- def testListGroupCommand(quorum: String): Unit = {
+ @Test
+ def testConsumerGroupTypesFromString(): 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)
+
@MethodSource(Array("getTestQuorumAndGroupProtocolParametersConsumerGroupProtocolOnly"))
+ def testListGroupCommandConsumerProtocol(quorum: String, groupProtocol:
String): Unit = {
+ val simpleGroup = "simple-group"
+ val protocolGroup = "protocol-group"
+
+ createOffsetsTopic()
+
+ 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) && 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("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("Consumer") &&
!out.contains("STATE") && out.contains(protocolGroup) &&
out.contains(simpleGroup) && out.contains(group)
+ }, s"Expected to find $protocolGroup and the header, but found $out")
+
+ cgcArgs = Array("--bootstrap-server", bootstrapServers(), "--list",
"--type", "consumer")
+ TestUtils.waitUntilTrue(() => {
+ out = TestUtils.grabConsoleOutput(ConsumerGroupCommand.main(cgcArgs))
+ out.contains("TYPE") && out.contains("Consumer") &&
!out.contains("STATE") && out.contains(protocolGroup)
+ }, s"Expected to find $protocolGroup and the header, but found $out")
+
+ cgcArgs = Array("--bootstrap-server", bootstrapServers(), "--list",
"--type", "consumer", "--state", "Stable")
+ TestUtils.waitUntilTrue(() => {
+ out = TestUtils.grabConsoleOutput(ConsumerGroupCommand.main(cgcArgs))
+ out.contains("TYPE") && out.contains("Consumer") &&
out.contains("STATE") && out.contains("Stable") && out.contains(protocolGroup)
+ }, s"Expected to find $protocolGroup and the header, but found $out")
}
+ def testWaitUntilTrue(
+ typeFilterSet: Set[GroupType],
+ stateFilterSet: Set[ConsumerGroupState],
+ expectedListing: Set[ConsumerGroupListing],
+ service: ConsumerGroupCommand.ConsumerGroupService
Review Comment:
ugh idky checkstyle didn't catch this when I ran locally :( thanks
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]