Skip to content

test(paidtool): de-flake postpaid metering (fixes intermittent CI failure)#35

Open
boymak wants to merge 1 commit into
niceberginc:mainfrom
boymak:fix/flaky-postpaid-metering-test
Open

test(paidtool): de-flake postpaid metering (fixes intermittent CI failure)#35
boymak wants to merge 1 commit into
niceberginc:mainfrom
boymak:fix/flaky-postpaid-metering-test

Conversation

@boymak

@boymak boymak commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Why

CI run 28174117576 failed on postpaid metering › charges based on actual execution metrics (expected true, actual false). It's a flaky, timing-dependent assertion — not a real regression: re-runs and every merge build passed, so main is green.

The handler sleeps 50ms and meters durationMs × $0.001. The test asserted amount < 0.15 (i.e. duration < 150ms). On a slow/loaded CI runner the real duration can spike past 150ms (GC, scheduler, cold runner) → the upper bound fails.

Fix

  • Keep the meaningful lower bound (≥ $0.05 ⇒ ≥50ms of metered work — setTimeout never fires early, so this is safe).
  • Replace the flaky upper bound with an exact check that amount === durationMs × rate, which actually proves "charges based on actual metrics" without depending on wall-clock speed.

Full suite: 247 passing. No production code touched.

Note (non-blocking)

CI also logs a warning that actions/checkout@v4 / actions/setup-node@v4 target Node 20 (deprecated, forced to Node 24). Worth bumping the actions in a follow-up, but it's just a warning, not the failure.

🤖 Generated with Claude Code

…per bound

CI run 28174117576 failed on "postpaid metering › charges based on actual
execution metrics" (expected true, actual false). The handler sleeps 50ms and
the test asserted the metered charge was < $0.15 (i.e. duration < 150ms) — a
tight upper bound that flakes on slow/loaded CI runners where the real duration
can spike past 150ms (GC, scheduler, cold runner). The failure is non-
deterministic and unrelated to the change under test; re-runs and the merge
build passed.

Keep the meaningful lower bound (≥ $0.05 ⇒ ≥50ms of metered work) and replace
the flaky upper bound with an exact check that the charge equals
durationMs * rate — which actually proves "charges based on actual metrics"
without depending on wall-clock speed.

Full suite: 247 passing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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