test: pgstore test isolation — Truncate calls cause cross-test failures #243

Closed
opened 2026-03-10 19:49:26 +00:00 by ash · 0 comments
Owner

Problem

Several pgstore tests call store.Truncate(ctx) or similar table-wiping operations that affect other tests running in the same suite:

  • benchmark_gaps_test.go:60store.Truncate(ctx)
  • conformance_test.go:92store.Truncate(context.Background())

When run as a full suite (go test ./pgstore/), these wipe the events table between tests, causing unrelated tests to find 0 events and fail.

All tests pass individually. ~9 fail when run together.

Solution

Options (pick one):

  1. Per-test schema isolation: each test creates its own schema (CREATE SCHEMA test_<uuid>) and drops it on cleanup
  2. Unique stream IDs everywhere: no test shares stream IDs, remove all Truncate calls from tests
  3. TestMain with serial execution: run truncating tests in a known order with explicit barriers

Option 2 is simplest. Most tests already use unique IDs — just need to fix the few that Truncate.

Pre-existing

This is not caused by #240. These failures existed before the stream_type interface change.

## Problem Several pgstore tests call `store.Truncate(ctx)` or similar table-wiping operations that affect other tests running in the same suite: - `benchmark_gaps_test.go:60` — `store.Truncate(ctx)` - `conformance_test.go:92` — `store.Truncate(context.Background())` When run as a full suite (`go test ./pgstore/`), these wipe the events table between tests, causing unrelated tests to find 0 events and fail. All tests pass individually. ~9 fail when run together. ## Solution Options (pick one): 1. **Per-test schema isolation**: each test creates its own schema (`CREATE SCHEMA test_<uuid>`) and drops it on cleanup 2. **Unique stream IDs everywhere**: no test shares stream IDs, remove all Truncate calls from tests 3. **TestMain with serial execution**: run truncating tests in a known order with explicit barriers Option 2 is simplest. Most tests already use unique IDs — just need to fix the few that Truncate. ## Pre-existing This is not caused by #240. These failures existed before the stream_type interface change.
ash closed this issue 2026-03-10 20:57:44 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ash/eskit#243
No description provided.