muralibasani commented on code in PR #23813:
URL: https://github.com/apache/kafka/pull/23813#discussion_r4275444781


##########
tools/src/test/java/org/apache/kafka/tools/ConsoleProducerTest.java:
##########
@@ -388,6 +388,59 @@ public void testCommandPropertyOverridesConfig() throws 
IOException {
         assertEquals(16384, 
producerConfig.getInt(ProducerConfig.BATCH_SIZE_CONFIG));
     }
 
+    @Test
+    public void testDefaultCompressionType() throws IOException {
+        ConsoleProducerOptions opts = new 
ConsoleProducerOptions(BOOTSTRAP_SERVER_VALID_ARGS);
+        ProducerConfig producerConfig = new 
ProducerConfig(opts.producerProps());
+
+        assertEquals("none", 
producerConfig.getString(ProducerConfig.COMPRESSION_TYPE_CONFIG));
+    }
+
+    @Test
+    public void testCompressionTypeFromCommandProperty() throws IOException {
+        String[] args = new String[]{
+            "--bootstrap-server", "localhost:9092",
+            "--topic", "test",
+            "--command-property", "compression.type=zstd"
+        };
+
+        ConsoleProducerOptions opts = new ConsoleProducerOptions(args);
+        ProducerConfig producerConfig = new 
ProducerConfig(opts.producerProps());
+
+        assertEquals("zstd", 
producerConfig.getString(ProducerConfig.COMPRESSION_TYPE_CONFIG));
+    }
+
+    @Test
+    public void testCompressionTypeFromCommandConfig() throws IOException {
+        File propsFile = 
ToolsTestUtils.tempPropertiesFile(Map.of("compression.type", "lz4"));
+
+        String[] args = new String[]{
+            "--bootstrap-server", "localhost:9092",
+            "--topic", "test",
+            "--command-config", propsFile.getAbsolutePath()
+        };
+
+        ConsoleProducerOptions opts = new ConsoleProducerOptions(args);
+        ProducerConfig producerConfig = new 
ProducerConfig(opts.producerProps());
+
+        assertEquals("lz4", 
producerConfig.getString(ProducerConfig.COMPRESSION_TYPE_CONFIG));
+    }
+
+    @Test
+    public void testCompressionCodecOverridesCommandProperty() throws 
IOException {
+        String[] args = new String[]{
+            "--bootstrap-server", "localhost:9092",
+            "--topic", "test",
+            "--command-property", "compression.type=zstd",
+            "--compression-codec", "lz4"
+        };
+
+        ConsoleProducerOptions opts = new ConsoleProducerOptions(args);
+        ProducerConfig producerConfig = new 
ProducerConfig(opts.producerProps());
+
+        assertEquals("lz4", 
producerConfig.getString(ProducerConfig.COMPRESSION_TYPE_CONFIG));
+    }
+

Review Comment:
   In general more tests are needed for ex a bare --compression-codec (no 
value).
   and the deprecated --producer-property and --producer.config paths 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to