ShivsundarR commented on code in PR #19818: URL: https://github.com/apache/kafka/pull/19818#discussion_r2108331701
########## clients/src/test/java/org/apache/kafka/clients/consumer/internals/ShareMembershipManagerTest.java: ########## @@ -561,10 +568,42 @@ 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 testIgnoreLeaveResponseWhenNotLeavingGroup() { + ShareMembershipManager membershipManager = createMemberInStableState(); + + 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 Review Comment: This response is not "ignored" right, we are setting the member epoch in the response to `membershipManager.memberEpoch` (-1 in this case). The leave operation is then processed successfully post which we are asserting if `leaveResult` has completed. If this is the case, can we change the comment above to reflect the same. (and in the other tests too). Thanks. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org