diff --git a/core/src/test/scala/unit/kafka/log/LogValidatorTest.scala b/core/src/test/scala/unit/kafka/log/LogValidatorTest.scala index ee1b896e7afae..0462fb86753d7 100644 --- a/core/src/test/scala/unit/kafka/log/LogValidatorTest.scala +++ b/core/src/test/scala/unit/kafka/log/LogValidatorTest.scala @@ -452,12 +452,15 @@ class LogValidatorTest { (RecordBatch.NO_PRODUCER_ID, RecordBatch.NO_PRODUCER_EPOCH, RecordBatch.NO_SEQUENCE, false, RecordBatch.NO_PARTITION_LEADER_EPOCH) - val records = MemoryRecords.withRecords(magic, 0L, CompressionType.GZIP, TimestampType.CREATE_TIME, producerId, + val records = MemoryRecords.withRecords(magic, 0L, CompressionType.NONE, TimestampType.CREATE_TIME, producerId, producerEpoch, baseSequence, partitionLeaderEpoch, isTransactional, new SimpleRecord(timestampSeq(0), "hello".getBytes), new SimpleRecord(timestampSeq(1), "there".getBytes), new SimpleRecord(timestampSeq(2), "beautiful".getBytes)) + // V2 has single batch, and other versions has many single-record batches + assertEquals(if (magic >= RecordBatch.MAGIC_VALUE_V2) 1 else 3, records.batches().asScala.size) + val validatingResults = new LogValidator(records, topicPartition, time, @@ -497,9 +500,9 @@ class LogValidatorTest { assertEquals(now + 1, validatingResults.maxTimestampMs, s"Max timestamp should be ${now + 1}") - // Both V2 and V1 has single branch in the record when compression is enable, and hence their shallow OffsetOfMaxTimestamp - // is the last offset of the single branch - assertEquals(1, records.batches().asScala.size) + // Both V2 and V1 has single batch in the validated records when compression is enable, and hence their shallow + // OffsetOfMaxTimestamp is the last offset of the single batch + assertEquals(1, validatedRecords.batches().asScala.size) assertEquals(2, validatingResults.shallowOffsetOfMaxTimestamp) assertTrue(validatingResults.messageSizeMaybeChanged, "Message size should have been changed")