niket-goel commented on code in PR #12457:
URL: https://github.com/apache/kafka/pull/12457#discussion_r937164272


##########
raft/src/test/java/org/apache/kafka/raft/internals/RecordsIteratorTest.java:
##########
@@ -85,18 +88,41 @@ public void testFileRecords(
         FileRecords fileRecords = FileRecords.open(TestUtils.tempFile());
         fileRecords.append(memRecords);
 
-        testIterator(batches, fileRecords);
+        testIterator(batches, fileRecords, true);
+    }
+
+    @Property
+    public void testCrcValidation(
+            @ForAll CompressionType compressionType,
+            @ForAll long seed
+    ) throws IOException {
+        List<TestBatch<String>> batches = createBatches(seed);
+        MemoryRecords memRecords = buildRecords(compressionType, batches);
+        // Corrupt the record buffer
+        
memRecords.buffer().putInt(DefaultRecordBatch.LAST_OFFSET_DELTA_OFFSET, new 
Random(seed).nextInt());

Review Comment:
   There is a non-zero probability that the test might fail due to the random 
int colliding with the actual value. Will modify the test to fix this.
   As for the field, it was one of the two exposed offsets that I could choose 
to corrupt. I am actually not happy about this either. I am going to expose the 
CRC_OFFSET as a public field and corrupt that instead. Should make for a more 
reliable test.



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