Commit Graph

600 Commits

Author SHA1 Message Date
Ken Huang ebae768bd8
KAFKA-18193 Refactor Kafka Streams CloseOptions to Fluent API Style (#19955)
In Kafka Streams, configuration classes typically follow a fluent API
pattern to ensure a consistent and intuitive developer experience.
However, the current implementation of
`org.apache.kafka.streams.KafkaStreams$CloseOptions` deviates from this
convention by exposing a public constructor, breaking the uniformity
expected across the API.

To address this inconsistency, we propose introducing a new
`CloseOptions` class that adheres to the fluent API style, replacing the
existing implementation. The new class will retain the existing
`timeout(Duration)` and `leaveGroup(boolean)` methods but will enforce
fluent instantiation and configuration. Given the design shift, we will
not maintain backward compatibility with the current class.

This change aligns with the goal of standardizing configuration objects
across Kafka Streams, offering developers a more cohesive and
predictable API.

Reviewers: Bill Bejeck<bbejeck@apache.org>
2025-10-07 08:50:18 -04:00
Lan Ding 60ad638a35
KAFKA-19617: ConsumerPerformance#ConsumerPerfRebListener get corrupted value when the number of partitions is increased (#20388)
With changes to the consumer protocol, rebalance may not necessarily
result in a "stop the world".  Thus, the method for calculating pause
time in `ConsumerPerformance#ConsumerPerfRebListener` needs to be
modified.

Stop time is only recorded if `assignedPartitions` is empty.

Reviewers: Andrew Schofield <aschofield@confluent.io>
2025-09-28 16:50:25 +01:00
Lan Ding ac63ce9789
KAFKA-19544 Improve `MetadataVersion.fromVersionString()` to take an enableUnstableFeature flag (#20248)
Improve `MetadataVersion.fromVersionString()` to take an
`enableUnstableFeature` flag,   and enable `FeatureCommand` and
`StorageTool` to leverage the exception message from
`fromVersionString`.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2025-09-25 01:06:54 +08:00
Shivsundar R 348e64c57d
MINOR: Add unit tests for verifying --formatter-property in console tools. (#20560)
*What*
In the implementation of KIP-1147 for console tools -

https://github.com/apache/kafka/pull/20479/files#diff-85b87c675a4b933e8e0e05c654d35d60e9cfd36cebe3331af825191b2cc688ee,
we missed adding unit tests for verifying the new
"`--formatter-property`" option.
Thanks to @Yunyung for pointing this out.

PR adds unit tests to both `ConsoleConsumerOptionsTest` and
`ConsoleShareConsumerOptionsTest` to verify the same.

Reviewers: Jhen-Yung Hsu <jhenyunghsu@gmail.com>, Chia-Ping Tsai
 <chia7712@gmail.com>
2025-09-25 00:15:05 +08:00
ally heev dbe9d34e47
KAFKA-19624: Improve consistency of command-line arguments for consumer performance tests (#20385)
resolves https://issues.apache.org/jira/browse/KAFKA-19624

Reviewers: @brandboat, @AndrewJSchofield, @m1a2st
2025-09-23 10:01:40 +01:00
Andrew Schofield 5ed4a48829
MINOR: Tighten up argument descriptions for console CLI tools (#20554)
Small improvements to the argument descriptions in the usage messages
for the console producer/consumer tools.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2025-09-19 10:10:12 +08:00
Shivsundar R 3bc50f937c
KAFKA-19623: Implement KIP-1147 for console producer/consumer/share-consumer. (#20479)
*What*
https://issues.apache.org/jira/browse/KAFKA-19623

- The PR implements KIP-1147

(https://cwiki.apache.org/confluence/display/KAFKA/KIP-1147%3A+Improve+consistency+of+command-line+arguments)
for the console tools i.e. `ConsoleProducer`, `ConsoleConsumer` and
`ConsoleShareConsumer`.

- Currently the previous names for the options are still usable but
there will be warning message stating those are deprecated and will be
removed in a future version.
- I have added unit tests and also manually verified using the console
tools that things are working as expected.

Reviewers: Andrew Schofield <aschofield@confluent.io>, Jhen-Yung Hsu
 <jhenyunghsu@gmail.com>, Jimmy Wang
 <48462172+JimmyWang6@users.noreply.github.com>
2025-09-17 15:28:20 +01:00
Lucas Brutschy 620a01b74b
KAFKA-19661 [4/N]: Prefer range-style assignment (#20486)
This is actually fixing a difference between the old and the new
assignor. Given the assignment ordering, the legacy assignor has a
preference for range-style assignments built in, that is, assigning

C1: 0_0, 1_0  C2: 0_1, 1_1

instead of

C1: 0_0, 0_1  C2: 1_0, 1_1

We add tests to both assignors to check for this behavior, and improve
the new assingor by enforcing corresponding orderings.

Reviewers: Bill Bejeck <bill@confluent.io>
2025-09-09 10:44:37 +02:00
Chang-Yu Huang d6688f869c
KAFKA-15983 Kafka-acls should return authorization already done if repeating work is issued (#20482)
# Description
`kafka-acls.sh` doesn't print message about duplicate authorization.

# Changes 
Now the cli searches for existing AclBinding, prints duplicate bindings,
and removes them from the adding list.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2025-09-07 06:22:02 +08:00
Ken Huang 0a12eaa80e
KAFKA-19112 Unifying LIST-Type Configuration Validation and Default Values (#20334)
We add the three main changes in this PR

- Disallowing null values for most LIST-type configurations makes sense,
since users cannot explicitly set a configuration to null in a
properties file. Therefore, only configurations with a default value of
null should be allowed to accept null.
- Disallowing duplicate values is reasonable, as there are currently no
known configurations in Kafka that require specifying the same value
multiple times. Allowing duplicates is both rare in practice and
potentially confusing to users.
- Disallowing empty list, even though many configurations currently
accept them. In practice, setting an empty list for several of these
configurations can lead to server startup failures or unexpected
behavior. Therefore, enforcing non-empty lists helps prevent
misconfiguration and improves system robustness.
These changes may introduce some backward incompatibility, but this
trade-off is justified by the significant improvements in safety,
consistency, and overall user experience.

Additionally, we introduce two minor adjustments:

- Reclassify some STRING-type configurations as LIST-type, particularly
those using comma-separated values to represent multiple entries. This
change reflects the actual semantics used in Kafka.
- Update the default values for some configurations to better align with
other configs.
These changes will not introduce any compatibility issues.

Reviewers: Jun Rao <junrao@gmail.com>, Chia-Ping Tsai
 <chia7712@gmail.com>
2025-09-06 01:25:55 +08:00
Levani Kokhreidze 548fb18099
MINOR: Fix typo for the headers.separator cli option (#20489)
Should be `headers.separator=<headers.separator>` instead of
`headers.separator=<line.separator>`

Reviewers: Kuan-Po Tseng <brandboat@gmail.com>, Ken Huang
 <s7133700@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-09-06 00:57:21 +08:00
Andrew Schofield 37e04eca81
KAFKA-19662: Allow resetting offset for unsubscribed topic in kafka-share-groups.sh (#20453)
The `kafka-share-groups.sh` tool checks whether a topic already has a
start-offset in the share group when resetting offsets. This is not
necessary. By removing the check, it is possible to set a start offset
for a topic which has not yet but will be subscribed in the future, thus
initialising the consumption point.

There is still a small piece of outstanding work to do with resetting
the offset for a non-existent group which should also create the group.
A subsequent PR will be used to address that.

Reviewers: Jimmy Wang <48462172+JimmyWang6@users.noreply.github.com>,
Lan Ding <isDing_L@163.com>, Apoorv Mittal <apoorvmittal10@gmail.com>
2025-09-04 18:46:12 +01:00
Andrew Schofield 1d0c5f2820
KAFKA-19667: Close ShareConsumer in ShareConsumerPerformance after metrics displayed (#20467)
Ensure that metrics are retrieved and displayed (when requested) before
ShareConsumer.close() is called. This is important because metrics are
technically supposed to be removed on ShareConsumer.close(), which means
retrieving them after close() would yield an empty map.

Related to https://github.com/apache/kafka/pull/20267.

Reviewers: Apoorv Mittal <apoorvmittal10@gmail.com>
2025-09-04 18:42:58 +01:00
jimmy 9257c431ed
MINOR: Fix failed e2e compatibility_test_new_broker_test and upgrade_test.py (#20471)
#20390 Replace the -`-producer.config` for the verifiable producer and
`--consumer.config` option by `--command-config` for the verifiable
consumer. However, for e2e tests targeting older broker versions, the
original configuration should still be used.

Fix the following tests:
`consumer_protocol_migration_test.py`、`compatibility_test_new_broker_test.py`
and `upgrade_test.py`.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Manikumar Reddy <manikumar.reddy@gmail.com>
2025-09-04 21:02:45 +05:30
Hong-Yi Chen 6a1cdf8262
MINOR: Refactor CLI tools to use CommandLineUtils#maybePrintHelpOrVersion (#20469)
Refactor help and version handling in command-line tools by replacing
duplicate code with `CommandLineUtils#maybePrintHelpOrVersion`.

Reviewers: TengYao Chi <kitingiao@gmail.com>, Ken Huang
 <s7133700@gmail.com>, Jhen-Yung Hsu <jhenyunghsu@gmail.com>, Chia-Ping
 Tsai <chia7712@gmail.com>
2025-09-04 21:43:17 +08:00
Nick Guo ef10a52a52
KAFKA-19011 Improve EndToEndLatency Tool with argument parser and message key/header support (#20301)
jira: https://issues.apache.org/jira/browse/KAFKA-19011  kip:

https://cwiki.apache.org/confluence/display/KAFKA/KIP-1172%3A+Improve+EndToEndLatency+tool

This PR improves the usability and maintainability of the
`kafka-e2e-latency.sh` tool:

- Replaces fixed-index argument parsing with a proper argument parser
(joptsimple)
- Adds support for configuring:
    - -record-key-size: size of the message key
    - -num-headers: number of headers per message
    - -record-header-key-size: size of each header key
    - -record-header-size: size of each header value
- Renames existing arguments to align with Kafka CLI conventions:
    - broker_list → bootstrap-server
    - num_messages → num-records
    - message_size_bytes → record-size
    - properties_file → command-config
    -

Reviewers: Jhen-Yung Hsu <jhenyunghsu@gmail.com>, Ken Huang
 <s7133700@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-09-04 02:29:53 +08:00
Andrew Schofield 4b9075b506
KAFKA-19653: Improve metavariable names in usage messages (#20438)
This trivial PR improves the so-called metavariable names in the usage
messages of the verifiable producer/consumer command-line tools. These
are the names of the replacement variables that appear solely in the
usage messages.

Verifiable producer (before):
```
usage: verifiable-producer [-h] --topic TOPIC
    [--max-messages MAX-MESSAGES] [--throughput THROUGHPUT]
    [--acks ACKS] [--producer.config CONFIG_FILE]
    [--message-create-time CREATETIME] [--value-prefix VALUE-PREFIX]
    [--repeating-keys REPEATING-KEYS] [--command-config CONFIG_FILE]
    --bootstrap-server HOST1:PORT1[,HOST2:PORT2[...]]
```

(after)
```
usage: verifiable-producer [-h] --topic TOPIC
    [--max-messages MAX-MESSAGES] [--throughput THROUGHPUT]
    [--acks ACKS] [--producer.config CONFIG-FILE]
    [--message-create-time CREATE-TIME] [--value-prefix VALUE-PREFIX]
    [--repeating-keys REPEATING-KEYS] [--command-config CONFIG-FILE]
    --bootstrap-server HOST1:PORT1[,HOST2:PORT2[...]]
```

Verifiable consumer (before):
```
usage: verifiable-consumer [-h] --topic TOPIC
    [--group-protocol GROUP_PROTOCOL]
    [--group-remote-assignor GROUP_REMOTE_ASSIGNOR]
    --group-id GROUP_ID
    [--group-instance-id GROUP_INSTANCE_ID]
    [--max-messages MAX-MESSAGES]
    [--session-timeout TIMEOUT_MS] [--verbose]
    [--enable-autocommit] [--reset-policy RESETPOLICY]
    [--assignment-strategy ASSIGNMENTSTRATEGY]
    [--consumer.config CONFIG_FILE] [--command-config CONFIG_FILE]
    --bootstrap-server HOST1:PORT1[,HOST2:PORT2[...]]
```

(after)
```
usage: verifiable-consumer [-h] --topic TOPIC
    [--group-protocol GROUP-PROTOCOL]
    [--group-remote-assignor GROUP-REMOTE-ASSIGNOR]
    --group-id GROUP-ID
    [--group-instance-id GROUP-INSTANCE-ID]
    [--max-messages MAX-MESSAGES]
    [--session-timeout TIMEOUT-MS] [--verbose]
    [--enable-autocommit] [--reset-policy RESET-POLICY]
    [--assignment-strategy ASSIGNMENT-STRATEGY]
    [--consumer.config CONFIG-FILE] [--command-config CONFIG-FILE]
    --bootstrap-server HOST1:PORT1[,HOST2:PORT2[...]]
```

Verifiable share consumer (before):
```
usage: verifiable-share-consumer
       [-h] --topic TOPIC --group-id GROUP_ID
       [--max-messages MAX-MESSAGES] [--verbose]
       [--acknowledgement-mode ACKNOWLEDGEMENTMODE]
       [--offset-reset-strategy OFFSETRESETSTRATEGY]
       [--command-config CONFIG_FILE]
       --bootstrap-server HOST1:PORT1[,HOST2:PORT2[...]]
```

(after):
```
usage: verifiable-share-consumer
       [-h] --topic TOPIC --group-id GROUP-ID
       [--max-messages MAX-MESSAGES] [--verbose]
       [--acknowledgement-mode ACKNOWLEDGEMENT-MODE]
       [--offset-reset-strategy OFFSET-RESET-STRATEGY]
       [--command-config CONFIG-FILE]
       --bootstrap-server HOST1:PORT1[,HOST2:PORT2[...]]
```

Reviewers: Kirk True <kirk@kirktrue.pro>, Ken Huang
 <s7133700@gmail.com>, Lianet Magrans <lmagrans@confluent.io>
2025-09-03 15:38:42 +01:00
Kirk True 4271fd8c8b
KAFKA-19564: Close Consumer in ConsumerPerformance only after metrics displayed (#20267)
Ensure that metrics are retrieved and displayed (when requested) before
`Consumer.close()` is called. This is important because metrics are
technically supposed to be removed on `Consumer.close()`, which means
retrieving them _after_ `close()` would yield an empty map.

Reviewers: Andrew Schofield <aschofield@confluent.io>
2025-09-03 09:25:21 +01:00
Yunchi Pang 5441f5e3e1
KAFKA-19616 Add compression type and level support to LogCompactionTester (#20396)
issue: [KAFKA-19616](https://issues.apache.org/jira/browse/KAFKA-19616)

**why**: validate log compaction works correctly with compressed data.
**what**: adds compression config options to `LogCompactionTester` tool
and extends test coverage to validate log compaction with different
compression types and levels.

Reviewers: TengYao Chi <kitingiao@gmail.com>, Chia-Ping Tsai
 <chia7712@gmail.com>
2025-08-30 10:21:22 +08:00
Jhen-Yung Hsu 65f789f560
KAFKA-19626: KIP-1147 Consistency of command-line arguments for remaining CLI tools (#20431)
This implements [KIP-1147](https://cwiki.apache.org/confluence/x/DguWF)
for kafka-cluster.sh, kafka-leader-election.sh and
kafka-streams-application-reset.sh.

Jira: https://issues.apache.org/jira/browse/KAFKA-19626

Reviewers: Andrew Schofield <aschofield@confluent.io>
2025-08-29 12:04:03 +01:00
jimmy a931f85835
KAFKA-19625: Consistency of command-line arguments for verifiable producer/consumer (#20390)
As described in
[jira](https://issues.apache.org/jira/browse/KAFKA-19625), this PR
implements replace `consumer.config` and `producer.config` with
`command-config` for kafka-verifiable-producer.sh and
kafka-verifiable-consumer.sh.

Reviewers: Andrew Schofield <aschofield@confluent.io>
2025-08-27 10:53:26 +01:00
Abhijeet Kumar 8d93d1096c
KAFKA-17108: Add EarliestPendingUpload offset spec in ListOffsets API (#16584)
This is the first part of the implementation of

[KIP-1023](https://cwiki.apache.org/confluence/display/KAFKA/KIP-1023%3A+Follower+fetch+from+tiered+offset)

The purpose of this pull request is for the broker to start returning
the correct offset when it receives a -6 as a timestamp in a ListOffsets
API request.

Added unit tests for the new timestamp.

Reviewers: Kamal Chandraprakash <kamal.chandraprakash@gmail.com>
2025-08-27 08:34:31 +05:30
jimmy d2f162a071
MINOR: kafka-stream-groups.sh should fail quickly if the partition leader is unavailable (#20271)
This PR applies the same partition leader check for `StreamsGroupCommand` as
`ShareGroupCommand`  and `ConsumerGroupCommand` to avoid the command
execution timeout.

Reviewers: Lucas Brutschy <lucasbru@apache.org>
2025-08-26 10:08:35 +02:00
Federico Valeri f97b95c60a
KAFKA-19498 Add include argument to ConsumerPerformance tool (#20221)
This patch adds the include argument to ConsumerPerformance tool.

ConsoleConsumer and ConsumerPerformance serve different purposes but
share common functionality for message consumption. Currently, there's
an inconsistency in their command-line interfaces:

- ConsoleConsumer supports an --include argument that allows users to
specify a regular expression pattern to filter topics for consumption
- ConsumerPerformance lacks this topic filtering capability, requiring
users to specify a single topic explicitly via --topic argument

This inconsistency creates two problems:

- Similar tools should provide similar topic selection capabilities for
better user experience
- Users cannot test consumer performance across multiple topics or
dynamically matching topic sets, making it difficult to test realistic
scenarios

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2025-08-25 04:15:37 +08:00
Yunchi Pang 511818e027
MINOR: Change LogCompactionTester topics parameter to Set<String> (#20372)
issue: https://github.com/apache/kafka/pull/19905#discussion_r2282202312

What: Change `String[] topics` to `Set<String> topics` throughout
`LogCompactionTester`. Why: `Set<String>` is more modern and reduces the
need for array-to-collection conversions.

Reviewers: Ken Huang  <s7133700@gmail.com>, TengYao Chi
 <kitingiao@gmail.com>, Jhen-Yung Hsu  <jhenyunghsu@gmail.com>, Lan Ding
 <isDing_L@163.com>, Kuan-Po Tseng  <brandboat@gmail.com>, Chia-Ping
 Tsai <chia7712@gmail.com>
2025-08-23 03:28:55 +08:00
Ken Huang 47bb46c10d
KAFKA-19582 the current assignments shown by ReassignPartitionsCommand should include the log directories (#20319)
The ReassignPartitionsCommand shows the topic replicas on each broker.
When using the --generate command, it returns the current partition
replica assignment. However, the log directory for each current replica
is always shown as any. This makes it impossible for users to determine
which specific log directory is being used by each replica. Therefore,
we should fix this behavior.

```
Current partition replica assignment
{
  "version": 1,
  "partitions": [
    {
      "topic": "test1",
      "partition": 0,
      "replicas": [
        4,
        2
      ],
      "log_dirs": [
        "any",
        "any"
      ]
    }
  ]
}
```

This PR
```
Current partition replica assignment
{
  "version": 1,
  "partitions": [
    {
      "topic": "test1",
      "partition": 0,
      "replicas": [
        4,
        2
      ],
      "log_dirs": [
        "/tmp/kraft-broker-logs234",
        "/tmp/kraft-broker-logs"
      ]
    }
  ]
}
```

Reviewers: PoAn Yang <payang@apache.org>, Jhen-Yung Hsu
 <jhenyunghsu@gmail.com>, TaiJuWu <tjwu1217@gmail.com>, Chia-Ping Tsai
 <chia7712@gmail.com>
2025-08-23 02:57:00 +08:00
Andrew Schofield c565ba1a04
KAFKA-19598: Command-line arguments for producer perf test (#20361)
This implements KIP-1147 for kafka-producer-perf-test.sh.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2025-08-23 01:14:14 +08:00
Sanskar Jhajharia 0da9cacffa
MINOR: Cleanups in Tools Module (3/n) (#20332)
This PR aims at cleaning up the tools module further by getting rid of
some extra code which can be replaced by `record`

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2025-08-19 22:24:13 +08:00
Yunchi Pang 4a5562c341
KAFKA-19306 Migrate LogCompactionTester to tools module (#19905)
jira: [KAFKA-19306](https://issues.apache.org/jira/browse/KAFKA-19306)

log
```
Producing 1000000 messages..to topics
log-cleaner-test-849894102467800668-0
Logging produce requests to
/tmp/kafka-log-cleaner-produced-6049271649847384547.txt
Sleeping for 20seconds...
Consuming messages...
Logging consumed messages to
/tmp/kafka-log-cleaner-consumed-7065252868189829937.txt
1000000 rows of data produced, 120176 rows of data consumed (88.0%
reduction).
De-duplicating and validating output files...
Validated 90057 values, 0 mismatches.
Data verification is completed
```
result
```
================================================================================
SESSION REPORT (ALL TESTS)
ducktape version: 0.12.0
session_id:       2025-07-10--001
run time:         1 minute 2.051 seconds
tests run:        1
passed:           1
flaky:            0
failed:           0
ignored:          0
================================================================================
test_id:
kafkatest.tests.tools.log_compaction_test.LogCompactionTest.test_log_compaction.metadata_quorum=ISOLATED_KRAFT
status:     PASS
run time:   1 minute 1.809 seconds
```

Reviewers: Jhen-Yung Hsu <jhenyunghsu@gmail.com>, Chia-Ping Tsai
 <chia7712@gmail.com>
2025-08-18 02:49:06 +08:00
Ming-Yen Chung c4fb1008c4
MINOR: Use lambda expressions instead of ImmutableValue for Gauges (#20351)
Refactor metric gauges instantiation to use lambda expressions instead
of ImmutableValue.

Reviewers: Ken Huang <s7133700@gmail.com>, TengYao Chi
 <kitingiao@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-08-14 20:35:21 +08:00
TaiJuWu 18045c6ac3
KAFKA-19592: testGenerateAssignmentWithBootstrapServer uses wrong JSON format (#20336)
This PR do following:
1. Use correct json format to test.
2. make `PartitionReassignmentState` and `VerifyAssignmentResult.java`
become record

Reviewers: TengYao Chi <frankvicky@apache.org>, Ken Huang
 <s7133700@gmail.com>, PoAn Yang <payang@apache.org>
2025-08-11 20:14:06 +08:00
Sanskar Jhajharia b9413ea4d6
MINOR: Cleanup Tools Module (2/n) (#20096)
Now that Kafka support Java 17, this PR makes some changes in tools
module. The changes in this PR are limited to only some files. A future
PR(s) shall follow. The changes mostly include:

- Collections.emptyList(), Collections.singletonList() and
Arrays.asList() are replaced with List.of()
- Collections.emptyMap() and Collections.singletonMap() are replaced
with Map.of()
- Collections.singleton() is replaced with Set.of()

Some minor changes to use the enhanced switch.

Sub modules targeted: tools/src/test

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2025-08-05 21:16:01 +08:00
Tsung-Han Ho (Miles Ho) 3f1d830174
MINOR: Remove duplicate renewTimePeriodOpt in DelegationTokenCommand validation (#20177)
The bug was a duplicate parameter validation in the
`DelegationTokenCommand` class.  The `checkInvalidArgs` method for the
`describeOpt` was incorrectly including `renewTimePeriodOpt` twice in
the set of invalid arguments.

This bug caused unexpected command errors during E2E testing.

### Before the fix:
The following command would fail due to the duplicate validation logic:
```
TC_PATHS="tests/kafkatest/tests/core/delegation_token_test.py::DelegationTokenTest"
/bin/bash tests/docker/run_tests.sh
```

### Error output:
```
ducktape.cluster.remoteaccount.RemoteCommandError: ducker@ducker03:
Command
'KAFKA_OPTS="-Djava.security.auth.login.config=/mnt/security/jaas.conf
-Djava.security.krb5.conf=/mnt/security/krb5.conf"
/opt/kafka-dev/bin/kafka-delegation-tokens.sh --bootstrap-server
ducker03:9094  --create  --max-life-time-period -1  --command-config
/mnt/kafka/client.properties > /mnt/kafka/delegation_token.out' returned
non-zero exit status 1. Remote error message: b'duplicate element:
[renew-time-period]\njava.lang.IllegalArgumentException: duplicate
element: [renew-time-period]\n\tat
java.base/java.util.ImmutableCollections$SetN.<init>(ImmutableCollections.java:918)\n\tat
java.base/java.util.Set.of(Set.java:544)\n\tat
org.apache.kafka.tools.DelegationTokenCommand$DelegationTokenCommandOptions.checkArgs(DelegationTokenCommand.java:304)\n\tat
org.apache.kafka.tools.DelegationTokenCommand.execute(DelegationTokenCommand.java:79)\n\tat
org.apache.kafka.tools.DelegationTokenCommand.mainNoExit(DelegationTokenCommand.java:57)\n\tat
org.apache.kafka.tools.DelegationTokenCommand.main(DelegationTokenCommand.java:52)\n\n'

[INFO:2025-07-31 11:27:25,531]: RunnerClient:
kafkatest.tests.core.delegation_token_test.DelegationTokenTest.test_delegation_token_lifecycle.metadata_quorum=ISOLATED_KRAFT:
Data: None
================================================================================
SESSION REPORT (ALL TESTS)
ducktape version: 0.12.0
session_id:       2025-07-31--002
run time:         33.213 seconds
tests run:        1
passed:           0
flaky:            0
failed:           1
ignored:          0
================================================================================
test_id:
kafkatest.tests.core.delegation_token_test.DelegationTokenTest.test_delegation_token_lifecycle.metadata_quorum=ISOLATED_KRAFT
status:     FAIL
run time:   33.090 seconds
```

### After the fix:
The same command now executes successfully:
```
TC_PATHS="tests/kafkatest/tests/core/delegation_token_test.py::DelegationTokenTest"
/bin/bash tests/docker/run_tests.sh
```

### Success output:
```
================================================================================
SESSION REPORT (ALL TESTS)
ducktape version: 0.12.0
session_id:       2025-07-31--001
run time:         35.488 seconds
tests run:        1
passed:           1
flaky:            0
failed:           0
ignored:          0
================================================================================
test_id:
kafkatest.tests.core.delegation_token_test.DelegationTokenTest.test_delegation_token_lifecycle.metadata_quorum=ISOLATED_KRAFT
status:     PASS
run time:   35.363 seconds
--------------------------------------------------------------------------------
```

Reviewers: Jhen-Yung Hsu <jhenyunghsu@gmail.com>, TengYao Chi
 <frankvicky@apache.org>, Ken Huang <s7133700@gmail.com>, PoAn Yang
 <payang@apache.org>, Chia-Ping Tsai <chia7712@gmail.com>
2025-08-03 16:40:18 +08:00
majialong 6b96735872
MINOR: Fix typo in GetOffsetShell (#20277)
Fix typo in GetOffsetShell : `visible for tseting` -> `Visible for
testing`

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
2025-08-01 00:48:31 +08:00
TaiJuWu dfaf9f9cf7
MINOR: add test for `kafka-consumer-groups.sh` should not fail when partition offline (#20235)
CI / build (push) Waiting to run Details
See: https://github.com/apache/kafka/pull/20168#discussion_r2227310093

add follow test case:

Given a topic with three partitions, where partition `t-2` is offline,
if partitionsToReset contains only `t-1`, the method
filterNoneLeaderPartitions incorrectly includes `t-2` in the result,
leading to a failure in the tool.

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Jhen-Yung Hsu
 <jhenyunghsu@gmail.com>, Ken Huang <s7133700@gmail.com>, Andrew
 Schofield <aschofield@confluent.io>
2025-07-31 15:54:27 +01:00
Sanskar Jhajharia c7caf912aa
KAFKA-19524 Fix UnsupportedOperationException in connect-plugin-path (#20222)
### Problem
The connect-plugin-path tool crashes with
`UnsupportedOperationException` when processing plugins that have
loadable classes but no ServiceLoader manifest files.

### Root Cause
Line 326 attempts to remove from an immutable `Collections.emptySet()`:
```java
nonLoadableManifests.getOrDefault(pluginDesc.className(),
Collections.emptySet()).remove(pluginDesc.type());
```

### Solution
Replace `Collections.emptySet()` with `new HashSet<>()` to provide a
mutable set.

Reviewers: Ken Huang <s7133700@gmail.com>, Chia-Ping Tsai
 <chia7712@gmail.com>
2025-07-31 20:37:35 +08:00
jimmy dd784e7d7a
KAFKA-16717 [3/N]: Add AdminClient.alterShareGroupOffsets (#19820)
[KAFKA-16717](https://issues.apache.org/jira/browse/KAFKA-16717) aims to
finish the AlterShareGroupOffsets for ShareGroupCommand part.

Reviewers: Lan Ding <isDing_L@163.com>, Chia-Ping Tsai
 <chia7712@gmail.com>, TaiJuWu <tjwu1217@gmail.com>, Andrew Schofield
 <aschofield@confluent.io>
2025-07-29 11:47:24 +01:00
Maros Orsak 8614e15a28
MINOR: typo in javadoc (#20113)
CI / build (push) Waiting to run Details
Fixup PR Labels / fixup-pr-labels (needs-attention) (push) Has been cancelled Details
Fixup PR Labels / fixup-pr-labels (triage) (push) Has been cancelled Details
Fixup PR Labels / needs-attention (push) Has been cancelled Details
This PR fixes a typo in the Javadoc.

---------

Signed-off-by: see-quick <maros.orsak159@gmail.com>

Reviewers: Luke Chen <showuon@gmail.com>
2025-07-24 19:05:07 +08:00
Matt Welch fba01c42c8
KAFKA-17645 Enable warmup in producer performance test (KIP-1052) (#17340)
CI / build (push) Waiting to run Details
In order to better analyze steady-state performance of Kafka, this PR
enables a warmup in the Producer Performance test. The warmup duration
is specified as a number of records that are a subset of the total
numRecords. If warmup records is greater than 0, the warmup is
represented by a second Stats object which holds warmup results. Once
warmup records have been exhausted, the test switches to using the
existing Stats object. At end of test, if warmup was enabled, the
summary of the whole test (warump + steady state) is printed followed by
the summary of the steady-state portion of the test.  If no warmup is
used, summary prints don't change from existing behavior. This
contribution is an original work and is licensed to the Kafka project
under the Apache license

Testing strategy comprises new Java unit tests added to
ProducerPerformanceTests.java.

Reviewers: Kirk True <kirk@kirktrue.pro>, Federico Valeri
 <fedevaleri@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-07-24 13:07:26 +08:00
Sanskar Jhajharia f1e9aa1c65
MINOR: Fix flaky tests in Tools modules (#20225)
### Problem
The
`ShareGroupCommandTest.testDeleteShareGroupOffsetsArgsWithoutTopic()`,
`ShareGroupCommandTest.testDeleteShareGroupOffsetsArgsWithoutGroup()`,
`ResetStreamsGroupOffsetTest.testResetOffsetsWithoutGroupOption()`,
`DeleteStreamsGroupTest.testDeleteWithoutGroupOption()`,
`DescribeStreamsGroupTest.testDescribeWithoutGroupOption()` tests were
flaky due to a dependency on Set iteration order in error message
generation.

### Root Cause
The cleanup [commit](https://github.com/apache/kafka/pull/20091) that
replaced `new HashSet<>(Arrays.asList(...))` with `Set.of(...)` in
ShareGroupCommandOptions and StreamsGroupCommandOptions changed the
iteration characteristics of collections used for error message
generation:

This produces different orders like `[topic], [group]` vs `[group],
[topic]`, but the tests expected a specific order, causing intermittent
failures.

### Solution
Fix the root cause by ensuring deterministic error message generation
through alphabetical sorting of option names.

Reviewers: ShivsundarR <shr@confluent.io>, Ken Huang
 <s7133700@gmail.com>, TengYao Chi <frankvicky@apache.org>
2025-07-23 14:40:18 +08:00
Lan Ding 7738db9b2d
KAFKA-19533: Correct the docs of 'messages' for `kafka-consumer-perf-test.sh` and `kafka-share-consumer-perf-test.sh (#20217)
The descrption "REQUIRED: The number of messages to send or consume" is
not correct, since those tools do NOT send any records.

Reviewers: TengYao Chi <frankvicky@apache.org>
2025-07-22 22:37:49 +08:00
Chang-Chi Hsu 8a5549ca9b
MINOR: Rename waitForTopic to waitTopicCreation (#20216)
Changes: Rename `waitForTopic` to `waitTopicCreation` for better clarity
Reasons: To align with `waitTopicDeletion`  Reference:
https://github.com/apache/kafka/pull/20108/files#r2221659660

Reviewers: Ken Huang <s7133700@gmail.com>, TengYao Chi
<frankvicky@apache.org>
2025-07-22 21:02:57 +08:00
Sanskar Jhajharia 5cf6a9d80d
MINOR: Cleanup Tools Module (1/n) (#20091)
Now that Kafka support Java 17, this PR makes some changes in tools
module. The changes in this PR are limited to only some files. A future
PR(s) shall follow.
The changes mostly include:
- Collections.emptyList(), Collections.singletonList() and
Arrays.asList() are replaced with List.of()
- Collections.emptyMap() and Collections.singletonMap() are replaced
with Map.of()
- Collections.singleton() is replaced with Set.of()

Sub modules targeted: tools/src/main

Reviewers: Ken Huang <s7133700@gmail.com>, Jhen-Yung Hsu
<jhenyunghsu@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-07-22 18:14:25 +08:00
xijiu f188a31124
KAFKA-19500: `kafka-consumer-groups.sh` should fail quickly if the partition leader is unavailable (#20168)
1. Add check leader missing logic in method
`ConsumerGroupCommand.ConsumerGroupService#prepareOffsetsToReset` in
order to fail quickly
2. Add some tests

Reviewers: TaiJuWu <tjwu1217@gmail.com>, Lan Ding <isDing_L@163.com>,
 Ken Huang <s7133700@gmail.com>, Andrew Schofield
 <aschofield@confluent.io>
2025-07-21 09:25:40 +01:00
lucliu1108 7ea32a0e93
KAFKA-19459: List internal topics for the user (#20157)
CI / build (push) Waiting to run Details
For the Kafka Stream group commands, if delete topic requests fail due
to version mismatch, user will have to remove the topics manually by
first retrieving the relevant internal topics.

To assist the user, the internal topic names are now included as part of
the error message, so that the user could delete the internal topics
associated with this application directly.

Reviewers: TengYao Chi <frankvicky@apache.org>, Alieh Saeedi
<asaeedi@confluent.io>
2025-07-15 11:52:35 +08:00
xijiu 873379873e
KAFKA-19435 Optimize `kafka-consumer-groups.sh` to return the offset info when some partitions without leaders (#20064)
1. Optimize the corresponding logic in the `ConsumerGroupCommand` by
first checking if a leader exists for the partition before invoking the
`admin.listOffsets`. Finally, concatenate the data and return
2. Add integration test, create a cluster with 3 brokers, then shutdown
a broker and observe whether the output meets the expectations

Reviewers: Ken Huang <s7133700@gmail.com>, PoAn Yang
 <payang@apache.org>, TaiJuWu <tjwu1217@gmail.com>, Chia-Ping Tsai
 <chia7712@gmail.com>
2025-07-14 22:13:01 +08:00
Alieh Saeedi c058c134d2
KAFKA-19496: Deflake streams admin api describe test (#20154)
This fixes the flaky

`DescribeStreamsGroupTest.testDescribeMultipleStreamsGroupWithMembersAndVerboseOptions()`,
which sometimes fails due to `ERROR stream-thread Missing source topics:
Source topics customInputTopic2 are missing`

Reviewers: Bill Bejeck <bbejeck@apache.org>
2025-07-11 15:48:24 +02:00
Xuan-Zhang Gong 2f6ea81d0a
KAFKA-19488: Update the docs of "if-not-exists" (#20133)
"the action will only execute" is incorrect, as the admin still sends
the request. The "if-not-exists" flag is actually used to swallow the
exception

Reviewers: TengYao Chi <frankvicky@apache.org>, Nick Guo
<lansg0504@gmail.com>, Ken Huang <s7133700@gmail.com>
2025-07-10 10:26:06 +08:00
Chang-Chi Hsu 22698493e9
MINOR: Move partitions == 0 logic from waitForTopic to waitTopicDeletion (#20108)
## Changes

- The partitions == 0 branch has been moved from **waitForTopic** to
**waitTopicDeletion**.

## Reasons

- Clarify the responsibility of each helper method makes the test code
easier to reason by moving the partitions == 0 logic from
**waitForTopic** into a dedicated method **waitTopicDeletion**.

Reviewers: Jhen-Yung Hsu <jhenyunghsu@gmail.com>, TaiJuWu
 <tjwu1217@gmail.com>, TengYao Chi <kitingiao@gmail.com>, Ken Huang
 <s7133700@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
2025-07-10 01:10:20 +08:00
Abhinav Dixit e489682c45
KAFKA-19450: ShareConsumerPerformance does not handle exceptions from consumeMessagesForSingleShareConsumer (#20126)
### About
Within `ShareConsumerPerformance.java`, all the share consumers run with
within an executorService object and when we
perform `executorService.submit()`, we do not store this future and
exception would be recovered only when we do a future.get() in this
case. I believe this is a shortcoming
in `ShareConsumerPerformance.java` which needs to be improved.

Reviewers: Andrew Schofield <aschofield@confluent.io>
2025-07-09 09:51:05 +01:00