From a30860fdb7a2a018a96e0d13928c353e323ff7de Mon Sep 17 00:00:00 2001 From: Oleksii Sholik Date: Wed, 10 Jun 2026 14:49:30 +0200 Subject: [PATCH 1/2] test(sync-service): make StackSupervisor telemetry test synchronous 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) --- .../test/electric/stack_supervisor/telemetry_test.exs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/sync-service/test/electric/stack_supervisor/telemetry_test.exs b/packages/sync-service/test/electric/stack_supervisor/telemetry_test.exs index 0b658eae75..5c543abf87 100644 --- a/packages/sync-service/test/electric/stack_supervisor/telemetry_test.exs +++ b/packages/sync-service/test/electric/stack_supervisor/telemetry_test.exs @@ -1,6 +1,10 @@ if Electric.telemetry_enabled?() and Code.ensure_loaded?(ElectricTelemetry.Reporters.Prometheus) do defmodule Electric.StackSupervisor.TelemetryTest do - use ExUnit.Case, async: true + # Not async: the Prometheus reporter attaches a global :telemetry handler for + # [:electric, :plug, :serve_shape], so concurrent async tests that emit that + # event (via the real serve_shape plug) leak into this reporter's per-status + # counters and make the exact-count assertions below non-deterministic. + use ExUnit.Case, async: false alias Electric.StackSupervisor.Telemetry From 123a5f8e906025b16b1f2a89d48c6ef898575bdf Mon Sep 17 00:00:00 2001 From: Oleksii Sholik Date: Thu, 11 Jun 2026 13:27:27 +0200 Subject: [PATCH 2/2] chore: add changeset for test-only sync-service change --- .changeset/fix-telemetry-test-isolation.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-telemetry-test-isolation.md diff --git a/.changeset/fix-telemetry-test-isolation.md b/.changeset/fix-telemetry-test-isolation.md new file mode 100644 index 0000000000..c783d48838 --- /dev/null +++ b/.changeset/fix-telemetry-test-isolation.md @@ -0,0 +1,5 @@ +--- +"@core/sync-service": patch +--- + +Test-only: make the StackSupervisor telemetry test synchronous to avoid serve_shape counter contamination from concurrently running tests. No runtime changes.