Class ConsumerMembershipManagerTest
java.lang.Object
org.apache.kafka.clients.consumer.internals.ConsumerMembershipManagerTest
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidsetup()voidvoidvoidvoidvoidThis is the case where a member is stuck reconciling an assignment A (waiting on metadata, commit or callbacks), and the target assignment changes due to new topics.voidThis is the case where a member is stuck reconciling an assignment A (waiting on metadata, commit or callbacks), and the target assignment changes due to a new assignment received from broker.voidThis is the case where a member is stuck reconciling an assignment A (waiting for commit to complete), and it rejoins (due to fence or unsubscribe/subscribe).voidThis is the case where a member is stuck reconciling an assignment A (waiting for onPartitionsAssigned callback to complete), and it rejoins (due to fence or unsubscribe/subscribe).voidThis is the case where a member is stuck reconciling an assignment A (waiting for onPartitionsRevoked callback to complete), and it rejoins (due to fence or unsubscribe/subscribe).voidThis is the case where a member is stuck reconciling and transitions out of the RECONCILING state (due to failure).voidvoidvoidvoidvoidvoidvoidvoidMembers keep sending heartbeats while preparing to leave, so they could get fenced.voidvoidvoidvoidtestHeartbeatFailedResponseWhenLeavingGroupCompletesLeave(boolean retriableResponseError) voidvoidtestIgnoreHeartbeatResponseWhenNotInGroup(org.apache.kafka.clients.consumer.internals.MemberState state) voidvoidTest that when unsubscribe/leaveGroup is called during an ongoing reconciliation and the pending assignment event is completed exceptionally, the member can still rejoin and start a new reconciliation.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidThis test should be the case when an assignment is sent to the member, and it cannot find it in metadata (temporarily).voidvoidvoidvoidvoidvoidvoidvoidvoidThis test should be the case when an assignment is sent to the member, and it cannot find it in metadata (permanently, ex.voidThis test ensures that member goes back to STABLE when the broker sends assignment that removes the unresolved target the client has, without triggering a reconciliation.voidvoidvoidvoidvoidWhen the resolvable subset of the target equals the current assignment but some topic ids remain unresolved, the partial acknowledgement must fire exactly once per target epoch - regardless of which thread invokes maybeReconcile.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidThis is the case where a member rejoins (due to fence).voidThis is the case where we receive a new assignment while reconciling an existing one.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidThis ensures that the client reconciles target assignments as soon as they are discovered in metadata, without depending on the broker to re-send the assignment.void
-
Constructor Details
-
ConsumerMembershipManagerTest
public ConsumerMembershipManagerTest()
-
-
Method Details
-
setup
@BeforeEach public void setup() -
testMembershipManagerServerAssignor
@Test public void testMembershipManagerServerAssignor() -
testMembershipManagerRackId
@Test public void testMembershipManagerRackId() -
testAssignedPartitionCountMetricRegistered
@Test public void testAssignedPartitionCountMetricRegistered() -
testMembershipManagerInitSupportsEmptyGroupInstanceId
@Test public void testMembershipManagerInitSupportsEmptyGroupInstanceId() -
testReconcilingWhenReceivingAssignmentFoundInMetadata
@Test public void testReconcilingWhenReceivingAssignmentFoundInMetadata() -
testTransitionToReconcilingIfEmptyAssignmentReceived
@Test public void testTransitionToReconcilingIfEmptyAssignmentReceived() -
testMemberIdAndEpochResetOnFencedMembers
@Test public void testMemberIdAndEpochResetOnFencedMembers() -
testTransitionToFatal
@Test public void testTransitionToFatal() -
testTransitionToFailedWhenTryingToJoin
@Test public void testTransitionToFailedWhenTryingToJoin() -
testFencingWhenStateIsStable
@Test public void testFencingWhenStateIsStable() -
testTransitionToFencedMarksPendingRevocationBeforeSignalingPartitionsLost
@Test public void testTransitionToFencedMarksPendingRevocationBeforeSignalingPartitionsLost() -
testTransitionToFatalMarksPendingRevocationBeforeSignalingPartitionsLost
@Test public void testTransitionToFatalMarksPendingRevocationBeforeSignalingPartitionsLost() -
testTransitionToStaleMarksPendingRevocationBeforeSignalingPartitionsLost
@Test public void testTransitionToStaleMarksPendingRevocationBeforeSignalingPartitionsLost() -
testListenersGetNotifiedOnTransitionsToFatal
@Test public void testListenersGetNotifiedOnTransitionsToFatal() -
testListenersGetNotifiedOnTransitionsToLeavingGroup
@Test public void testListenersGetNotifiedOnTransitionsToLeavingGroup() -
testListenersGetNotifiedOfMemberEpochUpdatesOnlyIfItChanges
@Test public void testListenersGetNotifiedOfMemberEpochUpdatesOnlyIfItChanges() -
testFencingWhenStateIsReconciling
@Test public void testFencingWhenStateIsReconciling() -
testFencingWhenStateIsPrepareLeaving
@Test public void testFencingWhenStateIsPrepareLeaving()Members keep sending heartbeats while preparing to leave, so they could get fenced. This tests ensures that if a member gets fenced while preparing to leave, it will directly transition to UNSUBSCRIBE (no callbacks triggered or rejoin as in regular fencing scenarios), and when the PREPARE_LEAVING completes it remains UNSUBSCRIBED (no last heartbeat sent). -
testFencingWhenStateIsPrepareLeavingCompletesTheLeaveOperation
@Test public void testFencingWhenStateIsPrepareLeavingCompletesTheLeaveOperation() -
testNewAssignmentIgnoredWhenStateIsPrepareLeaving
@Test public void testNewAssignmentIgnoredWhenStateIsPrepareLeaving() -
testFencingWhenStateIsLeaving
@Test public void testFencingWhenStateIsLeaving() -
testLeaveGroupEpoch
@Test public void testLeaveGroupEpoch() -
testLeaveGroupEpochOnClose
@Test public void testLeaveGroupEpochOnClose() -
testDelayedReconciliationResultDiscardedIfMemberNotInReconcilingStateAnymore
@Test public void testDelayedReconciliationResultDiscardedIfMemberNotInReconcilingStateAnymore()This is the case where a member is stuck reconciling and transitions out of the RECONCILING state (due to failure). When the reconciliation completes it should not be applied because it is not relevant anymore (it should not update the assignment on the member or send ack). -
testDelayedReconciliationResultDiscardedAfterCommitIfMemberRejoins
@Test public void testDelayedReconciliationResultDiscardedAfterCommitIfMemberRejoins()This is the case where a member is stuck reconciling an assignment A (waiting for commit to complete), and it rejoins (due to fence or unsubscribe/subscribe). If the reconciliation of A completes it should be interrupted, and it should not update the assignment on the member or send ack. -
testDelayedReconciliationResultDiscardedAfterPartitionsRevokedCallbackIfMemberRejoins
@Test public void testDelayedReconciliationResultDiscardedAfterPartitionsRevokedCallbackIfMemberRejoins()This is the case where a member is stuck reconciling an assignment A (waiting for onPartitionsRevoked callback to complete), and it rejoins (due to fence or unsubscribe/subscribe). When the reconciliation of A completes it should be interrupted, and it should not update the assignment on the member or send ack. -
testDelayedReconciliationResultDiscardedAfterPartitionsAssignedCallbackIfMemberRejoins
@Test public void testDelayedReconciliationResultDiscardedAfterPartitionsAssignedCallbackIfMemberRejoins()This is the case where a member is stuck reconciling an assignment A (waiting for onPartitionsAssigned callback to complete), and it rejoins (due to fence or unsubscribe/subscribe). If the reconciliation of A completes it should be interrupted, and it should not update the assignment on the member or send ack. -
testSameAssignmentReconciledAgainWhenFenced
@Test public void testSameAssignmentReconciledAgainWhenFenced()This is the case where a member rejoins (due to fence). If the member gets the same assignment again, it should still reconcile and ack the assignment. -
testSameAssignmentReconciledAgainWithMissingTopic
@Test public void testSameAssignmentReconciledAgainWithMissingTopic()This is the case where we receive a new assignment while reconciling an existing one. The intermediate assignment is not applied, and a new assignment containing the same partitions is received and reconciled. In all assignments, one topic is not resolvable. We need to make sure that the last assignment is acked and applied, even though the set of partitions does not change. In this case, no rebalance listeners are run. -
testDelayedReconciliationResultAppliedWhenTargetChangedWithMetadataUpdate
@Test public void testDelayedReconciliationResultAppliedWhenTargetChangedWithMetadataUpdate()This is the case where a member is stuck reconciling an assignment A (waiting on metadata, commit or callbacks), and the target assignment changes due to new topics. If the reconciliation of A completes it should be applied (should update the assignment on the member and send ack), and then the reconciliation of assignment B will be processed and applied in the next reconciliation loop. -
testDelayedReconciliationResultAppliedWhenTargetChangedWithNewAssignment
@Test public void testDelayedReconciliationResultAppliedWhenTargetChangedWithNewAssignment()This is the case where a member is stuck reconciling an assignment A (waiting on metadata, commit or callbacks), and the target assignment changes due to a new assignment received from broker. If the reconciliation of A completes it should be applied (should update the assignment on the member and send ack), and then the reconciliation of assignment B will be processed and applied in the next reconciliation loop. -
testPartialAckNotRepeatedOnBackgroundReconcileWhenMetadataMissing
@Test public void testPartialAckNotRepeatedOnBackgroundReconcileWhenMetadataMissing()When the resolvable subset of the target equals the current assignment but some topic ids remain unresolved, the partial acknowledgement must fire exactly once per target epoch - regardless of which thread invokes maybeReconcile. The first attempt (background or foreground) acks the resolvable fragment; subsequent attempts must stay in RECONCILING to avoid emitting redundant heartbeats. -
testDelayedMetadataUsedToCompleteAssignment
@Test public void testDelayedMetadataUsedToCompleteAssignment() -
testLeaveGroupWhenStateIsStable
@Test public void testLeaveGroupWhenStateIsStable() -
testHeartbeatSuccessfulResponseWhenLeavingGroupCompletesLeave
@Test public void testHeartbeatSuccessfulResponseWhenLeavingGroupCompletesLeave() -
testHeartbeatFailedResponseWhenLeavingGroupCompletesLeave
@ParameterizedTest @ValueSource(booleans={true,false}) public void testHeartbeatFailedResponseWhenLeavingGroupCompletesLeave(boolean retriableResponseError) -
testIgnoreHeartbeatResponseWhenNotInGroup
@ParameterizedTest @MethodSource("notInGroupStates") public void testIgnoreHeartbeatResponseWhenNotInGroup(org.apache.kafka.clients.consumer.internals.MemberState state) -
testIgnoreLeaveResponseWhenNotLeavingGroup
@Test public void testIgnoreLeaveResponseWhenNotLeavingGroup() -
testLeaveGroupWhenMemberOwnsAssignment
@Test public void testLeaveGroupWhenMemberOwnsAssignment() -
testFencedWhenAssignmentEmpty
@Test public void testFencedWhenAssignmentEmpty() -
testLeaveGroupWhenMemberAlreadyLeaving
@Test public void testLeaveGroupWhenMemberAlreadyLeaving() -
testLeaveGroupWhenMemberAlreadyLeft
@Test public void testLeaveGroupWhenMemberAlreadyLeft() -
testLeaveGroupWhenMemberFenced
@Test public void testLeaveGroupWhenMemberFenced() -
testLeaveGroupWhenMemberIsStale
@Test public void testLeaveGroupWhenMemberIsStale() -
testLeaveGroupDuringReconciliationThenRejoin
@Test public void testLeaveGroupDuringReconciliationThenRejoin()Test that when unsubscribe/leaveGroup is called during an ongoing reconciliation and the pending assignment event is completed exceptionally, the member can still rejoin and start a new reconciliation. -
testFatalFailureWhenStateIsUnjoined
@Test public void testFatalFailureWhenStateIsUnjoined() -
testFatalFailureWhenStateIsStable
@Test public void testFatalFailureWhenStateIsStable() -
testFatalFailureWhenStateIsPrepareLeaving
@Test public void testFatalFailureWhenStateIsPrepareLeaving() -
testFatalFailureWhenStateIsLeaving
@Test public void testFatalFailureWhenStateIsLeaving() -
testFatalFailureWhenMemberAlreadyLeft
@Test public void testFatalFailureWhenMemberAlreadyLeft() -
testUpdateStateFailsOnResponsesWithErrors
@Test public void testUpdateStateFailsOnResponsesWithErrors() -
testNewAssignmentReplacesPreviousOneWaitingOnMetadata
@Test public void testNewAssignmentReplacesPreviousOneWaitingOnMetadata()This test should be the case when an assignment is sent to the member, and it cannot find it in metadata (permanently, ex. topic deleted). The member will keep the assignment as waiting for metadata, but the following assignment received from the broker will not contain the deleted topic. The member will discard the assignment that was pending and proceed with the reconciliation of the new assignment. -
testNewEmptyAssignmentReplacesPreviousOneWaitingOnMetadata
@Test public void testNewEmptyAssignmentReplacesPreviousOneWaitingOnMetadata()This test ensures that member goes back to STABLE when the broker sends assignment that removes the unresolved target the client has, without triggering a reconciliation. In this case the member should discard the assignment that was unresolved and go back to STABLE with nothing to reconcile. -
testNewAssignmentNotInMetadataReplacesPreviousOneWaitingOnMetadata
@Test public void testNewAssignmentNotInMetadataReplacesPreviousOneWaitingOnMetadata() -
testUnresolvedTargetAssignmentIsReconciledWhenMetadataReceived
@Test public void testUnresolvedTargetAssignmentIsReconciledWhenMetadataReceived()This ensures that the client reconciles target assignments as soon as they are discovered in metadata, without depending on the broker to re-send the assignment. -
testMemberKeepsUnresolvedAssignmentWaitingForMetadataUntilResolved
@Test public void testMemberKeepsUnresolvedAssignmentWaitingForMetadataUntilResolved()This test should be the case when an assignment is sent to the member, and it cannot find it in metadata (temporarily). If the broker continues to send the assignment to the member, this one should keep it waiting for metadata and continue to request updates. -
testReconcileNewPartitionsAssignedWhenNoPartitionOwned
@Test public void testReconcileNewPartitionsAssignedWhenNoPartitionOwned() -
testReconcileNewPartitionsAssignedWhenOtherPartitionsOwned
@Test public void testReconcileNewPartitionsAssignedWhenOtherPartitionsOwned() -
testReconciliationSkippedWhenSameAssignmentReceived
@Test public void testReconciliationSkippedWhenSameAssignmentReceived() -
testReconcilePartitionsRevokedNoAutoCommitNoCallbacks
@Test public void testReconcilePartitionsRevokedNoAutoCommitNoCallbacks() -
testReconcilePartitionsRevokedWithSuccessfulAutoCommitNoCallbacks
@Test public void testReconcilePartitionsRevokedWithSuccessfulAutoCommitNoCallbacks() -
testReconcilePartitionsRevokedWithFailedAutoCommitCompletesRevocationAnyway
@Test public void testReconcilePartitionsRevokedWithFailedAutoCommitCompletesRevocationAnyway() -
testReconcileNewPartitionsAssignedAndRevoked
@Test public void testReconcileNewPartitionsAssignedAndRevoked() -
testMetadataUpdatesReconcilesUnresolvedAssignments
@Test public void testMetadataUpdatesReconcilesUnresolvedAssignments() -
testMetadataUpdatesRequestsAnotherUpdateIfNeeded
@Test public void testMetadataUpdatesRequestsAnotherUpdateIfNeeded() -
testRevokePartitionsUsesTopicNamesLocalCacheWhenMetadataNotAvailable
@Test public void testRevokePartitionsUsesTopicNamesLocalCacheWhenMetadataNotAvailable() -
testOnSubscriptionUpdatedDoesNotTransitionToJoiningIfInGroup
@Test public void testOnSubscriptionUpdatedDoesNotTransitionToJoiningIfInGroup() -
testOnSubscriptionUpdatedTransitionsToJoiningOnPollIfNotInGroup
@Test public void testOnSubscriptionUpdatedTransitionsToJoiningOnPollIfNotInGroup() -
testListenerCallbacksBasic
@Test public void testListenerCallbacksBasic() -
testListenerCallbacksThrowsErrorOnPartitionsRevoked
@Test public void testListenerCallbacksThrowsErrorOnPartitionsRevoked() -
testListenerCallbacksThrowsErrorOnPartitionsAssigned
@Test public void testListenerCallbacksThrowsErrorOnPartitionsAssigned() -
testAddedPartitionsTemporarilyDisabledAwaitingOnPartitionsAssignedCallback
@Test public void testAddedPartitionsTemporarilyDisabledAwaitingOnPartitionsAssignedCallback() -
testAddedPartitionsNotEnabledAfterFailedOnPartitionsAssignedCallback
@Test public void testAddedPartitionsNotEnabledAfterFailedOnPartitionsAssignedCallback() -
testOnPartitionsLostNoError
@Test public void testOnPartitionsLostNoError() -
testOnPartitionsLostError
@Test public void testOnPartitionsLostError() -
testTransitionToLeavingWhileReconcilingDueToStaleMember
@Test public void testTransitionToLeavingWhileReconcilingDueToStaleMember() -
testTransitionToLeavingWhileJoiningDueToStaleMember
@Test public void testTransitionToLeavingWhileJoiningDueToStaleMember() -
testTransitionToLeavingWhileStableDueToStaleMember
@Test public void testTransitionToLeavingWhileStableDueToStaleMember() -
testTransitionToLeavingWhileAcknowledgingDueToStaleMember
@Test public void testTransitionToLeavingWhileAcknowledgingDueToStaleMember() -
testStaleMemberDoesNotSendHeartbeatAndAllowsTransitionToJoiningToRecover
@Test public void testStaleMemberDoesNotSendHeartbeatAndAllowsTransitionToJoiningToRecover() -
testStaleMemberRejoinsWhenTimerResetsNoCallbacks
@Test public void testStaleMemberRejoinsWhenTimerResetsNoCallbacks() -
testStaleMemberWaitsForCallbackToRejoinWhenTimerReset
@Test public void testStaleMemberWaitsForCallbackToRejoinWhenTimerReset() -
testMemberJoiningTransitionsToStableWhenReceivingEmptyAssignment
@Test public void testMemberJoiningTransitionsToStableWhenReceivingEmptyAssignment() -
testMemberJoiningCallsRebalanceListenerWhenReceivingEmptyAssignment
@Test public void testMemberJoiningCallsRebalanceListenerWhenReceivingEmptyAssignment() -
testMetricsWhenHeartbeatFailed
@Test public void testMetricsWhenHeartbeatFailed() -
testRebalanceMetricsOnSuccessfulRebalance
@Test public void testRebalanceMetricsOnSuccessfulRebalance() -
testRebalanceMetricsForMultipleReconciliations
@Test public void testRebalanceMetricsForMultipleReconciliations() -
testRebalanceMetricsOnFailedRebalance
@Test public void testRebalanceMetricsOnFailedRebalance() -
testPollMustCallsMaybeReconcileWithFalse
@Test public void testPollMustCallsMaybeReconcileWithFalse()
-