Files
coder/coderd/x/chatd
Thomas KosiewskiandEthan Dickson 8fb77c1b94 test(coderd/x/chatd): wait for in-flight admissions before partitioning replica (#31830)
Fixes the `TestRunnerManager_HeartbeatDoesNotReviveStaleLease` flake
([CODAGT-1288](https://linear.app/codercom/issue/CODAGT-1288)).

An admission on replica one that started before the simulated partition
could finish after the test made chat A's lease stale, then admit chat B
on replica one. Replica two never acquired B and the test timed out
waiting for it.

`partitionableLimiter` now holds a read lock for each `Admit` call, and
`setPartitioned` takes the write lock. Setting the partition therefore
waits for admissions already in flight, which see A's lease as fresh and
refuse B. This is a test-only change.

Verification:
- With a 1s delay injected into `partitionableLimiter.Admit`, the
original test failed 3/3 with the CI error. The fixed test passed 3/3
with the same delay.
- `go test -race -count=20` passed for this test and the other tests in
the file.
- `golangci-lint` and `go vet` on `./coderd/x/chatd/...` are clean.

> [!NOTE]
> Generated by Coder Agents.

Co-authored-by: Ethan Dickson <ethanndickson@gmail.com>
2026-12-02 06:29:37 +00:00
..
…