@@ -2580,6 +2580,12 @@ class PlaintextAdminIntegrationTest extends BaseAdminIntegrationTest {
2580
2580
val config = createConfig
2581
2581
client = Admin .create(config)
2582
2582
2583
+ client.createTopics(util.Set .of(
2584
+ new NewTopic (testTopicName, 1 , 1 .toShort)
2585
+ )).all().get()
2586
+ waitForTopics(client, List (testTopicName), List ())
2587
+ val topicPartition = new TopicPartition (testTopicName, 0 )
2588
+
2583
2589
consumerConfig.put(ConsumerConfig .GROUP_PROTOCOL_CONFIG , GroupProtocol .CLASSIC .name)
2584
2590
val classicGroupConfig = new Properties (consumerConfig)
2585
2591
classicGroupConfig.put(ConsumerConfig .GROUP_ID_CONFIG , classicGroupId)
@@ -2600,12 +2606,6 @@ class PlaintextAdminIntegrationTest extends BaseAdminIntegrationTest {
2600
2606
)
2601
2607
2602
2608
try {
2603
- client.createTopics(util.Set .of(
2604
- new NewTopic (testTopicName, 1 , 1 .toShort)
2605
- )).all().get()
2606
- waitForTopics(client, List (testTopicName), List ())
2607
- val topicPartition = new TopicPartition (testTopicName, 0 )
2608
-
2609
2609
classicGroup.subscribe(util.Set .of(testTopicName))
2610
2610
classicGroup.poll(JDuration .ofMillis(1000 ))
2611
2611
consumerGroup.subscribe(util.Set .of(testTopicName))
@@ -2628,20 +2628,22 @@ class PlaintextAdminIntegrationTest extends BaseAdminIntegrationTest {
2628
2628
val consumerGroupListing = new GroupListing (consumerGroupId, Optional .of(GroupType .CONSUMER ), " consumer" , Optional .of(GroupState .STABLE ))
2629
2629
val shareGroupListing = new GroupListing (shareGroupId, Optional .of(GroupType .SHARE ), " share" , Optional .of(GroupState .STABLE ))
2630
2630
val simpleGroupListing = new GroupListing (simpleGroupId, Optional .of(GroupType .CLASSIC ), " " , Optional .of(GroupState .EMPTY ))
2631
- // Streams group could either be in STABLE or NOT_READY state
2632
- val streamsGroupListingStable = new GroupListing (streamsGroupId, Optional .of(GroupType .STREAMS ), " streams" , Optional .of(GroupState .STABLE ))
2633
- val streamsGroupListingNotReady = new GroupListing (streamsGroupId, Optional .of(GroupType .STREAMS ), " streams" , Optional .of(GroupState .NOT_READY ))
2631
+ val streamsGroupListing = new GroupListing (streamsGroupId, Optional .of(GroupType .STREAMS ), " streams" , Optional .of(GroupState .STABLE ))
2634
2632
2635
2633
var listGroupsResult = client.listGroups()
2636
2634
assertTrue(listGroupsResult.errors().get().isEmpty)
2637
2635
2638
- val expectedStreamListings = Set (streamsGroupListingStable, streamsGroupListingNotReady)
2639
- val expectedListings = Set (classicGroupListing, simpleGroupListing, consumerGroupListing, shareGroupListing)
2640
- val actualListings = listGroupsResult.all().get().asScala.toSet
2641
-
2642
- // Check that actualListings contains all expectedListings and one of the streams listings
2643
- assertTrue(expectedListings.subsetOf(actualListings))
2644
- assertTrue(actualListings.exists(expectedStreamListings.contains))
2636
+ TestUtils .waitUntilTrue(() => {
2637
+ val listGroupResultScala = client.listGroups().all().get().asScala
2638
+ val filteredStreamsGroups = listGroupResultScala.filter(_.groupId() == streamsGroupId)
2639
+ val filteredClassicGroups = listGroupResultScala.filter(_.groupId() == classicGroupId)
2640
+ val filteredConsumerGroups = listGroupResultScala.filter(_.groupId() == consumerGroupId)
2641
+ val filteredShareGroups = listGroupResultScala.filter(_.groupId() == shareGroupId)
2642
+ filteredClassicGroups.forall(_.groupState().orElse(null ) == GroupState .STABLE ) &&
2643
+ filteredConsumerGroups.forall(_.groupState().orElse(null ) == GroupState .STABLE ) &&
2644
+ filteredShareGroups.forall(_.groupState().orElse(null ) == GroupState .STABLE ) &&
2645
+ filteredStreamsGroups.forall(_.groupState().orElse(null ) == GroupState .STABLE )
2646
+ }, " Groups not stable yet" )
2645
2647
2646
2648
listGroupsResult = client.listGroups(new ListGroupsOptions ().withTypes(util.Set .of(GroupType .CLASSIC )))
2647
2649
assertTrue(listGroupsResult.errors().get().isEmpty)
@@ -2660,10 +2662,8 @@ class PlaintextAdminIntegrationTest extends BaseAdminIntegrationTest {
2660
2662
2661
2663
listGroupsResult = client.listGroups(new ListGroupsOptions ().withTypes(util.Set .of(GroupType .STREAMS )))
2662
2664
assertTrue(listGroupsResult.errors().get().isEmpty)
2663
- assertTrue(listGroupsResult.all().get().asScala.toSet.equals(Set (streamsGroupListingStable)) ||
2664
- listGroupsResult.all().get().asScala.toSet.equals(Set (streamsGroupListingNotReady)))
2665
- assertTrue(listGroupsResult.valid().get().asScala.toSet.equals(Set (streamsGroupListingStable)) ||
2666
- listGroupsResult.valid().get().asScala.toSet.equals(Set (streamsGroupListingNotReady)))
2665
+ assertEquals(Set (streamsGroupListing), listGroupsResult.all().get().asScala.toSet)
2666
+ assertEquals(Set (streamsGroupListing), listGroupsResult.valid().get().asScala.toSet)
2667
2667
2668
2668
} finally {
2669
2669
Utils .closeQuietly(classicGroup, " classicGroup" )
0 commit comments