lianetm commented on code in PR #16200: URL: https://github.com/apache/kafka/pull/16200#discussion_r1669063349
########## clients/src/test/java/org/apache/kafka/clients/consumer/internals/HeartbeatRequestManagerTest.java: ########## @@ -756,18 +846,18 @@ public void testFencedMemberStopHeartbeatUntilItReleasesAssignmentToRejoin() { @ParameterizedTest @ApiKeyVersionsSource(apiKey = ApiKeys.CONSUMER_GROUP_HEARTBEAT) public void testSendingLeaveGroupHeartbeatWhenPreviousOneInFlight(final short version) { - 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.leaveGroup(); - + when(heartbeatRequestState.canSendRequest(anyLong())).thenReturn(true); + when(heartbeatState.buildRequestData()).thenReturn(new ConsumerGroupHeartbeatRequestData().setMemberEpoch(-1)); ConsumerGroupHeartbeatRequest heartbeatToLeave = getHeartbeatRequest(heartbeatRequestManager, version); assertEquals(ConsumerGroupHeartbeatRequest.LEAVE_GROUP_MEMBER_EPOCH, heartbeatToLeave.data().memberEpoch()); + when(coordinatorRequestManager.coordinator()).thenReturn(Optional.empty()); Review Comment: similar to other comments above, this will achieve the result we want (no HB), but not for the reason we wanted to test. The intention of the test was to asssert that polling the HB mananager after the request to leave has been sent will generate no request (and that's because the member transitions to UNSUBSCRIBED on `onHeartbeatRequestSent`. So probably here we should only set the expectation that shouldSkipHeartbeat returns true, which is what the HB mgr checks, and gets when the member is UNSUBSCRIBED. Makes sense? -- 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