test(sync-service): make StackSupervisor telemetry test synchronous#4554
test(sync-service): make StackSupervisor telemetry test synchronous#4554erik-the-implementer wants to merge 2 commits 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% 58.07% +3.21%
==========================================
Files 318 369 +51
Lines 36843 40459 +3616
Branches 10516 11465 +949
==========================================
+ Hits 20212 23498 +3286
- Misses 16598 16887 +289
- Partials 33 74 +41
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. Previous Review StatusIteration 1 → 2: The only change since my last review is the newly added
My iteration-1 note said a changeset wasn't strictly required since the change is test-only and doesn't alter the published artifact — but adding one is harmless and keeps the change consistent with the repo's changeset-gated workflow. No concerns. The test change itself is unchanged and still correct. This PR looks ready to merge. Review iteration: 2 | 2026-06-11 |
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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