@Test
    public void testConversion() throws IOException {
        doTestConversion(Compression.NONE, RecordBatch.MAGIC_VALUE_V0);
        doTestConversion(Compression.gzip().build(), RecordBatch.MAGIC_VALUE_V0);
        doTestConversion(Compression.NONE, RecordBatch.MAGIC_VALUE_V1);
        doTestConversion(Compression.gzip().build(), RecordBatch.MAGIC_VALUE_V1);
        doTestConversion(Compression.NONE, RecordBatch.MAGIC_VALUE_V2);
        doTestConversion(Compression.gzip().build(), RecordBatch.MAGIC_VALUE_V2);
    }
Test the new FileRecords with pre allocate as true and file has been clearly shut down, the file will be truncate to end of valid data.
clients/src/test/java/org/apache/kafka/common/record/FileRecordsTest.java