Skip to content

KAFKA-18105 Fix flaky PlaintextAdminIntegrationTest#testElectPreferredLeaders #20068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We���ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

jim0987795064
Copy link
Contributor

@jim0987795064 jim0987795064 commented Jun 30, 2025

Changes

This PR improves the stability of the
PlaintextAdminIntegrationTest.testElectPreferredLeaders test by
introducing short Thread.sleep( ) delays before invoking:

  • changePreferredLeader( )

  • waitForBrokersOutOfIsr( )

Reasons

  • Metadata propagation for partition2 :
    Kafka requires time to propagate the updated leader metadata across all
    brokers. Without waiting, metadataCache may return outdated leader
    information for partition2.

  • Eviction of broker1 from the ISR :
    To simulate a scenario where broker1 is no longer eligible as leader,
    the test relies on broker1 being removed from the ISR (e.g., due to
    intentional shutdown). This eviction is not instantaneous and requires a
    brief delay before Kafka reflects the change.

@github-actions github-actions bot added triage PRs from the community core Kafka Broker tests Test fixes (including flaky tests) small Small PRs labels Jun 30, 2025
@@ -2909,6 +2909,7 @@ class PlaintextAdminIntegrationTest extends BaseAdminIntegrationTest {
TestUtils.assertLeader(client, partition2, 0)

// Now change the preferred leader to 1
Thread.sleep(1000)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please use "wait for condition" instead of time-based waiting?

@github-actions github-actions bot removed the triage PRs from the community label Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-approved core Kafka Broker small Small PRs tests Test fixes (including flaky tests)
3 participants