apoorvmittal10 commented on code in PR #18804:
URL: https://github.com/apache/kafka/pull/18804#discussion_r1945592660
##########
core/src/test/java/kafka/server/share/SharePartitionTest.java:
##########
@@ -1186,6 +1185,50 @@ public void
testAcquireWithMultipleBatchesAndMaxFetchRecords() {
assertNull(sharePartition.cachedState().get(10L).offsetState());
}
+ @Test
+ public void testAcquireMultipleRecordsWithOverlapAndMaxFetchRecords() {
+ SharePartition sharePartition =
SharePartitionBuilder.builder().withState(SharePartitionState.ACTIVE).build();
+ MemoryRecords records = memoryRecords(5, 0);
+ // Acquire 5 records.
+ fetchAcquiredRecords(sharePartition.acquire(
+ MEMBER_ID,
+ BATCH_SIZE,
+ 2,
+ new FetchPartitionData(Errors.NONE, 20, 3, records,
+ Optional.empty(), OptionalLong.empty(), Optional.empty(),
OptionalInt.empty(), false)),
+ 5);
+
+ records = memoryRecords(5, 5);
+ // Acquire another 5 records.
+ fetchAcquiredRecords(sharePartition.acquire(
+ MEMBER_ID,
+ BATCH_SIZE,
+ 2,
+ new FetchPartitionData(Errors.NONE, 20, 3, records,
+ Optional.empty(), OptionalLong.empty(), Optional.empty(),
OptionalInt.empty(), false)),
+ 5);
+ // Release the acquired records so they can be re-acquired and max
fetch records can be tested
+ // for overlapping records.
+ sharePartition.releaseAcquiredRecords(MEMBER_ID);
+ // Add batches from 0-9 offsets and 10-12, 5-9 should be acquired and
0-4 should be ignored.
+ // 10-12 should be ignored as it exceeds the max fetch records.
Review Comment:
My bad, I was trying multipe scenarios and wrote the intial comments. But
later changed the test but didn't update the comment. Yes you are right, the
comment here is incorrect. I have corrected it now. Thanks for the catch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]