Skip to content

Fix flaky test by relying on fake clock#2157

Open
pquentin wants to merge 3 commits into
elastic:masterfrom
pquentin:fix-async-executor-clock
Open

Fix flaky test by relying on fake clock#2157
pquentin wants to merge 3 commits into
elastic:masterfrom
pquentin:fix-async-executor-clock

Conversation

@pquentin

@pquentin pquentin commented Jul 3, 2026

Copy link
Copy Markdown
Member

For a target throughput of 1000 ops/s and 4 clients, we need 250 ops/s per client, which is one operation every ~4ms. On macOS, the CI overhead is large enough that we sometimes only get 107 operations, roughly one every ~9ms. This happened at least twice today:

Instead of relying on wall-clock time and actually sleeping, we can patch the driver's time functions to observe the sleep calls. It's both fast and precise, at the cost of some monkeypatching.

@pquentin pquentin added the :internal Changes for internal, undocumented features: e.g. experimental, release scripts label Jul 3, 2026
Copilot AI review requested due to automatic review settings July 3, 2026 13:54
@pquentin pquentin requested a review from a team as a code owner July 3, 2026 13:54
@pquentin pquentin added the :ci Everything related to CI label Jul 3, 2026
@pquentin pquentin requested review from gbanasiak and stevereads-elastic and removed request for a team July 3, 2026 13:54
@pquentin pquentin requested review from a team, b-deam, inqueue and stevereads-elastic and removed request for a team, b-deam, gbanasiak, inqueue and stevereads-elastic July 3, 2026 13:57
@pquentin

pquentin commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Sorry for the multiple review requests; I was testing to check that GitHub respected the "Busy" status.

Copilot AI 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.

Pull request overview

This PR stabilizes a flaky throughput-throttling unit test by replacing real wall-clock timing and actual sleeps with a virtual clock that deterministically advances time and records sleep intervals, making the test fast and CI-robust across slower environments (notably macOS).

Changes:

  • Added a VirtualClock and VirtualRequestTiming test helper to control time progression and observe sleep behavior.
  • Updated test_execute_schedule_throughput_throttled to monkeypatch driver timing/sleep functions and assert deterministic sample counts and throttling behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/driver/driver_test.py
Comment thread tests/driver/driver_test.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:ci Everything related to CI :internal Changes for internal, undocumented features: e.g. experimental, release scripts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants