Skip to content

fix(test): make the flaky e2e tests hermetic and condition-driven - #711

Merged
ajianaz merged 1 commit into
developfrom
fix/flaky-tests
Nov 14, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/flaky-tests

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

What

Fixes the flaky local tests in #702: agents::parent_spawns_child_polls_until_settled, compaction_e2e::doctor_warns_non_fatally_about_a_missing_window, the pid-named temp dir in config_apply, and hardens the waits of delegate::tests::an_independent_participant_is_a_consult_child_settled_with_its_report.

Why

Reproduced each on a clean develop under CPU load before changing anything.

  • parent_spawns_child_polls_until_settled failed 12 of 15 runs under load. The test ran against the real $HOME, so delegate went through the real machine guard: the machine-wide registry and 2 s spawn interval (any other tole on the machine queued the child) and the real load limit (queued: load 7.07 per CPU > 1.50). A queued agent_start result carries no agent id, so the content-driven mock replied with agent_start again until the loop guard stopped the run (exit 7).
  • doctor_warns_non_fatally_about_a_missing_window asserted that the whole doctor report has no ! line. The report also carries the delegation headroom (! load 2.06 per CPU (max 1.50), memory, disk), so any busy or nearly full machine failed it: 72 of 72 runs in parallel under load. Nothing to do with the window.
  • config_apply (and the other temp dirs touched here) were named after the pid plus a counter and never removed, so a reused pid found a stale trusted project or home from an earlier run.
  • The delegate test polled the child for 5 s. I could not reproduce that failure (see Testing); the bound was too tight for a loaded machine, so it is now 60 s of condition polling.

Changes

  • tests/agents.rs: each run gets its own CODECORA_HOME (outside the workspace) with a user config that opens the machine guard to its bounds. New tests: a_run_never_touches_the_machine_home (fails without the fix: a decoy HOME is populated with .codecora) and a_run_opens_the_machine_guard.
  • tests/compaction_e2e.rs: the window verdict is read from the context window line, and the test now also runs with a guard that always warns (min_free_disk_mb = 16 TiB) so the unrelated warning is certain. Temp dir names carry a clock stamp.
  • tests/config_apply.rs: temp dir names carry a clock stamp.
  • src/delegate_tests.rs: condition waits bounded at 60 s (were 5 s / 200 x 25 ms), the non-blocking checks at 30 s, and the shared data dir is unique per run.

Testing

  • Before: agents 12/15 failed under load, doctor_warns... 72/72 failed in parallel under load.
  • After: agents 0/48 failed with 12 parallel runs under the same load (load average above 15), doctor_warns... 0/72, config_apply 0/16.
  • cargo fmt, cargo clippy --workspace --all-targets --all-features -- -D warnings, cargo test --workspace (twice), cargo test -p tole-core --no-default-features: green.
  • Not reproduced, so unchanged: session_effort_e2e (flaky test: session_effort_e2e::a_rejecting_provider_still_answers_without_the_parameter (session lock still held by the test process) #646) and wire_size_missions (0 failures in 36 parallel runs each under load); the delegate test (0 failures in 40 runs at 64 threads, and 12 runs pinned to one CPU). No fixed ports, no sleeps and no shared names were found in the first two; the cause of the one-off failures is unknown.
  • The machine-guard queueing needs the real load average, which a test cannot raise on demand, so the regression for it is the check that the opened limits are what the binary applies plus the hermetic-home test.

Refs #702 (the not-reproduced tests stay open there).

The agents e2e queued its child behind the real machine guard (load,
spawn interval, shared registry); it now runs in its own home with the
guard opened. The doctor window test read an unrelated delegation
headroom warning as a window warning; it now reads the window line.
Temp dirs no longer reuse pid-named names, and delegate test waits are
bounded at 60 s instead of 5 s.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

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.

2 participants