Files
buzz/crates
Logan Johnson 403855d788 test(relay): give group-state Postgres tests a normal acquire timeout (#8564)
🤖
## Summary
The relay's PostgreSQL CI job sometimes fails in the channel group-state
tests with `ensure community: Sqlx(PoolTimedOut)`. The tests themselves
are fine. They connect to the test database through a test helper that
waits only 100 ms for a connection, and on a busy CI runner the first
connection can take longer than that. One example is
`group_state_events_carry_type_then_creator` in [this #8522
run](https://github.com/block/buzz/actions/runs/40013074144/job/120623293420):
it failed after 0.57 s, while its other 1110 tests passed.

This PR gives these tests a pool with sqlx's normal acquire timeout. No
product code changes.

## Details
- `test_state_with_database_url` keeps its 100 ms timeout on purpose.
Its other callers point at a closed port (`127.0.0.1:1`) to test
fail-closed paths, and the short timeout makes them fail fast.
- `group_state_postgres_tests::state()` is the only caller that passes
it the real test database. It now builds a normal lazy pool and passes
it to `test_state_with_database_pool`. The same `state()` also serves
`create_with_members_postgres_tests`, `edit_metadata_postgres_tests`,
and `system_channel_postgres_tests`.

### Related issue
N/A. I searched open PRs for `PoolTimedOut` and `acquire_timeout` and
found none for this.

### Testing
To reproduce a slow first connection, I ran the tests through a local
TCP proxy that waits 250 ms before it connects to Postgres:
- Before this change: `group_state_postgres_tests` had 13 of 14 tests
fail with `PoolTimedOut`.
- After this change: all 14 pass. `create_with_members_postgres_tests`
(3), `edit_metadata_postgres_tests` (7), and
`system_channel_postgres_tests` (9) also pass through the same proxy.
- Without the proxy, all 14 pass before and after.
- `cargo clippy -p buzz-relay --all-targets -D warnings` and `just
test-unit` pass.

---------

Signed-off-by: Logan Johnson <loganj@squareup.com>
Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 16:55:51 -04:00
..