@Test
    public void testIterateCompressedRecordWithWrapperOffsetZero() {
        for (byte magic : Arrays.asList(RecordBatch.MAGIC_VALUE_V0, RecordBatch.MAGIC_VALUE_V1)) {
            SimpleRecord[] simpleRecords = new SimpleRecord[] {
                new SimpleRecord(1L, "a".getBytes(), "1".getBytes()),
                new SimpleRecord(2L, "b".getBytes(), "2".getBytes()),
                new SimpleRecord(3L, "c".getBytes(), "3".getBytes())
            };

            MemoryRecords records = MemoryRecords.withRecords(magic, 0L,
                    Compression.gzip().build(), TimestampType.CREATE_TIME, simpleRecords);

            ByteBufferLegacyRecordBatch batch = new ByteBufferLegacyRecordBatch(records.buffer());
            batch.setLastOffset(0L);

            long offset = 0L;
            for (Record record : batch)
                assertEquals(offset++, record.offset());
        }
    }
The wrapper offset should be 0 in v0, but not in v1. However, the latter worked by accident and some versions of
librdkafka now depend on it. So we support 0 for compatibility reasons, but the recommendation is to set the
wrapper offset to the relative offset of the last record in the batch.
clients/src/test/java/org/apache/kafka/common/record/AbstractLegacyRecordBatchTest.java