This is an automated email from the ASF dual-hosted git repository.

davidarthur 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 ce152e7395b MINOR: Fix rare flaky behaviour in 
testPreferredReplicaElection (#20976)
ce152e7395b is described below

commit ce152e7395b520cfbe76ce944aa7920b61ae769e
Author: Mahsa Seifikar <[email protected]>
AuthorDate: Tue Nov 25 16:38:32 2025 -0500

    MINOR: Fix rare flaky behaviour in testPreferredReplicaElection (#20976)
    
    The `testPreferredReplicaElection` test shows rare flakiness by failing
    with this error `X replica(s) could not be elected`.
    This occurs because the test uses `--all-topic-partitions`, which
    attempts preferred leader election on all internal topics as well as the
    test topic which creates some timing issue. While the test waits for the
    test topic to join the ISR, it does not wait for all internal topics to
    synchronize their ISR membership after the broker restart. This fix
    modifies the test to target only the specific test topic partition
    rather than all partitions.
    
    Reviewers: Jonah Hooper <[email protected]>, kevin-wu24 
<[email protected]>, David Arthur <[email protected]>
---
 .../test/java/org/apache/kafka/tools/LeaderElectionCommandTest.java    | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/tools/src/test/java/org/apache/kafka/tools/LeaderElectionCommandTest.java 
b/tools/src/test/java/org/apache/kafka/tools/LeaderElectionCommandTest.java
index 8809e3ca174..7894e34d9fd 100644
--- a/tools/src/test/java/org/apache/kafka/tools/LeaderElectionCommandTest.java
+++ b/tools/src/test/java/org/apache/kafka/tools/LeaderElectionCommandTest.java
@@ -278,7 +278,8 @@ public class LeaderElectionCommandTest {
             assertEquals(0, LeaderElectionCommand.mainNoExit(
                     "--bootstrap-server", cluster.bootstrapServers(),
                     "--election-type", "preferred",
-                    "--all-topic-partitions"
+                    "--topic", topic,
+                    "--partition", Integer.toString(partition)
             ));
 
             TestUtils.assertLeader(client, topicPartition, broker2);

Reply via email to