ahuang98 commented on code in PR #21028:
URL: https://github.com/apache/kafka/pull/21028#discussion_r2709840461


##########
raft/src/test/java/org/apache/kafka/raft/internals/KafkaRaftLogTest.java:
##########
@@ -1083,6 +1086,70 @@ public void testSegmentsLessThanLatestSnapshot() throws 
IOException {
         );
     }
 
+    @Test
+    public void testReadOfDefaultLogValue() throws IOException {
+        MetadataLogConfig config = createMetadataLogConfig(
+                10240,
+                10 * 1000,
+                10240,
+                60 * 1000,
+                128,
+                1
+        );
+        KafkaRaftLog log = buildMetadataLog(tempDir, mockTime, config);
+        // Append twice to ensure we have two batches.
+        append(log, 1, 1);
+        append(log, 2, 1);
+
+        // If the default configured value of 1 is used we will read a single 
record.
+        LogFetchInfo info = log.read(0, Isolation.UNCOMMITTED);
+
+        // Exactly 1 batch of records will be read. Since there are 2 batches, 
with the first batch having 1 record
+        // only 1 record should be returned.
+        assertRecords(info, 1, 1);
+    }
+
+    @Test
+    public void testNonDefaultReadFromLog() throws IOException {
+        int batchSizeBytes = 1024;
+        int maxSizeToReadBytes = 1;
+        MetadataLogConfig config = createMetadataLogConfig(
+                10240,
+                10 * 1000,
+                10240,
+                60 * 1000,
+                batchSizeBytes,
+                maxSizeToReadBytes
+        );
+        KafkaRaftLog log = buildMetadataLog(tempDir, mockTime, config);
+        int recordsPerBatch = 5;
+        append(log, recordsPerBatch, 1);
+        append(log, recordsPerBatch, 1);
+
+        // Default value of 1 is NOT used in this case.
+        LogFetchInfo info = log.read(0,
+                Isolation.UNCOMMITTED,
+                batchSizeBytes * 3);
+
+        assertRecords(info, recordsPerBatch * 2, recordsPerBatch);
+    }
+
+    private static void assertRecords(LogFetchInfo info, int numberExpected, 
int recordsPerBatch) {

Review Comment:
   I was actually just hoping for a code comment for readers to understand 
quickly what validation this does (sorry, was being imprecise asking for 
javadoc)



-- 
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]

Reply via email to