-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-16557 Implemented OffsetFetchRequestState toStringBase and added a test for it in CommitRequestManagerTest #16115
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 20 commits
b9499c2
58f1ca4
7a5f172
4f56809
1dea30d
cee03b7
42c7826
935f0b8
272d5de
7aa6ba5
f5a3748
b560db3
8d7ddbb
3d9f58b
426313a
4461145
a252ec1
33a7748
554ad53
f5abcc5
7e8be50
97c29c6
df3e2ae
c34f473
9265258
74034dc
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 |
|---|---|---|
|
|
@@ -76,6 +76,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; | ||
|
|
@@ -123,6 +124,50 @@ public void setup() { | |
| this.props.put(VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); | ||
| } | ||
|
|
||
| @Test | ||
| public void testOffsetFetchRequestStateToStringBase() { | ||
| ConsumerConfig config = mock(ConsumerConfig.class); | ||
|
brenden20 marked this conversation as resolved.
|
||
| CommitRequestManager.MemberInfo memberInfo = new CommitRequestManager.MemberInfo(); | ||
|
|
||
| CommitRequestManager commitRequestManager = new CommitRequestManager( | ||
| time, | ||
| logContext, | ||
| subscriptionState, | ||
| config, | ||
| coordinatorRequestManager, | ||
| offsetCommitCallbackInvoker, | ||
| "groupId", | ||
| Optional.of("groupInstanceId"), | ||
| metrics); | ||
|
|
||
| Set<TopicPartition> requestedPartitions = new HashSet<>(); | ||
| TopicPartition topicPartition1 = new TopicPartition("topic-1", 1); | ||
| requestedPartitions.add(topicPartition1); | ||
|
|
||
| CommitRequestManager.OffsetFetchRequestState offsetFetchRequestState = commitRequestManager.new OffsetFetchRequestState( | ||
| requestedPartitions, | ||
| retryBackoffMs, | ||
| retryBackoffMaxMs, | ||
| 1000, | ||
| memberInfo); | ||
|
|
||
| RequestState requestState = new RequestState( | ||
|
brenden20 marked this conversation as resolved.
|
||
| logContext, | ||
| "CommitRequestManager", | ||
| retryBackoffMs, | ||
| retryBackoffMaxMs); | ||
|
|
||
| String target = requestState.toStringBase() + | ||
| ", memberInfo=" + memberInfo + | ||
| ", expirationTimeMs=" + (offsetFetchRequestState.expirationTimeMs().isPresent() ? offsetFetchRequestState.expirationTimeMs() : "undefined") + | ||
|
Contributor
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. we can directly do
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. Looking at the code, I am able to do this, however it will cause an issue with OffsetFetchRequestState.toStringBase(). |
||
| ", isExpired=" + offsetFetchRequestState.isExpired + | ||
| ", requestedPartitions=" + offsetFetchRequestState.requestedPartitions + | ||
| ", future=" + offsetFetchRequestState.future(); | ||
|
|
||
|
brenden20 marked this conversation as resolved.
|
||
| assertDoesNotThrow(requestState::toString); | ||
| assertEquals(target, offsetFetchRequestState.toStringBase()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testPollSkipIfCoordinatorUnknown() { | ||
| CommitRequestManager commitRequestManager = create(false, 0); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.