dajac commented on code in PR #21312:
URL: https://github.com/apache/kafka/pull/21312#discussion_r2697448082
##########
core/src/test/scala/unit/kafka/server/StreamsGroupHeartbeatRequestTest.scala:
##########
@@ -1003,6 +1003,94 @@ class StreamsGroupHeartbeatRequestTest(cluster:
ClusterInstance) extends GroupCo
}
}
+ @ClusterTest
+ def testFencedMemberCanRejoinWithEpochZero(): Unit = {
+ val admin = cluster.admin()
+ val memberId = "test-fenced-rejoin-member"
+ val groupId = "test-fenced-rejoin-group"
+ val topicName = "test-fenced-topic"
+
+ try {
+ TestUtils.createOffsetsTopicWithAdmin(
+ admin = admin,
+ brokers = cluster.brokers.values().asScala.toSeq,
+ controllers = cluster.controllers().values().asScala.toSeq
+ )
+
+ // Create topic first.
+ TestUtils.createTopicWithAdmin(
+ admin = admin,
+ brokers = cluster.brokers.values().asScala.toSeq,
+ controllers = cluster.controllers().values().asScala.toSeq,
+ topic = topicName,
+ numPartitions = 3
+ )
+
+ val topology = createMockTopology(topicName)
+
+ // Join and wait for assignment.
+ var streamsGroupHeartbeatResponse: StreamsGroupHeartbeatResponseData =
null
+ TestUtils.waitUntilTrue(() => {
+ streamsGroupHeartbeatResponse = streamsGroupHeartbeat(
+ groupId = groupId,
+ memberId = memberId,
+ rebalanceTimeoutMs = 1000,
+ activeTasks = Option(streamsGroupHeartbeatResponse)
+ .map(r => convertTaskIds(r.activeTasks()))
+ .getOrElse(List.empty),
+ standbyTasks = Option(streamsGroupHeartbeatResponse)
+ .map(r => convertTaskIds(r.standbyTasks()))
+ .getOrElse(List.empty),
+ warmupTasks = Option(streamsGroupHeartbeatResponse)
+ .map(r => convertTaskIds(r.warmupTasks()))
+ .getOrElse(List.empty),
+ topology = topology
+ )
+ streamsGroupHeartbeatResponse.errorCode == Errors.NONE.code() &&
+ streamsGroupHeartbeatResponse.activeTasks() != null &&
+ !streamsGroupHeartbeatResponse.activeTasks().isEmpty
+ }, "Did not get assignment within the timeout period.")
+
+ // Verify we have an epoch and assignment.
+ assertEquals(memberId, streamsGroupHeartbeatResponse.memberId())
+ assertTrue(streamsGroupHeartbeatResponse.memberEpoch() > 0)
Review Comment:
Streams goes to epoch 2 in this case due to the delayed rebalance time. I
have updated the assertions to make it clear.
--
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]