Skip to content

test: fix two timing flakes in the keys proxy tests - #1795

Merged
askalf merged 3 commits into
masterfrom
test/budget-burst-gate
Nov 2, 2026
Merged

askalf merged 3 commits into
masterfrom
test/budget-burst-gate

Conversation

@askalf

@askalf askalf commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Fixes an intermittent failure in test/keys-budget-proxy.mjs (the burst checks for dan, erin and gina).

Each admitted burst request was held at the stub for a fixed 400 ms so the burst overlapped at the budget check. On a loaded runner a burst request could reach that check after an admitted one had already completed, so it saw completed use instead of a reservation and the admitted count came out different from the expected one.

What changes:

  • A burstOf(n, want, send) helper fires the burst and holds the admitted requests at the stub until all n - want refusals have come back. Every request is then decided while the admitted ones are still in flight, however slowly the runner delivers them.
  • The expected count is computed before the burst fires, since the helper needs it.
  • A 10 s timer releases the hold if the count is already wrong, so the check fails with the real statuses instead of hanging.

No product code changes. Ran the file three times locally: 53 passed, 0 failed each run.

Second fix, in test/keys-proxy.mjs: the proxy's presence heartbeat goes through the stubbed fetch every 5 s, and the stub recorded it like a routed request. A pulse landing between a reset of started and a check failed "nothing went upstream" (it can also skew the per-seat counts). The stub now answers presence pulses without recording them. Ran it twice locally: 68 passed, 0 failed.

…back

The keys-budget burst checks held each admitted request at the stub for a fixed 400 ms. On a loaded runner a burst request could reach the budget check after an admitted one completed, so it saw completed use instead of a reservation and the admitted count drifted. The stub now holds admitted requests until every expected refusal has come back, with a 10 s bound so a wrong count fails instead of hanging.
@github-actions github-actions Bot added the tests Test suite changes label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Live test: ✅ PASS

Head 0f3b7d6f65fc3b822d20c8abc730a86d5f7675db on the self-hosted runner: All stages PASS: install/build/cc-detect/cli/doctor/live-probe(pong)

Stages
install: PASS
build: PASS
cc-detect: PASS
cli: PASS
doctor: PASS (exit 1, 19 rows; no credentials, reported cleanly)
live: PASS (pong)

Full workflow run

The proxy's presence heartbeat goes through the stubbed fetch every 5 s. A pulse that landed between a reset of the recorded calls and a check made 'nothing went upstream' (and the per-seat counts) fail on a slow runner. The stub now answers presence pulses without recording them.
@askalf askalf changed the title test: hold a budget burst's admitted requests until its refusals are back test: fix two timing flakes in the keys proxy tests Nov 2, 2026

@sprayberry-redline sprayberry-redline left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verdict: approve. The burst helper keeps admitted requests in flight until the expected refusals have returned, and the upstream stub now excludes presence heartbeats from routed-request assertions. The tests retain their status-count assertions while avoiding timing-dependent completion ordering.

Minor:

  • test/keys-budget-proxy.mjs:102: This comment narrates the prior timing failure and the patch history rather than only documenting the helper's current contract.

@askalf
askalf merged commit 3f8e3f3 into master Nov 2, 2026
22 checks passed
@askalf
askalf deleted the test/budget-burst-gate branch November 2, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants