Skip to content

Fix flaky CircuitBreakerTest timing assertions#452

Merged
adamw merged 3 commits into
masterfrom
fix-ci-build-26810641361
Jun 2, 2026
Merged

Fix flaky CircuitBreakerTest timing assertions#452
adamw merged 3 commits into
masterfrom
fix-ci-build-26810641361

Conversation

@adamw
Copy link
Copy Markdown
Member

@adamw adamw commented Jun 2, 2026

Problem

CI run 26810641361 failed on the ci (21) matrix entry in ox.resilience.CircuitBreakerTest (CircuitBreakerTest.scala:153, test "should switch back to open after configured timeout in half open state").

Root cause

The scheduled circuit-breaker state transitions (open → half-open → open) are driven by forked timers handed off to the breaker's actor. The exact moment a transition becomes observable depends on thread scheduling, so on a loaded CI runner a transition can land later than its nominal delay. The tests asserted state with a single fixed sleep-then-read, which is racy — hence the intermittent failure.

Fix

Replace the fixed-sleep-then-read assertions with ScalaTest Eventually polling (8s timeout, 50ms interval) for the expected state. This keeps the assertions deterministic in intent while tolerating scheduling jitter. No production code changed.

🤖 Generated with Claude Code

adamw and others added 3 commits June 2, 2026 12:08
Replace shared eventually timeout/interval vals with concrete values sized
to each test's config: the transient HalfOpen catch uses a timeout inside the
half-open window, while the recovery-to-Open wait outlasts it. Widen the
half-open window so the transient state is reliably sampled under load.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@adamw adamw merged commit 3182ccd into master Jun 2, 2026
6 checks passed
@adamw adamw deleted the fix-ci-build-26810641361 branch June 2, 2026 13:05
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