-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-16557 Implemented OffsetFetchRequestState toStringBase and added a test for it #16291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
81a5572
7147a27
e91891f
caf17bb
1941a55
5768017
94f26b5
837d9ea
98361ea
f061d97
2583e12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,6 +75,7 @@ | |
| import static org.apache.kafka.clients.consumer.internals.ConsumerTestBuilder.DEFAULT_GROUP_ID; | ||
| import static org.apache.kafka.clients.consumer.internals.ConsumerTestBuilder.DEFAULT_GROUP_INSTANCE_ID; | ||
| import static org.apache.kafka.test.TestUtils.assertFutureThrows; | ||
| import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.junit.jupiter.api.Assertions.assertInstanceOf; | ||
|
|
@@ -122,6 +123,48 @@ public void setup() { | |
| this.props.put(VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); | ||
| } | ||
|
|
||
| @Test | ||
| public void testOffsetFetchRequestStateToStringBase() { | ||
| ConsumerConfig config = mock(ConsumerConfig.class); | ||
| CommitRequestManager.MemberInfo memberInfo = new CommitRequestManager.MemberInfo(); | ||
|
|
||
| CommitRequestManager commitRequestManager = new CommitRequestManager( | ||
| time, | ||
| logContext, | ||
| subscriptionState, | ||
| config, | ||
| coordinatorRequestManager, | ||
| offsetCommitCallbackInvoker, | ||
| "groupId", | ||
| Optional.of("groupInstanceId"), | ||
| metrics); | ||
|
|
||
| commitRequestManager.onMemberEpochUpdated(Optional.of(1), Optional.empty()); | ||
| Set<TopicPartition> requestedPartitions = Collections.singleton(new TopicPartition("topic-1", 1)); | ||
|
|
||
| CommitRequestManager.OffsetFetchRequestState offsetFetchRequestState = commitRequestManager.new OffsetFetchRequestState( | ||
| requestedPartitions, | ||
| retryBackoffMs, | ||
| retryBackoffMaxMs, | ||
| 1000, | ||
| memberInfo); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the line#142 - The If we want to complete the test, maybe we can remove
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am a bit hesitant to change the constructor of |
||
|
|
||
| TimedRequestState timedRequestState = new TimedRequestState( | ||
| logContext, | ||
| "CommitRequestManager", | ||
| retryBackoffMs, | ||
| retryBackoffMaxMs, | ||
| TimedRequestState.deadlineTimer(time, 0) | ||
| ); | ||
|
|
||
| String target = timedRequestState.toStringBase() + | ||
| ", " + memberInfo + | ||
| ", requestedPartitions=" + offsetFetchRequestState.requestedPartitions; | ||
|
|
||
| assertDoesNotThrow(timedRequestState::toString); | ||
| assertEquals(target, offsetFetchRequestState.toStringBase()); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can add
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added! |
||
|
|
||
| @Test | ||
| public void testPollSkipIfCoordinatorUnknown() { | ||
| CommitRequestManager commitRequestManager = create(false, 0); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we had discussion about "Optional#toString", maybe we define either
MemberInfo#memberIdorMemberInfo#memberEpoch, and then we should check theMemberInfo#toStringdoes not contain "Optional[value]"There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you meant now, I have implemented a setter for
MemberInfo#memberEpochand set the memberEpoch value. Upon testing, there is no "Optional[value]"Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brenden20 we already have an
onMemberEpochUpdatedthat you could maybe use for this? so we don't have to add a new setter. That's the actual method that gets called when the member gets a new epoch on the heartbeat response, and we want to pass it on to the commit manager ;)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lianetm oh I see it now, I will revert that change and use
onMemberEpochUpdatedinstead. Thank you!