This is an automated email from the ASF dual-hosted git repository.
schofielaj pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new b8de78cafdf KAFKA-19210: resolved the flakiness in
testShareGroupHeartbeatInitializeOnPartitionUpdate (#19601)
b8de78cafdf is described below
commit b8de78cafdfd6fe09f499667b5c1f2d7553024ca
Author: Chirag Wadhwa <[email protected]>
AuthorDate: Wed Apr 30 20:37:55 2025 +0530
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 <[email protected]>, Andrew Schofield
<[email protected]>
---
.../group/GroupMetadataManagerTest.java | 46 +++++++++++++---------
1 file changed, 28 insertions(+), 18 deletions(-)
diff --git
a/group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupMetadataManagerTest.java
b/group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupMetadataManagerTest.java
index 250b10fec34..81b127af16d 100644
---
a/group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupMetadataManagerTest.java
+++
b/group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupMetadataManagerTest.java
@@ -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(