KAFKA-19210: resolved the flakiness in testShareGroupHeartbeatInitializeOnPartitionUpdate (#19601)

The test testShareGroupHeartbeatInitializeOnPartitionUpdate was flaky
earlier. The shareGroupStatePartitionMetadataRecord that is created
during heartbeat contains 2 topics to be initialized, but the order in
which they appear in the list is not deterministic. The test is changed
to simply see whether the contents of the record is correct instead of
directly comparing it with an expected record which may contains the
correct topics, but in some different order.

Reviewers: Sushant Mahajan <smahajan@confluent.io>, Andrew Schofield <aschofield@confluent.io>
This commit is contained in:
Chirag Wadhwa 2025-04-30 20:37:55 +05:30 committed by GitHub
parent 19609d5986
commit b8de78cafd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 28 additions and 18 deletions

View File

@ -21260,16 +21260,21 @@ public class GroupMetadataManagerTest {
.setMemberEpoch(0)
.setSubscribedTopicNames(List.of(t1Name, t2Name)));
assertTrue(result.records().contains(
newShareGroupStatePartitionMetadataRecord(groupId, mkShareGroupStateMap(List.of(
mkShareGroupStateMetadataEntry(t1Uuid, t1Name, List.of(0, 1)),
mkShareGroupStateMetadataEntry(t2Uuid, t2Name, List.of(0, 1))
)),
Map.of(),
Map.of()
))
CoordinatorRecord expected = newShareGroupStatePartitionMetadataRecord(
groupId,
mkShareGroupStateMap(List.of(
mkShareGroupStateMetadataEntry(t1Uuid, t1Name, List.of(0, 1)),
mkShareGroupStateMetadataEntry(t2Uuid, t2Name, List.of(0, 1))
)),
Map.of(),
Map.of()
);
Optional<CoordinatorRecord> actual = result.records().stream().filter(record -> record.key() instanceof ShareGroupStatePartitionMetadataKey)
.findAny();
assertTrue(actual.isPresent());
assertRecordEquals(expected, actual.get());
verifyShareGroupHeartbeatInitializeRequest(
result.response().getValue(),
Map.of(
@ -21330,18 +21335,23 @@ public class GroupMetadataManagerTest {
.setMemberEpoch(1)
.setSubscribedTopicNames(null));
assertTrue(result.records().contains(
newShareGroupStatePartitionMetadataRecord(groupId, mkShareGroupStateMap(List.of(
mkShareGroupStateMetadataEntry(t1Uuid, t1Name, List.of(2, 3))
)),
mkShareGroupStateMap(List.of(
mkShareGroupStateMetadataEntry(t1Uuid, t1Name, List.of(0, 1)),
mkShareGroupStateMetadataEntry(t2Uuid, t2Name, List.of(0, 1))
)),
Map.of()
))
expected = newShareGroupStatePartitionMetadataRecord(
groupId,
mkShareGroupStateMap(List.of(
mkShareGroupStateMetadataEntry(t1Uuid, t1Name, List.of(2, 3))
)),
mkShareGroupStateMap(List.of(
mkShareGroupStateMetadataEntry(t1Uuid, t1Name, List.of(0, 1)),
mkShareGroupStateMetadataEntry(t2Uuid, t2Name, List.of(0, 1))
)),
Map.of()
);
actual = result.records().stream().filter(record -> record.key() instanceof ShareGroupStatePartitionMetadataKey)
.findAny();
assertTrue(actual.isPresent());
assertRecordEquals(expected, actual.get());
verifyShareGroupHeartbeatInitializeRequest(
result.response().getValue(),
Map.of(