Skip to content

Commit bd73490

Browse files
ci: run PostgreSQL tests in isolated lane (#6730)
## Why PR #6660 introduced four PostgreSQL-backed persistence tests and a focused CI selector, but an exact test-name list does not automatically cover future database tests. Broad ignored-test execution also exposed shared-schema races and ambiguity between desired-state and migration-applied schema expectations. ## What - Establish a discoverable convention: PostgreSQL unit modules use `postgres_tests`, PostgreSQL integration binaries use a `postgres_` prefix, and unrelated external-infrastructure tests use an `external_infra_` prefix. - Add a dedicated nextest PostgreSQL profile and archive-backed CI job covering the relevant crates without enumerating test names. - Create a run-scoped desired-state source database and a unique PostgreSQL database per test process for parallel-safe isolation, with cleanup on success, failure, or interruption. - Route destructive migration and migration-parity tests to clean `template0` databases while desired-state tests clone the desired-state database. - Document discovery, schema modes, required role privileges, and a bounded portable local runner. - Keep the existing infrastructure-free unit-test jobs unchanged. This is intentionally limited to test and CI harness behavior. It does not move production database code, change persistence semantics, or implement issue #20's broader shared test-utility refactor. ## Risk Low production risk because all changes are confined to tests, CI configuration, documentation, and test harness scripts. Remaining operational risks: - Cleanup retries `dropdb --force` five times across roughly four seconds. Exhaustion warns with the database name but deliberately does not mask the test result; individual PostgreSQL diagnostics are suppressed. - The seven-package boundary is duplicated between the runner and CI archive and must remain synchronized if PostgreSQL tests move to a new crate. - Portable SHA fallback branches were exercised on Linux; no macOS Blox workstation was needed for this Linux CI artifact. - GitHub's unchanged generic Unit Tests job currently fails while cold-linking `buzz-voice` because `sherpa-onnx-c-api` is absent. The branch changes no voice/build/toolchain inputs; the exact parent previously passed that job, and Blox passes the same infrastructure-free suite (1,450/1,450). A prior-head one-job retry and the final-head run both reproduced the hosted-runner failure. ## Verification Author Blox workstation `2020088`: - `cargo fmt --all -- --check` - `just clippy` - `just test-unit`: 1,450 passed; PostgreSQL tests remain skipped in fast jobs - PR #6660 focused tests: 4/4 passed through the final runner - Full lane: 282/282 passed in 10.087s with a non-superuser role limited to `CREATEDB`, `CREATEROLE`, and `pg_read_all_stats` - 272 desired-state tests - 10 migration-applied tests - 6 explicitly filtered external-infrastructure tests - Cleanup fault injection: a deliberately underprivileged 282-test run produced the expected 277 passes and 5 failures, and the post-run catalog audit found zero lane databases after retry cleanup. The restored successful run also left zero lane databases. GitHub exact final head `92c231e48f299ea2af23817763f5ae80ac013d68`: - [PostgreSQL Tests](https://github.com/block/buzz/actions/runs/32789030203/job/97630827823): 282/282 passed across 10 binaries in 98.886s; 1,240 skipped, including 6 via the profile filter - The shared relay/PostgreSQL archive predecessor completed successfully - [Unit Tests](https://github.com/block/buzz/actions/runs/32789030203/job/97626930420): unrelated `sherpa-onnx-c-api` native-link failure described above - Independent exact-head review on separate Blox workstation `2022762`: no substantive findings after all initial findings were addressed. The reviewer independently verified cleanup retry behavior, exit-status preservation, shell portability, syntax, and a clean exact-head worktree. ## References - Stacked on #6660 at exact head `561de54be4d9c2b622b7c2aa5b61bc3068f47e2a` - TheSentinel454#20 - TheSentinel454#20 (comment) Generated with Codex. ## Update — August 24, 2026 review follow-up - Centralized the repeated PostgreSQL test URL resolution in crate-local, test-only helpers without introducing the broader shared utility refactor from issue #20. - Restored descriptive hybrid/Redis test function names. Structural `external_infra_*_tests` modules now own exclusion, and the nextest filter only recognizes module path segments. - Added a three-second source guard that scans every Rust file and fails CI when an ignored PostgreSQL test would be omitted or an external-infrastructure test would be included. Fixture tests cover accepted modules/binaries and both failure modes. - Removed the two implementation-plan documents. Performance profiling on Blox workstation `2027352` (same prebuilt archive and cargo-nextest 0.9.143 for every comparison): - Current per-test database model, 8 workers: 10.15–10.40s across three runs. The 283 `createdb` calls and 284 `dropdb` calls consumed 28.85–29.46 aggregate seconds, about 39–40% of aggregate test-process duration. - Reusing one database per worker without cleanup: 6.55–6.84s, about 35% faster, but all three runs failed because global matcher-queue tests inherited a quiesced community from an earlier test; the failing test varied with scheduling. - Reusing workers with `TRUNCATE … RESTART IDENTITY CASCADE`: all 282 tests passed, but total time regressed to 10.47–10.67s. The 265 truncate calls consumed 24.34–25.45 aggregate seconds, so truncation merely replaced most clone/drop cost. - Raising concurrency to 16 workers reduced one isolated-database run to 8.79s, but 24 workers exposed a cluster-global `pg_stat_activity` race. The profile remains at the proven-safe 8 workers. Decision: retain unique per-test databases. Harness cleanup uses `dropdb --if-exists --force`; it drops the database rather than truncating tables or deleting rows. Verification at local branch head `60086c1f6ee34a193c342255a5e8e6293b60e988`: - Discovery inventory: exactly 282 intended tests; all 6 hybrid/Redis tests present and structurally excluded. - PR #6660 focused persistence tests: 4/4 passed. - Full PostgreSQL lane: 282/282 passed three times; 1,240 skipped each run; wall time 9.72–9.96s without profiling shims. - Non-ignored tests with a desired-state database: 1,234/1,234 passed; one mesh-demo timeout from the first run passed immediately in isolation. - `cargo fmt --all -- --check` and all-target/all-feature clippy for `buzz-db`, `buzz-deletion`, and `buzz-relay` passed. Final independent re-review at exact head `42097c0136ab3fa8f0efe5720ae829c04575b9b6` on separate Blox workstation `2028455`: no substantive residual findings. The reviewer independently exercised ordinary strings, zero/one/three-hash raw strings, line/block comments, and string-contained lookalikes, then reran the full 353-file scan, shell syntax, Python AST parsing, and diff check. Independent review found that the source guard's initial regular expression could miss raw-string ignore reasons and treat a commented attribute as real. Final head `42097c0136ab3fa8f0efe5720ae829c04575b9b6` parses valid ordinary/raw Rust string literals only at attributes found in comment-sanitized source; regression fixtures cover both cases. The fixture suite, Python compilation, shell syntax, diff check, and full 353-file repository scan pass on Blox. ## Update — August 25, 2026 restack PR #6660 merged, so this follow-up was rebased from its former exact parent onto current `origin/main` (`8d2d0ff5ad42733e9949442c4b6358d0ba87f9a8`). The final candidate head is `05dcc2ab28948e3ab79bb44839a69f2ba44648a2`; the PR no longer carries #6660's pre-squash history. Fresh exact-head verification on Blox workstation `2028572`: - Discovery guard passed across 353 Rust files; inventory remained exactly 282 intended PostgreSQL tests. - PR #6660 focused persistence tests: 4/4 passed. - Full PostgreSQL lane: 282/282 passed three times; 1,243 skipped each run; wall time 9.70–9.87s. - `cargo fmt --all -- --check` and all-target/all-feature clippy for `buzz-db`, `buzz-deletion`, and `buzz-relay` passed. ## Update — August 25, 2026 final hosted verification - [GitHub PostgreSQL Tests](https://github.com/block/buzz/actions/runs/32801679226/job/97667835080): 282/282 passed in 53.787s; 1,243 skipped. - The final guard scanned all 353 Rust files successfully before the hosted lane ran. - The shared relay/archive prerequisite and infrastructure-free Unit Tests job both passed at exact final head `42097c0136ab3fa8f0efe5720ae829c04575b9b6`. --------- Signed-off-by: Luke Tornquist <[email protected]> Signed-off-by: tornquist <[email protected]>
1 parent 114dbf7 commit bd73490

62 files changed

Lines changed: 1619 additions & 442 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.config/nextest.toml‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
nextest-version = "0.9.136"
2+
# The PostgreSQL lane uses a run-scoped desired-state template database and a
3+
# per-test wrapper, both of which require nextest's script support.
4+
experimental = ["setup-scripts", "wrapper-scripts"]
5+
6+
[scripts.setup.postgres-template]
7+
# Bootstrap the desired-state source database once per nextest invocation.
8+
command = { command-line = "scripts/postgres-test-setup.sh", relative-to = "workspace-root" }
9+
slow-timeout = "60s"
10+
11+
[scripts.wrapper.postgres-isolation]
12+
# Clone or create a unique database for each test process, then drop it on exit.
13+
command = { command-line = "scripts/postgres-test-wrapper.sh", relative-to = "workspace-root" }
14+
15+
[profile.postgres-ci]
16+
# This structural convention keeps new PostgreSQL-backed tests discoverable
17+
# without maintaining an exact list of test names.
18+
default-filter = """
19+
(test(/postgres_tests::/) or binary(/^postgres_/))
20+
and not test(/(^|::)external_infra[^:]*::/)
21+
"""
22+
fail-fast = false
23+
# Eight workers was the fastest stable setting in the Blox benchmark while the
24+
# wrapper retained one database per concurrently running test process.
25+
test-threads = 8
26+
27+
[test-groups.postgres-cluster-global]
28+
# These tests inspect cluster-wide activity or create least-privilege sessions,
29+
# so database-per-test isolation alone cannot make them independent.
30+
max-threads = 1
31+
32+
[[profile.postgres-ci.overrides]]
33+
filter = "test(/cluster_global_/)"
34+
test-group = "postgres-cluster-global"
35+
36+
[[profile.postgres-ci.scripts]]
37+
# Script filters are separate from default-filter: they attach the setup and
38+
# isolation wrapper to the same automatically discovered test set.
39+
filter = "(test(/postgres_tests::/) or binary(/^postgres_/)) and not test(/(^|::)external_infra[^:]*::/)"
40+
setup = "postgres-template"
41+
run-wrapper = "postgres-isolation"

‎.github/workflows/ci.yml‎

Lines changed: 112 additions & 163 deletions
Large diffs are not rendered by default.

‎CONTRIBUTING.md‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,64 @@ connections, NIP-42 auth, event ingestion, search indexing, and workflow
215215
execution. `just test` starts Docker services automatically if they're not
216216
already running.
217217

218+
### PostgreSQL-backed tests
219+
220+
PostgreSQL-backed tests run in a dedicated nextest lane. Mark them ignored with
221+
a PostgreSQL reason and place them in a module whose name ends in
222+
`postgres_tests`. Standalone integration-test targets use a `postgres_`
223+
filename prefix instead. Tests that also require infrastructure beyond
224+
PostgreSQL and Redis live under an `external_infra*_tests` module and are
225+
excluded without changing their descriptive function names.
226+
227+
See the [buzz-db testing guide](crates/buzz-db/TESTING.md) for the crate-level
228+
checklist.
229+
230+
`scripts/test-postgres-test-discovery.sh` enforces the convention across every
231+
Rust source file. It fails CI when an ignored PostgreSQL test would be omitted,
232+
or when a Redis-only or hybrid test is accidentally included, so module or file
233+
renames cannot silently change lane membership. The archive and runner derive
234+
their Cargo package set from the same markers, so a database test in a new crate
235+
does not require a separate package-list update.
236+
237+
The `postgres-ci` nextest profile creates one database per test process, so
238+
destructive and concurrent tests must use the database URL supplied through
239+
`BUZZ_TEST_DATABASE_URL`, `TEST_DATABASE_URL`, or `DATABASE_URL`; do not
240+
hard-code the shared development database. Ordinary tests receive the committed
241+
desired-state schema from `schema/schema.sql`. Tests under
242+
`migration::postgres_tests` receive an empty database and own the embedded
243+
migration lifecycle. A test outside that module whose behavior intentionally
244+
depends on migration-created triggers or seed rows uses a
245+
`migration_schema_` function-name prefix and also receives an empty database
246+
with `BUZZ_TEST_SCHEMA_MODE=migration`. Test helpers that normally call the
247+
migrator honor `BUZZ_TEST_SCHEMA_MODE=desired` so the desired-state contract is
248+
not re-migrated.
249+
250+
Tests that inspect cluster-wide PostgreSQL state or open least-privilege
251+
sessions use a `cluster_global_` function-name segment; migration-backed cases
252+
use `migration_schema_cluster_global_`. Nextest serializes this small group
253+
while the database-isolated remainder stays parallel.
254+
255+
The setup process requires a PostgreSQL role that can create and drop databases
256+
and owns the databases it creates; the harness itself does not require
257+
superuser access. The complete inventory includes privilege-boundary tests that
258+
create temporary roles and inspect all sessions, so grant that role
259+
`CREATEROLE` and membership in `pg_read_all_stats` (or use an ephemeral
260+
superuser, as CI does).
261+
Set `BUZZ_POSTGRES_ADMIN_URL` to that role's maintenance database, and set
262+
`PGHOST`, `PGPORT`, `PGUSER`, and `PGPASSWORD` for the desired-state
263+
schema bootstrap. PostgreSQL client tools are resolved from `PATH` unless
264+
`PG_BIN_DIR` is set. Tests that use Redis read `REDIS_URL`.
265+
266+
With native PostgreSQL and Redis running, the complete lane is below. The
267+
runner bounds compilation to the packages discovered from the current source
268+
tree and removes the run-scoped desired-state source database on exit.
269+
Per-test and source-database cleanup retries transient PostgreSQL disconnect
270+
races and emits a warning if all five attempts fail.
271+
272+
```bash
273+
./scripts/postgres-test-run.sh
274+
```
275+
218276
### End-to-End Tests
219277

220278
End-to-end tests live in `crates/buzz-test-client/tests/`:

‎crates/buzz-audit/src/service.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ fn row_to_audit_entry(row: &sqlx::postgres::PgRow) -> Result<AuditEntry, AuditEr
269269
}
270270

271271
#[cfg(test)]
272-
mod tests {
272+
mod postgres_tests {
273273
use super::*;
274274
use crate::action::AuditAction;
275275
use crate::entry::NewAuditEntry;

‎crates/buzz-db/TESTING.md‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# PostgreSQL-backed tests in buzz-db
2+
3+
The dedicated PostgreSQL CI lane discovers tests and Cargo packages by
4+
structure rather than by exact lists. Follow this checklist so a new database
5+
test is run automatically and remains safe under parallel execution.
6+
7+
## Adding a test
8+
9+
1. Put the test in a module whose name ends in `postgres_tests`.
10+
2. Mark it `#[ignore = "requires Postgres"]` so infrastructure-free unit-test
11+
jobs stay fast.
12+
3. Connect through `crate::test_support::database_url()`. The CI wrapper sets
13+
this helper's environment to a unique database for each test process; never
14+
hard-code the shared development database.
15+
4. Keep tests that need infrastructure beyond PostgreSQL and Redis in an
16+
`external_infra*_tests` module. The PostgreSQL lane excludes those tests.
17+
5. Run `scripts/test-postgres-test-discovery.sh` after adding or moving the
18+
test. The same guard runs in CI immediately after changed-path detection.
19+
20+
The wrapper isolates destructive tests by dropping the entire per-test
21+
database after the process exits. It does not `DELETE` rows or `TRUNCATE`
22+
shared tables, so tests may run concurrently without coordinating cleanup.
23+
24+
## Choose the schema intentionally
25+
26+
Most tests use the committed desired-state schema from `schema/schema.sql`.
27+
That is the default and is appropriate for data-access behavior.
28+
29+
Tests in `migration::postgres_tests` receive an empty database and own the
30+
embedded migration lifecycle. A test outside that module that intentionally
31+
depends on migration-created triggers or seed rows must prefix its function
32+
name with `migration_schema_`; it also receives an empty database with
33+
`BUZZ_TEST_SCHEMA_MODE=migration`.
34+
35+
Helpers that normally run migrations honor `BUZZ_TEST_SCHEMA_MODE=desired` in
36+
the default lane. Do not rerun migrations against a desired-state database.
37+
When behavior should match in both schema paths, add explicit desired-state and
38+
migration-applied coverage rather than making the bootstrap implicit.
39+
40+
Tests that inspect cluster-wide PostgreSQL state or open least-privilege
41+
sessions include `cluster_global_` in the function name. Migration-backed cases
42+
use `migration_schema_cluster_global_`. Nextest serializes this small group
43+
because separate databases still share `pg_stat_activity` and roles.
44+
45+
## Run the lane locally
46+
47+
Start native PostgreSQL and Redis, activate Hermit, and run:
48+
49+
```bash
50+
. ./bin/activate-hermit
51+
scripts/test-postgres-test-discovery.sh
52+
scripts/postgres-test-run.sh
53+
```
54+
55+
Set `BUZZ_POSTGRES_ADMIN_URL` to a PostgreSQL maintenance database owned by a
56+
role that can create and drop databases. Set `PGHOST`, `PGPORT`, `PGUSER`, and
57+
`PGPASSWORD` for desired-state bootstrap, plus `REDIS_URL` for Redis-backed
58+
tests. The complete privilege-boundary inventory also needs `CREATEROLE` and
59+
membership in `pg_read_all_stats`, or an ephemeral superuser as CI uses.
60+
61+
The runner creates one desired-state source database per invocation and clones
62+
it for ordinary tests. Migration-mode tests start empty. Cleanup retries
63+
transient disconnect races before reporting a warning.

‎crates/buzz-db/src/lib.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ mod store;
2727
/// Database error types.
2828
pub mod error;
2929

30+
#[cfg(test)]
31+
mod test_support;
32+
3033
pub use runtime::{
3134
insert_mentions, migration, replica_fence, Db, DbConfig, DbPoolStats, ReadSession,
3235
};

‎crates/buzz-db/src/runtime/migration.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ async fn reject_legacy_nip_rs_cardinality_ambiguity(conn: &mut PgConnection) ->
183183
}
184184

185185
#[cfg(test)]
186-
mod tests {
186+
mod postgres_tests {
187187
use super::*;
188188
use std::{
189189
collections::BTreeSet,

‎crates/buzz-db/src/runtime/mod.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,4 +1112,5 @@ impl Db {
11121112
}
11131113

11141114
#[cfg(test)]
1115-
mod tests;
1115+
#[path = "tests.rs"]
1116+
mod postgres_tests;

‎crates/buzz-db/src/runtime/observability.rs‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,14 +426,15 @@ mod tests {
426426
}
427427
}
428428

429-
#[tokio::test(flavor = "current_thread")]
430-
#[ignore = "requires Postgres"]
431429
async fn pool_acquire_records_success_timeout_and_error_with_wait_time() {
430+
// This timeout also bounds the pool's initial connection. Leave enough
431+
// headroom for a cold PostgreSQL start under the lane's eight workers;
432+
// the assertion below cares about classification, not a 75 ms budget.
432433
let database_url = std::env::var("TEST_DATABASE_URL")
433434
.unwrap_or_else(|_| "postgres://buzz:buzz_dev@localhost:5432/buzz".to_owned()); // sadscan:disable np.postgres.1 -- local test-only credentials
434435
let pool = sqlx::postgres::PgPoolOptions::new()
435436
.max_connections(1)
436-
.acquire_timeout(Duration::from_millis(75))
437+
.acquire_timeout(Duration::from_secs(1))
437438
.connect(&database_url)
438439
.await
439440
.expect("connect size-one test pool");
@@ -490,8 +491,6 @@ mod tests {
490491
);
491492
}
492493

493-
#[tokio::test(flavor = "current_thread")]
494-
#[ignore = "requires Postgres"]
495494
async fn advisory_lock_records_success_contention_timeout_and_error() {
496495
let database_url = std::env::var("TEST_DATABASE_URL")
497496
.unwrap_or_else(|_| "postgres://buzz:buzz_dev@localhost:5432/buzz".to_owned()); // sadscan:disable np.postgres.1 -- local test-only credentials
@@ -633,4 +632,18 @@ mod tests {
633632
"lock timer must include the holder wait: {contention:?}"
634633
);
635634
}
635+
636+
mod postgres_tests {
637+
#[tokio::test(flavor = "current_thread")]
638+
#[ignore = "requires Postgres"]
639+
async fn pool_acquire_records_success_timeout_and_error_with_wait_time() {
640+
super::pool_acquire_records_success_timeout_and_error_with_wait_time().await;
641+
}
642+
643+
#[tokio::test(flavor = "current_thread")]
644+
#[ignore = "requires Postgres"]
645+
async fn advisory_lock_records_success_contention_timeout_and_error() {
646+
super::advisory_lock_records_success_contention_timeout_and_error().await;
647+
}
648+
}
636649
}

‎crates/buzz-db/src/runtime/replica_fence.rs‎

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -789,28 +789,22 @@ pub async fn run_probe(writer: PgPool, fence: Arc<ReplicaFence>) {
789789
}
790790

791791
#[cfg(test)]
792-
mod tests {
792+
mod postgres_tests {
793793
use super::*;
794794

795-
const TEST_DB_URL: &str = "postgres://buzz:buzz_dev@localhost:5432/buzz"; // sadscan:disable np.postgres.1
796-
797-
fn test_db_url() -> String {
798-
std::env::var("TEST_DATABASE_URL").unwrap_or_else(|_| TEST_DB_URL.into())
799-
}
800-
801795
/// A private scratch database with migrations applied: the probe tests
802796
/// mutate the singleton heartbeat row (rewind/rotate), which must never
803797
/// race the shared dev database or each other.
804798
async fn scratch_db() -> (PgPool, PgPool, String) {
805-
let admin = PgPool::connect(&test_db_url())
799+
let admin = PgPool::connect(&crate::test_support::database_url())
806800
.await
807801
.expect("connect admin");
808802
let name = format!("fence_probe_{}", uuid::Uuid::new_v4().simple());
809803
sqlx::query(sqlx::AssertSqlSafe(format!("CREATE DATABASE {name}")))
810804
.execute(&admin)
811805
.await
812806
.expect("create scratch db");
813-
let base = test_db_url();
807+
let base = crate::test_support::database_url();
814808
let idx = base.rfind('/').expect("db url has a path segment");
815809
let pool = PgPool::connect(&format!("{}/{}", &base[..idx], name))
816810
.await
@@ -973,17 +967,27 @@ mod tests {
973967
/// sessions, per the agreed classification.
974968
#[tokio::test]
975969
#[ignore = "requires Postgres"]
976-
async fn sample_writer_sees_open_transactions_and_ignores_idle() {
977-
let pool = PgPool::connect(&test_db_url()).await.expect("connect");
970+
async fn migration_schema_cluster_global_sample_writer_sees_open_transactions_and_ignores_idle()
971+
{
972+
let pool = PgPool::connect(&crate::test_support::database_url())
973+
.await
974+
.expect("connect");
975+
crate::migration::run_migrations(&pool)
976+
.await
977+
.expect("apply migration schema");
978978

979979
// A plain idle session: pinned connection, no transaction.
980-
let idle_pool = PgPool::connect(&test_db_url()).await.expect("connect idle");
980+
let idle_pool = PgPool::connect(&crate::test_support::database_url())
981+
.await
982+
.expect("connect idle");
981983
let _idle_conn = idle_pool.acquire().await.expect("idle conn");
982984

983985
let before = sample_writer(&pool).await.expect("sample without tx");
984986

985987
// Now hold a transaction open on a second connection.
986-
let tx_pool = PgPool::connect(&test_db_url()).await.expect("connect tx");
988+
let tx_pool = PgPool::connect(&crate::test_support::database_url())
989+
.await
990+
.expect("connect tx");
987991
let mut tx = tx_pool.begin().await.expect("begin");
988992
sqlx::query("SELECT 1")
989993
.execute(&mut *tx)
@@ -1016,12 +1020,16 @@ mod tests {
10161020
/// never silently `MIN()` the hidden row away.
10171021
#[tokio::test]
10181022
#[ignore = "requires Postgres"]
1019-
async fn sample_writer_fails_closed_when_activity_is_masked() {
1020-
let admin = PgPool::connect(&test_db_url()).await.expect("connect");
1023+
async fn cluster_global_sample_writer_fails_closed_when_activity_is_masked() {
1024+
let admin = PgPool::connect(&crate::test_support::database_url())
1025+
.await
1026+
.expect("connect");
10211027

10221028
// Hold a transaction open as the privileged user: this is the row
10231029
// the unprivileged probe must notice it cannot classify.
1024-
let tx_pool = PgPool::connect(&test_db_url()).await.expect("connect tx");
1030+
let tx_pool = PgPool::connect(&crate::test_support::database_url())
1031+
.await
1032+
.expect("connect tx");
10251033
let mut tx = tx_pool.begin().await.expect("begin");
10261034
sqlx::query("SELECT 1")
10271035
.execute(&mut *tx)
@@ -1038,7 +1046,7 @@ mod tests {
10381046
.await
10391047
.expect("create unprivileged role");
10401048

1041-
let base = test_db_url();
1049+
let base = crate::test_support::database_url();
10421050
let unpriv_url = {
10431051
let rest = base.strip_prefix("postgres://").expect("pg url");
10441052
let at = rest.rfind('@').expect("credentials in url");
@@ -1079,7 +1087,9 @@ mod tests {
10791087
#[tokio::test]
10801088
#[ignore = "requires Postgres"]
10811089
async fn aurora_identity_probe_reports_false_on_plain_postgres() {
1082-
let pool = PgPool::connect(&test_db_url()).await.expect("connect");
1090+
let pool = PgPool::connect(&crate::test_support::database_url())
1091+
.await
1092+
.expect("connect");
10831093
let mut conn = pool.acquire().await.expect("conn");
10841094
assert!(
10851095
!reader_supports_aurora_identity(&mut conn)
@@ -1100,7 +1110,7 @@ mod tests {
11001110
/// same database observes a token/epoch that resolves that entry.
11011111
#[tokio::test]
11021112
#[ignore = "requires Postgres"]
1103-
async fn probe_commits_tokens_and_sessions_prove_coverage() {
1113+
async fn cluster_global_probe_commits_tokens_and_sessions_prove_coverage() {
11041114
let (admin, pool, name) = scratch_db().await;
11051115
let fence = ReplicaFence::new();
11061116

@@ -1155,7 +1165,7 @@ mod tests {
11551165
/// epoch — fails the epoch check instead of proving stale coverage.
11561166
#[tokio::test]
11571167
#[ignore = "requires Postgres"]
1158-
async fn probe_rotates_epoch_on_same_epoch_token_regression() {
1168+
async fn cluster_global_probe_rotates_epoch_on_same_epoch_token_regression() {
11591169
let (admin, pool, name) = scratch_db().await;
11601170
let fence = ReplicaFence::new();
11611171

0 commit comments

Comments
 (0)