8000 test: make the automation clock tests deterministic by aorumbayev · Pull Request #149 · kagan-sh/kagan · GitHub
[go: up one dir, main page]

Skip to content

test: make the automation clock tests deterministic - #149

Merged
aorumbayev merged 1 commit into
mainfrom
fix/flaky-automation-clock
Nov 12, 2026
Merged

aorumbayev merged 1 commit into
mainfrom
fix/flaky-automation-clock

Conversation

@aorumbayev
@aorumbayev aorumbayev commented Nov 12, 2026 •
Copy link
Copy Markdown
Member

Cause

One-time automation test. The core's clock is the wall time read when the workspace opens, plus the test executor's elapsed time. The test compared the due time to wall time read around the click. Any real gap between opening and clicking pushed the due time below the lower bound. CI run 43202985106 (Linux): due at 1794481025314, expected one minute after 1794480966747..1794480967205.

Failed-runs test. It waited a fixed 20 steps of fake time for the pause. The pause write runs on a real thread, so the fixed count did not wait for it.

Fix

  • Workspace::clock_now is the one clock. time() uses it, and the test reads it before and after the click. The widened 59 000 ms bound is gone.
  • The pause test waits for the AutomationPaused event through pause_heard. It polls with a short real sleep, up to 200 times, and stops as soon as the event arrives.

Proof

  • Forced a real 1.5 s pause after the workspace opens. The old assertion failed every time (due at 1794521547498, expected one minute after 1794521489201..1794521489237). The new one passes with the same pause.
  • Ran each test 30 times on macOS: once-in 30/30, failed-runs 30/30.
  • cargo fmt --check, cargo clippy --workspace --all-targets --locked -- -D warnings, and scripts/size-budget.sh (83238 of 83244) all pass.

Not proven

  • The macOS 19.8 s failure of the failed-runs test did not reproduce. The old version passed 15/15 with the CPU loaded. The run-level wait (runs_with_status) uses real child processes and the 500 ms drain, and this PR does not change it. If it flakes again, look there first.

The core clock is the wall time read when the workspace opens, moved on
by the executor's elapsed time. The one-time automation test compared the
due time to wall time read around the click, so any real gap between the
workspace opening and the click made it fail. The test now reads the same
clock through Workspace::clock_now, so the window matches what the core
used.

The three-failed-runs test waited a fixed 20 steps for the pause. It now
polls for the AutomationPaused event, up to 200 steps, and stops as soon
as the event arrives.
@aorumbayev
aorumbayev merged commit 38959c8 into main Nov 12, 2026
21 checks passed
@aorumbayev
aorumbayev deleted the fix/flaky-automation-clock branch November 12, 2026 22:38
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.

1 participant

0