Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2580,6 +2580,12 @@ class PlaintextAdminIntegrationTest extends BaseAdminIntegrationTest {
val config = createConfig
client = Admin.create(config)

client.createTopics(util.Set.of(
new NewTopic(testTopicName, 1, 1.toShort)
)).all().get()
waitForTopics(client, List(testTopicName), List())
val topicPartition = new TopicPartition(testTopicName, 0)

consumerConfig.put(ConsumerConfig.GROUP_PROTOCOL_CONFIG, GroupProtocol.CLASSIC.name)
val classicGroupConfig = new Properties(consumerConfig)
classicGroupConfig.put(ConsumerConfig.GROUP_ID_CONFIG, classicGroupId)
Expand All @@ -2600,12 +2606,6 @@ class PlaintextAdminIntegrationTest extends BaseAdminIntegrationTest {
)

try {
client.createTopics(util.Set.of(
new NewTopic(testTopicName, 1, 1.toShort)
)).all().get()
waitForTopics(client, List(testTopicName), List())
val topicPartition = new TopicPartition(testTopicName, 0)

classicGroup.subscribe(util.Set.of(testTopicName))
classicGroup.poll(JDuration.ofMillis(1000))
consumerGroup.subscribe(util.Set.of(testTopicName))
Expand All @@ -2628,20 +2628,22 @@ class PlaintextAdminIntegrationTest extends BaseAdminIntegrationTest {
val consumerGroupListing = new GroupListing(consumerGroupId, Optional.of(GroupType.CONSUMER), "consumer", Optional.of(GroupState.STABLE))
val shareGroupListing = new GroupListing(shareGroupId, Optional.of(GroupType.SHARE), "share", Optional.of(GroupState.STABLE))
val simpleGroupListing = new GroupListing(simpleGroupId, Optional.of(GroupType.CLASSIC), "", Optional.of(GroupState.EMPTY))
// Streams group could either be in STABLE or NOT_READY state
val streamsGroupListingStable = new GroupListing(streamsGroupId, Optional.of(GroupType.STREAMS), "streams", Optional.of(GroupState.STABLE))
val streamsGroupListingNotReady = new GroupListing(streamsGroupId, Optional.of(GroupType.STREAMS), "streams", Optional.of(GroupState.NOT_READY))
val streamsGroupListing = new GroupListing(streamsGroupId, Optional.of(GroupType.STREAMS), "streams", Optional.of(GroupState.STABLE))

var listGroupsResult = client.listGroups()
assertTrue(listGroupsResult.errors().get().isEmpty)

val expectedStreamListings = Set(streamsGroupListingStable, streamsGroupListingNotReady)
val expectedListings = Set(classicGroupListing, simpleGroupListing, consumerGroupListing, shareGroupListing)
val actualListings = listGroupsResult.all().get().asScala.toSet

// Check that actualListings contains all expectedListings and one of the streams listings
assertTrue(expectedListings.subsetOf(actualListings))
assertTrue(actualListings.exists(expectedStreamListings.contains))
TestUtils.waitUntilTrue(() => {
val listGroupResultScala = client.listGroups().all().get().asScala
val filteredStreamsGroups = listGroupResultScala.filter(_.groupId() == streamsGroupId)
val filteredClassicGroups = listGroupResultScala.filter(_.groupId() == classicGroupId)
val filteredConsumerGroups = listGroupResultScala.filter(_.groupId() == consumerGroupId)
val filteredShareGroups = listGroupResultScala.filter(_.groupId() == shareGroupId)
filteredClassicGroups.forall(_.groupState().orElse(null) == GroupState.STABLE) &&
filteredConsumerGroups.forall(_.groupState().orElse(null) == GroupState.STABLE) &&
filteredShareGroups.forall(_.groupState().orElse(null) == GroupState.STABLE) &&
filteredStreamsGroups.forall(_.groupState().orElse(null) == GroupState.STABLE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also add the check for simple group?

}, "Groups not stable yet")

listGroupsResult = client.listGroups(new ListGroupsOptions().withTypes(util.Set.of(GroupType.CLASSIC)))
assertTrue(listGroupsResult.errors().get().isEmpty)
Expand All @@ -2660,10 +2662,8 @@ class PlaintextAdminIntegrationTest extends BaseAdminIntegrationTest {

listGroupsResult = client.listGroups(new ListGroupsOptions().withTypes(util.Set.of(GroupType.STREAMS)))
assertTrue(listGroupsResult.errors().get().isEmpty)
assertTrue(listGroupsResult.all().get().asScala.toSet.equals(Set(streamsGroupListingStable)) ||
listGroupsResult.all().get().asScala.toSet.equals(Set(streamsGroupListingNotReady)))
assertTrue(listGroupsResult.valid().get().asScala.toSet.equals(Set(streamsGroupListingStable)) ||
listGroupsResult.valid().get().asScala.toSet.equals(Set(streamsGroupListingNotReady)))
assertEquals(Set(streamsGroupListing), listGroupsResult.all().get().asScala.toSet)
assertEquals(Set(streamsGroupListing), listGroupsResult.valid().get().asScala.toSet)

} finally {
Utils.closeQuietly(classicGroup, "classicGroup")
Expand Down
Loading