This is an automated email from the ASF dual-hosted git repository.
chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 047ae5c4c21 KAFKA-20281 Enhance helper message for producer-props and
command-property (#21688)
047ae5c4c21 is described below
commit 047ae5c4c21e14ba7d38832e0ea1ace5267593cc
Author: PoAn Yang <[email protected]>
AuthorDate: Wed Mar 11 02:28:00 2026 +0900
KAFKA-20281 Enhance helper message for producer-props and command-property
(#21688)
* Add helper message for `--producer-props` and `--command-property`.
* Add related test cases.
Reviewers: Ken Huang <[email protected]>, Nilesh Kumar
<[email protected]>, Chia-Ping Tsai <[email protected]>
---
.../org/apache/kafka/tools/ProducerPerformance.java | 4 ++--
.../apache/kafka/tools/ProducerPerformanceTest.java | 18 ++++++++++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git
a/tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java
b/tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java
index ac448f20957..4775e52812c 100644
--- a/tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java
+++ b/tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java
@@ -319,7 +319,7 @@ public class ProducerPerformance {
.dest("producerConfig")
.help("(DEPRECATED) Kafka producer related configuration
properties like client.id. " +
"These configs take precedence over those passed via
--command-config or --producer.config. " +
- "This option will be removed in a future version. Use
--command-property instead.");
+ "This option will be removed in a future version. Use
--command-property instead. Example: --command-property linger.ms=10
batch.size=32768");
parser.addArgument("--command-property")
.nargs("+")
@@ -328,7 +328,7 @@ public class ProducerPerformance {
.type(String.class)
.dest("commandProperties")
.help("Kafka producer related configuration properties like
client.id. " +
- "These configs take precedence over those passed via
--command-config or --producer.config.");
+ "These configs take precedence over those passed via
--command-config or --producer.config. Example: --command-property linger.ms=10
batch.size=32768");
parser.addArgument("--producer.config")
.action(store())
diff --git
a/tools/src/test/java/org/apache/kafka/tools/ProducerPerformanceTest.java
b/tools/src/test/java/org/apache/kafka/tools/ProducerPerformanceTest.java
index fa844dfbbe5..902de6ec740 100644
--- a/tools/src/test/java/org/apache/kafka/tools/ProducerPerformanceTest.java
+++ b/tools/src/test/java/org/apache/kafka/tools/ProducerPerformanceTest.java
@@ -27,6 +27,8 @@ import net.sourceforge.argparse4j.inf.ArgumentParserException;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.junit.jupiter.MockitoExtension;
@@ -774,4 +776,20 @@ public class ProducerPerformanceTest {
assertEquals(10, producerPerformanceSpy.stats.totalCount());
verify(producerMock, times(1)).close();
}
+
+ @ParameterizedTest
+ @ValueSource(strings = {"--command-property", "--producer-props"})
+ public void testMultipleProducerProperty(String configKey) throws
IOException, ArgumentParserException {
+ ArgumentParser parser = ProducerPerformance.argParser();
+ String[] args = new String[]{
+ "--topic", "Hello-Kafka",
+ "--num-records", "5",
+ "--throughput", "100",
+ "--record-size", "100",
+ "--bootstrap-server", "localhost:9000",
+ configKey, "linger.ms=10", "batch.size=32768"};
+ ProducerPerformance.ConfigPostProcessor configs = new
ProducerPerformance.ConfigPostProcessor(parser, args);
+ assertEquals("10",
configs.producerProps.get(ProducerConfig.LINGER_MS_CONFIG));
+ assertEquals("32768",
configs.producerProps.get(ProducerConfig.BATCH_SIZE_CONFIG));
+ }
}