test(sync-service): make StackSupervisor telemetry test synchronous#4554
test(sync-service): make StackSupervisor telemetry test synchronous#4554erik-the-implementer wants to merge 1 commit into
Conversation
The "per-status HTTP request counts are scrapable" test starts a Prometheus reporter and asserts exact per-status counters after emitting a fixed set of [:electric, :plug, :serve_shape] events. Telemetry handlers are global, so the reporter's handler also counts serve_shape events emitted by any other test running concurrently (the real serve_shape plug emits this event on every shape request). Under `async: true` that produced non-deterministic counts, e.g. status="200" observed as 3 instead of the expected 2. Mark the module `async: false` so ExUnit never runs it concurrently with other tests, making the exact-count assertions deterministic. The metric aggregates only by `:status`, so there is no way to scope the reporter's global handler per-test while keeping the module async. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4554 +/- ##
==========================================
+ Coverage 54.85% 56.70% +1.84%
==========================================
Files 318 361 +43
Lines 36843 39560 +2717
Branches 10516 11129 +613
==========================================
+ Hits 20212 22431 +2219
- Misses 16598 17058 +460
- Partials 33 71 +38
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Claude Code ReviewSummaryA one-line test-isolation fix that switches What's Working Well
Issues FoundCritical (Must Fix)None. Important (Should Fix)None. Suggestions (Nice to Have)
Issue ConformanceNo linked issue, but the PR description clearly explains the flake, the mechanism, and the context (#3992). For a self-contained test-isolation fix this is sufficient. No changeset is required: the change is test-only and doesn't affect the published Previous Review StatusN/A — first review. Review iteration: 1 | 2026-06-10 |
Summary
Fixes a flaky test:
Electric.StackSupervisor.TelemetryTest"per-status HTTPrequest counts are scrapable".
The test starts a Prometheus reporter and asserts exact per-status counters
after emitting a fixed set of
[:electric, :plug, :serve_shape]events.Telemetry handlers are global, so the reporter's handler also counts
serve_shapeevents emitted by any other test running concurrently — the realserve_shapeplug emits this event on every shape request. Underasync: truethis produced non-deterministic counts (e.g.
status="200"observed as 3instead of the expected 2).
Marking the module
async: falsemakes ExUnit never schedule it concurrentlywith other tests, so the exact-count assertions become deterministic. The
metric aggregates only by
:status, so there's no way to scope the reporter'sglobal handler per-test while keeping the module async.
Context
This flake surfaced while validating the Elixir/OTP upgrade in #3992, where
OTP 29's scheduling timing made the latent contamination trip more often. It's
an independent test-isolation bug on
main, so it's split out here.🤖 Generated with Claude Code