Skip to content

fix: flaky Consul embedded test startup#19564

Merged
abhishekrb19 merged 3 commits into
apache:masterfrom
Shekharrajak:fix/19563-consul-startup-flake
Jun 11, 2026
Merged

fix: flaky Consul embedded test startup#19564
abhishekrb19 merged 3 commits into
apache:masterfrom
Shekharrajak:fix/19563-consul-startup-flake

Conversation

@Shekharrajak

@Shekharrajak Shekharrajak commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #19563.

Description

This PR hardens the Consul-backed embedded tests against startup races where the Consul container has started but the host-mapped Consul API is not yet reliably accepting requests.

Readiness hardening:
reduce chance of starting Druid before Consul is usable

Announce retry:
tolerate a remaining transient HTTP race if it still happens

Release note

Druid's Consul service discovery announcer now retries transient HTTP registration failures during startup.

Key changed/added classes in this PR
  • embedded-tests/src/test/java/org/apache/druid/testing/embedded/consul/ConsulClusterResource.java
  • extensions-contrib/consul-extensions/src/main/java/org/apache/druid/consul/discovery/ConsulDruidNodeAnnouncer.java
  • extensions-contrib/consul-extensions/src/test/java/org/apache/druid/consul/discovery/ConsulDruidNodeAnnouncerTest.java

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@Shekharrajak Shekharrajak changed the title Fix flaky Consul embedded test startup fix: flaky Consul embedded test startup Jun 6, 2026
lastException = e;
}

try {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

means:

Consul is not ready yet.
Wait 500 ms.
Try again.

}
}

throw new RuntimeException(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

out side the while loop .

we kept retrying until READINESS_TIMEOUT expired
and Consul never became ready

}
}

private void waitForConsulApi()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

try /v1/status/leader
if ready -> return
if not ready -> sleep 500 ms
if sleep is interrupted -> restore interrupt flag and fail
otherwise -> retry until 30 seconds deadline

@Shekharrajak

Copy link
Copy Markdown
Contributor Author

@jtuglu1 @FrankChen021 - please have a look.

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Severity Findings
P0 0
P1 0
P2 1
P3 0
Total 1

Reviewed 3 of 3 changed files.


This is an automated review by Codex GPT-5.5

@Shekharrajak

Shekharrajak commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Thanks , looks good to merge. This will unblock : #19510

@abhishekrb19 abhishekrb19 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lgtm, thanks for the fix @Shekharrajak. Saw this test flake in https://github.com/apache/druid/actions/runs/27331948177/job/80830684837 as well.

@abhishekrb19 abhishekrb19 merged commit 80d7700 into apache:master Jun 11, 2026
38 checks passed
@github-actions github-actions Bot added this to the 38.0.0 milestone Jun 11, 2026
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.

Flaky Test: ConsulDruidNodeAnnouncerTest

3 participants