lianetm commented on code in PR #16200:
URL: https://github.com/apache/kafka/pull/16200#discussion_r1668883729
##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/HeartbeatRequestManagerTest.java:
##########
@@ -312,31 +369,33 @@ public void testHeartbeatOutsideInterval() {
@Test
public void testNetworkTimeout() {
// The initial heartbeatInterval is set to 0
- resetWithZeroHeartbeatInterval(Optional.empty());
- mockStableMember();
+ time.sleep(DEFAULT_HEARTBEAT_INTERVAL_MS);
when(coordinatorRequestManager.coordinator()).thenReturn(Optional.of(new
Node(1, "localhost", 9999)));
+ when(heartbeatRequestState.canSendRequest(anyLong())).thenReturn(true);
NetworkClientDelegate.PollResult result =
heartbeatRequestManager.poll(time.milliseconds());
assertEquals(1, result.unsentRequests.size());
// Mimic network timeout
result.unsentRequests.get(0).handler().onFailure(time.milliseconds(),
new TimeoutException("timeout"));
+ time.sleep(1);
+ result = heartbeatRequestManager.poll(time.milliseconds());
+ assertEquals(1, result.unsentRequests.size());
+
// Assure the manager will backoff on timeout
+
when(coordinatorRequestManager.coordinator()).thenReturn(Optional.empty());
time.sleep(DEFAULT_RETRY_BACKOFF_MS - 1);
result = heartbeatRequestManager.poll(time.milliseconds());
assertEquals(0, result.unsentRequests.size());
-
- time.sleep(1);
- result = heartbeatRequestManager.poll(time.milliseconds());
- assertEquals(1, result.unsentRequests.size());
}
@Test
public void testFailureOnFatalException() {
// The initial heartbeatInterval is set to 0
- resetWithZeroHeartbeatInterval(Optional.empty());
- mockStableMember();
+ time.sleep(DEFAULT_HEARTBEAT_INTERVAL_MS);
+ when(membershipManager.isLeavingGroup()).thenReturn(true);
when(coordinatorRequestManager.coordinator()).thenReturn(Optional.of(new
Node(1, "localhost", 9999)));
+ when(heartbeatRequestState.canSendRequest(anyLong())).thenReturn(true);
Review Comment:
needed? the state is spy, so I would expect we get here the behaviour we
want, based on the interval that we already expired above, all from the real
instance
--
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]