@Test
    public void testZStdCompressionTypeWithV0OrV1() {
        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())
        };

        // Check V0
        try {
            MemoryRecords records = MemoryRecords.withRecords(RecordBatch.MAGIC_VALUE_V0, 0L,
                Compression.zstd().build(), TimestampType.CREATE_TIME, simpleRecords);

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

            batch.iterator();
            fail("Can't reach here");
        } catch (IllegalArgumentException e) {
            assertEquals("ZStandard compression is not supported for magic 0", e.getMessage());
        }

        // Check V1
        try {
            MemoryRecords records = MemoryRecords.withRecords(RecordBatch.MAGIC_VALUE_V1, 0L,
                Compression.zstd().build(), TimestampType.CREATE_TIME, simpleRecords);

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

            batch.iterator();
            fail("Can't reach here");
        } catch (IllegalArgumentException e) {
            assertEquals("ZStandard compression is not supported for magic 1", e.getMessage());
        }
    }
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