lucasbru commented on code in PR #19818:
URL: https://github.com/apache/kafka/pull/19818#discussion_r2111669088
##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/ConsumerMembershipManagerTest.java:
##########
@@ -998,16 +1005,43 @@ public void
testIgnoreHeartbeatResponseWhenNotInGroup(MemberState state) {
assertEquals(state, membershipManager.state());
verify(responseData, never()).memberId();
- verify(responseData, never()).memberEpoch();
+ // In unsubscribed, we check if we received a leave group response, so
we do verify member epoch.
+ if (state != MemberState.UNSUBSCRIBED) {
+ verify(responseData, never()).memberEpoch();
+ }
verify(responseData, never()).assignment();
}
@Test
- public void testLeaveGroupWhenStateIsReconciling() {
- ConsumerMembershipManager membershipManager =
mockJoinAndReceiveAssignment(false);
- assertEquals(MemberState.RECONCILING, membershipManager.state());
+ public void testIgnoreLeaveResponseWhenNotLeavingGroup() {
+ ConsumerMembershipManager membershipManager =
createMemberInStableState();
-
testLeaveGroupReleasesAssignmentAndResetsEpochToSendLeaveGroup(membershipManager);
+ CompletableFuture<Void> leaveResult = membershipManager.leaveGroup();
+
+ // Send leave request, transitioning to UNSUBSCRIBED state
+ membershipManager.onHeartbeatRequestGenerated();
+ assertEquals(MemberState.UNSUBSCRIBED, membershipManager.state());
+
+ // Receive a previous heartbeat response, which should be ignored
+ membershipManager.onHeartbeatSuccess(new
ConsumerGroupHeartbeatResponse(
+ new ConsumerGroupHeartbeatResponseData()
+ .setErrorCode(Errors.NONE.code())
+ .setMemberId(membershipManager.memberId())
+ .setMemberEpoch(MEMBER_EPOCH)
+ ));
+ assertFalse(leaveResult.isDone());
Review Comment:
In this line, I am leaving the group. The IgnoreLeaveResponse referes to the
fact that I ignore the heartbeat after leaving the group is further down (the
second
`membershipManager.onHeartbeatSuccess(createConsumerGroupLeaveResponse(membershipManager.memberId()));`).
--
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]