lianetm commented on code in PR #16017:
URL: https://github.com/apache/kafka/pull/16017#discussion_r1617879454


##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/HeartbeatRequestManagerTest.java:
##########
@@ -880,4 +880,25 @@ private HeartbeatRequestManager 
createHeartbeatRequestManager(
                 backgroundEventHandler,
                 metrics);
     }
+
+
+    @Test
+    public void reproduceHeartbeatFail() throws InterruptedException {
+        mockStableMember();
+        time.sleep(DEFAULT_HEARTBEAT_INTERVAL_MS);
+        NetworkClientDelegate.PollResult result = 
heartbeatRequestManager.poll(time.milliseconds());
+        assertEquals(1, result.unsentRequests.size());
+
+        result = heartbeatRequestManager.poll(time.milliseconds());
+        assertEquals(0, result.unsentRequests.size(), "No heartbeat should be 
sent while a previous one is in-flight");
+
+        membershipManager.transitionToSendingLeaveGroup(true);
+        assertTrue(membershipManager.isLeavingGroup());
+
+        NetworkClientDelegate.PollResult resultAfterLeaving = 
heartbeatRequestManager.poll(time.milliseconds());
+        assertEquals(1, resultAfterLeaving.unsentRequests.size());

Review Comment:
   Here it would be helpful to check that the HB request generated is indeed 
the one to leave the group. So what about checking that 
`ConsumerGroupHeartbeatRequest` contained in the resultAfterLeaving has 
actually the leave epoch? There is already a utility func 
[getHeartbeatRequest](https://github.com/apache/kafka/blob/4d04eb83ea2cf67484d81e30603e976f63616428/clients/src/test/java/org/apache/kafka/clients/consumer/internals/HeartbeatRequestManagerTest.java#L423)
 in this class to help you with that. 



-- 
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

Reply via email to