Class ConsumerHeartbeatRequestManagerTest
java.lang.Object
org.apache.kafka.clients.consumer.internals.ConsumerHeartbeatRequestManagerTest
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidsetUp()voidtestConsumerAcksReconciledAssignmentAfterAckLost(short version) voidvoidvoidvoidvoidTest that GROUP_ID_NOT_FOUND error while unsubscribed is not treated as fatal.voidTest that GROUP_ID_NOT_FOUND error while stable is treated as fatal.voidvoidvoidvoidvoidvoidvoidtestHeartbeatResponseOnErrorHandling(org.apache.kafka.common.protocol.Errors error, boolean isFatal) voidvoidvoidvoidvoidKAFKA-20253: when the coordinator is unavailable (e.g.voidvoidvoidtestMaximumTimeToWaitWhenHeartbeatShouldBeSkipped(boolean isUnsubscribed) When the consumer uses manual partition assignment (assign()) instead of subscribe(), the member stays in UNSUBSCRIBED state indefinitely.voidWhile bootstrap DNS resolution is still in progress the coordinator is unknown, and a member that wants to join has a zero heartbeat interval, since the interval is only learned from the first heartbeat response.voidvoidvoidtestPollOnCloseGeneratesRequestIfNeeded(Optional<String> groupInstanceId, org.apache.kafka.clients.consumer.CloseOptions.GroupMembershipOperation operation) voidtestPollOnLeaving(Optional<String> groupInstanceId, org.apache.kafka.clients.consumer.CloseOptions.GroupMembershipOperation operation) voidvoidThis is expected to be the case where a member is already leaving the group and the poll timer expires.voidvoidvoidvoidtestSendingLeaveGroupHeartbeatWhenPreviousOneInFlight(short version) voidtestSkippingHeartbeat(boolean shouldSkipHeartbeat) voidvoidvoidtestUnsupportedVersionFromBroker(String errorMsg) This validates the UnsupportedApiVersion the client generates while building a HB if: 1.voidtestUnsupportedVersionFromClient(org.apache.kafka.common.errors.UnsupportedVersionException thrown, String errorMsg) This validates the UnsupportedApiVersion the client generates while building a HB if: REGEX_RESOLUTION_NOT_SUPPORTED_MSG only generated on the client side.voidtestValidateConsumerGroupHeartbeatRequest(short version) void
-
Constructor Details
-
ConsumerHeartbeatRequestManagerTest
public ConsumerHeartbeatRequestManagerTest()
-
-
Method Details
-
setUp
@BeforeEach public void setUp() -
testHeartBeatRequestStateToStringBase
@Test public void testHeartBeatRequestStateToStringBase() -
testHeartbeatOnStartup
@Test public void testHeartbeatOnStartup() -
testFirstHeartbeatIncludesRequiredInfoToJoinGroupAndGetAssignments
@ParameterizedTest public void testFirstHeartbeatIncludesRequiredInfoToJoinGroupAndGetAssignments(short version) -
testSkippingHeartbeat
@ParameterizedTest @ValueSource(booleans={true,false}) public void testSkippingHeartbeat(boolean shouldSkipHeartbeat) -
testMaximumTimeToWaitWhenHeartbeatShouldBeSkipped
@ParameterizedTest @ValueSource(booleans={true,false}) public void testMaximumTimeToWaitWhenHeartbeatShouldBeSkipped(boolean isUnsubscribed) When the consumer uses manual partition assignment (assign()) instead of subscribe(), the member stays in UNSUBSCRIBED state indefinitely. Because heartbeats are skipped in that state and heartbeatIntervalMs initialises to 0, maximumTimeToWait used to return 0, causing a busy-loop in pollForFetches. Verify that maximumTimeToWait returns Long.MAX_VALUE whenever the member is in UNSUBSCRIBED state so the application thread can block for the full poll timeout. -
testMaximumTimeToWaitWhenJoiningAndCoordinatorUnknownDoesNotSpin
@Test public void testMaximumTimeToWaitWhenJoiningAndCoordinatorUnknownDoesNotSpin()While bootstrap DNS resolution is still in progress the coordinator is unknown, and a member that wants to join has a zero heartbeat interval, since the interval is only learned from the first heartbeat response. maximumTimeToWait() must wait a retry backoff rather than the (zero) heartbeat interval; returning 0 busy-spins the application and network threads. -
testMaximumTimeToWaitWhenFatalReturnsMaxValue
@Test public void testMaximumTimeToWaitWhenFatalReturnsMaxValue() -
testMaximumTimeToWaitWhenFencedWaitsRetryBackoff
@Test public void testMaximumTimeToWaitWhenFencedWaitsRetryBackoff() -
testMaximumTimeToWaitDoesNotSpinDuringRealBootstrapDnsResolution
-
testHeartbeatNotSentIfAnotherOneInFlight
@Test public void testHeartbeatNotSentIfAnotherOneInFlight() -
testNetworkTimeout
@Test public void testNetworkTimeout() -
testDisconnect
@Test public void testDisconnect() -
testFailureOnFatalException
@Test public void testFailureOnFatalException() -
testHeartbeatResponseErrorNotifiedToGroupManagerAfterErrorPropagated
@Test public void testHeartbeatResponseErrorNotifiedToGroupManagerAfterErrorPropagated() -
testHeartbeatRequestFailureNotifiedToGroupManagerAfterErrorPropagated
@Test public void testHeartbeatRequestFailureNotifiedToGroupManagerAfterErrorPropagated() -
testValidateConsumerGroupHeartbeatRequest
@ParameterizedTest public void testValidateConsumerGroupHeartbeatRequest(short version) -
testValidateConsumerGroupHeartbeatRequestAssignmentSentWhenLocalEpochChanges
@ParameterizedTest public void testValidateConsumerGroupHeartbeatRequestAssignmentSentWhenLocalEpochChanges(short version) -
testUnsupportedVersionFromBroker
@ParameterizedTest @ValueSource(strings="The cluster does not support the new CONSUMER group protocol. Set group.protocol=classic on the consumer configs to revert to the CLASSIC protocol until the cluster is upgraded.") public void testUnsupportedVersionFromBroker(String errorMsg) This validates the UnsupportedApiVersion the client generates while building a HB if: 1. HB API is not supported. 2. Required HB API version is not available. -
testUnsupportedVersionFromClient
@ParameterizedTest @MethodSource("unsupportedVersionFromClientCases") public void testUnsupportedVersionFromClient(org.apache.kafka.common.errors.UnsupportedVersionException thrown, String errorMsg) This validates the UnsupportedApiVersion the client generates while building a HB if: REGEX_RESOLUTION_NOT_SUPPORTED_MSG only generated on the client side. -
testHeartbeatState
@Test public void testHeartbeatState() -
testPollTimerExpiration
@Test public void testPollTimerExpiration() -
testPollOnLeaving
-
testisExpiredByUsedForLogging
@Test public void testisExpiredByUsedForLogging() -
testFencedMemberStopHeartbeatUntilItReleasesAssignmentToRejoin
@Test public void testFencedMemberStopHeartbeatUntilItReleasesAssignmentToRejoin() -
testSendingLeaveGroupHeartbeatWhenPreviousOneInFlight
@ParameterizedTest public void testSendingLeaveGroupHeartbeatWhenPreviousOneInFlight(short version) -
testConsumerAcksReconciledAssignmentAfterAckLost
@ParameterizedTest public void testConsumerAcksReconciledAssignmentAfterAckLost(short version) -
testPollOnCloseGeneratesRequestIfNeeded
-
testRegexInHeartbeatLifecycle
@Test public void testRegexInHeartbeatLifecycle() -
testRegexInJoiningHeartbeat
@Test public void testRegexInJoiningHeartbeat() -
testRackIdInHeartbeatLifecycle
@Test public void testRackIdInHeartbeatLifecycle() -
testTimerNotDue
@Test public void testTimerNotDue() -
testHeartbeatOutsideInterval
@Test public void testHeartbeatOutsideInterval() -
testNoCoordinator
@Test public void testNoCoordinator() -
testPollTimerExpirationShouldNotMarkMemberStaleIfMemberAlreadyLeaving
@Test public void testPollTimerExpirationShouldNotMarkMemberStaleIfMemberAlreadyLeaving()This is expected to be the case where a member is already leaving the group and the poll timer expires. The poll timer expiration should not transition the member to STALE, and the member should continue to send heartbeats while the ongoing leaving operation completes (send heartbeats while waiting for callbacks before leaving, or send last heartbeat to leave). -
testSuccessfulHeartbeatTiming
@Test public void testSuccessfulHeartbeatTiming() -
testLogsHeartbeatIntervalReceivedFromCoordinatorOnlyWhenChanged
@Test public void testLogsHeartbeatIntervalReceivedFromCoordinatorOnlyWhenChanged() -
testGroupIdNotFoundExceptionWhileUnsubscribed
@Test public void testGroupIdNotFoundExceptionWhileUnsubscribed()Test that GROUP_ID_NOT_FOUND error while unsubscribed is not treated as fatal. This can happen when the consumer never successfully joined the group (e.g., due to an InvalidTopicException during poll() and close() sends a leave heartbeat for a group that was never created). -
testGroupIdNotFoundWhileStableIsFatal
@Test public void testGroupIdNotFoundWhileStableIsFatal()Test that GROUP_ID_NOT_FOUND error while stable is treated as fatal. This would indicate the group was unexpectedly deleted while the member was actively participating. -
testHeartbeatResponseOnErrorHandling
@ParameterizedTest @MethodSource("errorProvider") public void testHeartbeatResponseOnErrorHandling(org.apache.kafka.common.protocol.Errors error, boolean isFatal)
-