-
Notifications
You must be signed in to change notification settings - Fork 15.1k
KAFKA-10669: Make CurrentLeaderEpoch field ignorable and set MaxNumOffsets field default to 1 #9540
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 all commits
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 |
|---|---|---|
|
|
@@ -143,7 +143,13 @@ class ListOffsetsRequestTest extends BaseRequestTest { | |
| val partitionData = response.topics.asScala.find(_.name == topic).get | ||
| .partitions.asScala.find(_.partitionIndex == partition.partition).get | ||
|
|
||
| (partitionData.offset, partitionData.leaderEpoch) | ||
| if (version == 0) { | ||
| if (partitionData.oldStyleOffsets().isEmpty) | ||
| (-1, partitionData.leaderEpoch) | ||
| else | ||
| (partitionData.oldStyleOffsets().asScala.head, partitionData.leaderEpoch) | ||
|
Comment on lines
+147
to
+150
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. nit: We could use
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.
|
||
| } else | ||
| (partitionData.offset, partitionData.leaderEpoch) | ||
| } | ||
|
|
||
| @Test | ||
|
|
@@ -174,17 +180,27 @@ class ListOffsetsRequestTest extends BaseRequestTest { | |
| } | ||
|
|
||
| @Test | ||
| def testResponseDefaultOffsetAndLeaderEpochForLowerVersions(): Unit = { | ||
| def testResponseDefaultOffsetAndLeaderEpochForAllVersions(): Unit = { | ||
| val partitionToLeader = TestUtils.createTopic(zkClient, topic, numPartitions = 1, replicationFactor = 3, servers) | ||
| val firstLeaderId = partitionToLeader(partition.partition) | ||
|
|
||
| TestUtils.generateAndProduceMessages(servers, topic, 10) | ||
|
|
||
| assertEquals((-1L, -1), fetchOffsetAndEpoch(firstLeaderId, 0L, 0)) | ||
| assertEquals((0L, -1), fetchOffsetAndEpoch(firstLeaderId, 0L, 1)) | ||
| assertEquals((0L, -1), fetchOffsetAndEpoch(firstLeaderId, 0L, 2)) | ||
| assertEquals((0L, -1), fetchOffsetAndEpoch(firstLeaderId, 0L, 3)) | ||
| assertEquals((0L, 0), fetchOffsetAndEpoch(firstLeaderId, 0L, 4)) | ||
| for (version <- ApiKeys.LIST_OFFSETS.oldestVersion to ApiKeys.LIST_OFFSETS.latestVersion) { | ||
|
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. nit: Now that we test all versions, could we rename to test to |
||
| if (version == 0) { | ||
| assertEquals((-1L, -1), fetchOffsetAndEpoch(firstLeaderId, 0L, version.toShort)) | ||
| assertEquals((0L, -1), fetchOffsetAndEpoch(firstLeaderId, ListOffsetRequest.EARLIEST_TIMESTAMP, version.toShort)) | ||
| assertEquals((10L, -1), fetchOffsetAndEpoch(firstLeaderId, ListOffsetRequest.LATEST_TIMESTAMP, version.toShort)) | ||
| } else if (version >= 1 && version <= 3) { | ||
| assertEquals((0L, -1), fetchOffsetAndEpoch(firstLeaderId, 0L, version.toShort)) | ||
| assertEquals((0L, -1), fetchOffsetAndEpoch(firstLeaderId, ListOffsetRequest.EARLIEST_TIMESTAMP, version.toShort)) | ||
| assertEquals((10L, -1), fetchOffsetAndEpoch(firstLeaderId, ListOffsetRequest.LATEST_TIMESTAMP, version.toShort)) | ||
| } else if (version >= 4) { | ||
| assertEquals((0L, 0), fetchOffsetAndEpoch(firstLeaderId, 0L, version.toShort)) | ||
| assertEquals((0L, 0), fetchOffsetAndEpoch(firstLeaderId, ListOffsetRequest.EARLIEST_TIMESTAMP, version.toShort)) | ||
| assertEquals((10L, 0), fetchOffsetAndEpoch(firstLeaderId, ListOffsetRequest.LATEST_TIMESTAMP, version.toShort)) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private def assertResponseError(error: Errors, brokerId: Int, request: ListOffsetRequest): Unit = { | ||
|
|
||
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 suggest to set current leader epoch for all the versions as we have made it ignorable. We set it all the time in the replica fetcher so the test would be aligned with what we do.