KAFKA-20733: Fix fetchResponseWithUnexpectedPartitionIsIgnored passing for wrong reason with CONSUMER protocol#22651
Open
david-parkk wants to merge 4 commits into
Open
KAFKA-20733: Fix fetchResponseWithUnexpectedPartitionIsIgnored passing for wrong reason with CONSUMER protocol#22651david-parkk wants to merge 4 commits into
david-parkk wants to merge 4 commits into
Conversation
…est to CLASSIC protocol
lianetm
reviewed
Jun 23, 2026
| @ParameterizedTest | ||
| @EnumSource(GroupProtocol.class) | ||
| public void fetchResponseWithUnexpectedPartitionIsIgnored(GroupProtocol groupProtocol) { | ||
| @EnumSource(value = GroupProtocol.class, names = "CLASSIC") |
Member
There was a problem hiding this comment.
could you please add a comment here that CONSUMER is tested separately (just to avoid confusion, it's not that the asyncConsumer does not support this)
Contributor
Author
|
@lianetm Thanks for the review! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
KafkaConsumerTest.fetchResponseWithUnexpectedPartitionIsIgnoredwasannotated with
@EnumSource(GroupProtocol.class), but the CONSUMERprotocol case passed for the wrong reason.
The CONSUMER protocol uses
FetchRequestManagerand relies onConsumerGroupHeartbeatfor rebalancing. Since the test does not set upheartbeat-based rebalancing, partition assignment never completes and 0
records are returned — not because
FetchSessionHandlercorrectlyrejected the response.
Analysis
While writing the CONSUMER protocol test, we first attempted to use
AsyncKafkaConsumerTestas a reference. However, it was not suitablebecause
fetchCollectoris replaced with a Mock, meaningFetchSessionHandler's actual rejection logic is never exercised.We also found that naively adding the CONSUMER case to
KafkaConsumerTestdoes not work either. The test usesprepareResponse()for the Join and Sync group requests, but theseresponses were never consumed — because the CONSUMER protocol does not
go through the classic Join/Sync rebalance flow. As a result, the fetch
phase was never reached.
FetchRequestManagerTestis the correctlocation for this test, as it directly runs
FetchSessionHandlerwithout mocking.
Changes
KafkaConsumerTest: RestrictfetchResponseWithUnexpectedPartitionIsIgnoredtoCLASSICprotocolonly, where the existing setup correctly exercises
FetchSessionHandler's unexpected partition rejection logic.FetchRequestManagerTest: AddtestFetchResponseWithUnexpectedPartitionIsIgnoredto properly coverthe CONSUMER protocol path. The test verifies that when a
FetchResponsecontains a partition not included in theFetchRequest,FetchSessionHandlerrejects the entire response and no records arereturned to the consumer.
+
KafkaConsumerTest: RenamefetchResponseWithUnexpectedPartitionIsIgnoredtotestFetchResponseWithUnexpectedPartitionIsIgnoredto align with theexisting test naming convention in the class.
Reviewers: Lianet Magrans lmagrans@confluent.io
I'm happy to make any adjustments based on your feedback. Thank you to
the maintainers for taking the time to review this contribution!