Skip to content

test: deflake spawn/election assertions under parallel load - #103

Merged
OBenner merged 1 commit into
mainfrom
fix/13-deflake-election
Nov 17, 2026
Merged

OBenner merged 1 commit into
mainfrom
fix/13-deflake-election

Conversation

@OBenner

@OBenner OBenner commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Проблема

Flaky election-тесты под параллельной нагрузкой. Хронология по #13: relay-lifecycle «preserves the conversation and re-elects one owner» — 4 падения за 2026-11-16 (CI PR #87, #97, #98 attempt 1: таймаут 5s → факт 7994ms; + локальный прогон), supervisor-loop election — 2 падения.

Диагноз (по коду)

Прошлый дефлак поднял таймауты только в test/relay/supervisor-loop.test.ts. test/e2e/relay-lifecycle.test.ts остался на дефолтах: probeTimeoutMs: 100, election waitFor 5s и без describe/test timeout — дефолтный vitest 5s. Под 106+ параллельными воркерами spawn relay (SQLite open + HTTP listen + election) не укладывается в 5s → точное совпадение с CI-фактом «5s → 7994ms». supervisor-loop после поднятия до 20s всё ещё пробивался пиковой нагрузкой (наблюдавшийся прогон 23s).

Изменения (только test/, production-код и supervisor loop не тронуты)

  • relay-lifecycle.test.ts: describe timeout: 20_000, probeTimeoutMs: 100 → 1_000, election waitFor 5s → 10s — вровень с supervisor-loop.
  • supervisor-loop.test.ts: describe timeout: 20_000 → 30_000, election waitFor 10s → 15s.
  • Оба election-describe: retry: 1 — bounded retry из скоупа issue; afterEach закрывает supervisors и чистит temp-roots, повтор стартует с чистого листа.
  • codex-probe не тронут: 15s/20s deadlines уже в main.

Evidence по DoD

Closes #13.

relay-lifecycle e2e was left on vitest defaults when the supervisor-loop
deflake landed: probeTimeoutMs 100, election waitFor 5 s and no describe
timeout override — so the default 5 s test timeout killed it under
parallel-suite load (CI run 43907126160: timed out at 5 s, actual 7994 ms).
supervisor-loop still flaked twice after its bump (a 23 s run exceeded the
20 s describe budget).

- relay-lifecycle: describe timeout 20 s, probeTimeoutMs 1 s, election
  waitFor 10 s — level with supervisor-loop.
- supervisor-loop: describe timeout 30 s, election waitFor 15 s.
- Both election describes get retry: 1 as a bounded second chance for
  peak-load scheduling stalls; afterEach closes supervisors and removes
  temp roots, so a retried attempt starts clean.

Production code untouched; codex-probe already carries 15 s/20 s
deadlines. Evidence: 10 consecutive local pnpm verify runs green
(108 files / 949 tests each); CI evidence linked in #13 from this PR.
@OBenner

OBenner commented Nov 16, 2026

Copy link
Copy Markdown
Owner Author

Review (dev) — ACCEPT

Test-only, exactly the approved plan. The diagnosis holds: the previous deflake wave covered supervisor-loop (comment 6909810448) but left relay-lifecycle on defaults — vitest's 5 s default against an observed 7994 ms under full-suite load is precisely today's CI failure signature (run 43907126160).

  • relay-lifecycle: describe 20 s, probe 100 ms → 1 s, election wait 5 s → 10 s.
  • supervisor-loop: describe 20 s → 30 s, election wait 10 s → 15 s.
  • Both describes: retry: 1 — the bounded second chance sanctioned by the issue scope; afterEach teardown makes a retried attempt start clean. The visibility trade-off (a single peak-load stall becomes invisible in CI) is acknowledged and accepted.
  • No production code; codex-probe untouched (deadlines already landed earlier).

Verified independently: 4/4 on the two touched suites in a detached worktree; author's DoD evidence: 10 consecutive full pnpm verify runs green (108 files / 949 tests each). CI leg of the DoD to be appended to #13 when the runs finish.

closes #13. Passing to CTO for final.

@OBenner
OBenner merged commit 0d97b2e into main Nov 17, 2026
8 checks passed
@OBenner
OBenner deleted the fix/13-deflake-election branch November 17, 2026 02:45
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.

[P3] Flaky spawn tests under load in verify chain/CI

1 participant