mimaison commented on code in PR #15516:
URL: https://github.com/apache/kafka/pull/15516#discussion_r1605420401


##########
core/src/test/scala/unit/kafka/log/LogValidatorTest.scala:
##########
@@ -1538,7 +1563,80 @@ class LogValidatorTest {
     assertEquals(e.recordErrors.size, 3)
   }
 
-  private def testBatchWithoutRecordsNotAllowed(sourceCompression: 
CompressionType, targetCompression: CompressionType): Unit = {
+  @Test
+  def testDifferentLevelDoesNotCauseRecompression(): Unit = {
+    val records = List(
+      List.fill(256)("some").mkString("").getBytes,
+      List.fill(256)("data").mkString("").getBytes
+    )
+    // Records from the producer were created with gzip max level
+    val gzipMax: Compression = 
Compression.gzip().level(GzipCompression.MAX_LEVEL).build()
+    val recordsGzipMax = createRecords(records, RecordBatch.MAGIC_VALUE_V2, 
RecordBatch.NO_TIMESTAMP, gzipMax)
+
+    // The topic is configured with gzip min level
+    val gzipMin: Compression = 
Compression.gzip().level(GzipCompression.MIN_LEVEL).build()
+    val recordsGzipMin = createRecords(records, RecordBatch.MAGIC_VALUE_V2, 
RecordBatch.NO_TIMESTAMP, gzipMin)
+
+    // ensure data compressed with gzip max and min is different
+    assertNotEquals(recordsGzipMax, recordsGzipMin)
+    val validator = new LogValidator(recordsGzipMax,
+      topicPartition,
+      time,
+      gzipMax.`type`(),
+      gzipMin,
+      false,
+      RecordBatch.CURRENT_MAGIC_VALUE,

Review Comment:
   Yes, let's keep it consistent. Done



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to