apoorvmittal10 commented on code in PR #18864:
URL: https://github.com/apache/kafka/pull/18864#discussion_r1968132678
##########
core/src/test/scala/unit/kafka/server/ShareGroupHeartbeatRequestTest.scala:
##########
@@ -261,13 +255,23 @@ class ShareGroupHeartbeatRequestTest(cluster:
ClusterInstance) {
shareGroupHeartbeatResponse = null
TestUtils.waitUntilTrue(() => {
shareGroupHeartbeatResponse =
connectAndReceive(shareGroupHeartbeatRequest)
- shareGroupHeartbeatResponse.data.errorCode == Errors.NONE.code &&
- shareGroupHeartbeatResponse.data.assignment == expectedAssignment
+ shareGroupHeartbeatResponse.data.errorCode == Errors.NONE.code &&
shareGroupHeartbeatResponse.data.assignment != null
}, msg = s"Could not get partitions assigned. Last response
$shareGroupHeartbeatResponse.")
+ val topicPartitionsAssignedToMember2 =
shareGroupHeartbeatResponse.data.assignment.topicPartitions()
// Verify the response.
assertEquals(3, shareGroupHeartbeatResponse.data.memberEpoch)
+ var partitionsAssigned: Set[Integer] = Set()
+ for (topicPartition <- topicPartitionsAssignedToMember1.asScala) {
+ partitionsAssigned = partitionsAssigned ++
topicPartition.partitions().asScala
+ }
+ for (topicPartition <- topicPartitionsAssignedToMember2.asScala) {
+ partitionsAssigned = partitionsAssigned ++
topicPartition.partitions().asScala
+ }
+ // Verify all the 3 topic partitions for "foo" have been assigned to at
least 1 member.
+ assertEquals(Set(0, 1, 2), partitionsAssigned)
Review Comment:
Instead of converting to scala the code can be written as:
```
val partitionsAssigned: util.Set[Integer] = new util.HashSet[Integer]()
topicPartitionsAssignedToMember1.forEach(topicPartition => {
partitionsAssigned.addAll(topicPartition.partitions())
})
topicPartitionsAssignedToMember2.forEach(topicPartition => {
partitionsAssigned.addAll(topicPartition.partitions())
})
// Verify all the 3 topic partitions for "foo" have been assigned to
at least 1 member.
assertEquals(util.Set.of(0, 1, 2), partitionsAssigned)
--
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]