Skip to content

Replace Thread.sleep with Wait.waitFor in FailoverClusterTest#1679

Open
jeanouii wants to merge 1 commit intoapache:mainfrom
jeanouii:fix/AutoFailoverClusterTest
Open

Replace Thread.sleep with Wait.waitFor in FailoverClusterTest#1679
jeanouii wants to merge 1 commit intoapache:mainfrom
jeanouii:fix/AutoFailoverClusterTest

Conversation

@jeanouii
Copy link
Contributor

Thread.sleep(3000) is unreliable on slow CI machines for waiting on cluster formation and client rebalancing. Replace all sleep-based synchronization with Wait.waitFor polling:

  • testClusterConnectedAfterClients: poll for clients on multiple brokers
  • testClusterURIOptionsStrip: same polling for client rebalance
  • testClusterConnectedBeforeClients: poll for bridge formation, then poll for client failover after broker stop

This also fixes AutoFailoverClusterTest which inherits these methods.

Thread.sleep(3000) is unreliable on slow CI machines for waiting on cluster formation and client rebalancing. Replace all sleep-based synchronization with Wait.waitFor polling:
- testClusterConnectedAfterClients: poll for clients on multiple brokers
- testClusterURIOptionsStrip: same polling for client rebalance
- testClusterConnectedBeforeClients: poll for bridge formation, then poll for client failover after broker stop

This also fixes AutoFailoverClusterTest which inherits these methods.
@rahul-chakradhari
Copy link

Hi @jeanouii,

I am an Outreachy applicant for the May 2026 cohort and a Java developer. I’ve been exploring the codebase and I see you are replacing Thread.sleep with Wait.waitFor in FailoverClusterTest.

Could you please guide me if I can take this up or if there’s a similar 'Good First Issue' I can start with? I'm eager to make my initial contributions!

@jeanouii
Copy link
Contributor Author

Hi,

First, thank you for showing up and be eager to help. I've started the same way, all of us pretty much.
The build stability is an issue, especially since we moved to Github Actions.

My usual approach is to monitor the builds (quick, nightly, or on-demand) on Github Actions and then create an issue to start investigating. Most of the time it's a race condition (Thread.sleep or similar). The test needs fixing. I've seen a few issues in the production code, but not much.

If you want to look at the test failures and send an email to dev@activemq.apache.org we can better guide you.
If you can't find test failures, I'm happy to take a first look and create the JIRA issues for you to dig in.

Let us know and welcome

@jbonofre
Copy link
Member

@rahul-chakradhari you can start by testing locally and identify flaky tests and fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants