carlos / platform Public

dbreads: TestRunPassesOnANudge waits for the start probe's unit before it nudges

Main's CI at cd55508a failed it: on a loaded box the start probe's worker
was still stopping when the nudge's pass ran, so admission met it as an
orphan and refused (by design, spec §5.7), and the next pass was 30 s away.
The test now makes that linger deterministic (300 ms) and was seen to fail
with it; it nudges once the probe has run and its unit is gone. No
production change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev f20eeb8569557e09c71fd5ce6962e5bac69889d3 parent cd55508
1 file changed, +15 −1
  • internal/dbreads/loop_test.go +15 −1

CI passed — run details

diff --git a/internal/dbreads/loop_test.go b/internal/dbreads/loop_test.go
index 294a91537..ea8e7441c 100644
--- a/internal/dbreads/loop_test.go
+++ b/internal/dbreads/loop_test.go
@@ -286,11 +286,25 @@ func TestProbeOnTheThirdConnection(t *testing.T) {
func TestRunPassesOnANudge(t *testing.T) {
t.Parallel()
fx := newFixture(t, 1)
- a, _ := fx.agent("uk-1")
+ // The start probe's worker unit lingers as systemd's deactivation (and a
+ // loaded CI box) makes it: main's CI caught the nudge's pass meeting it
+ // as an orphan, refusing admission, and nothing passing again within
+ // the test's bound (ListEvery is 30 s).
+ a, w := fx.agent("uk-1", func(_ *AgentConfig, w *inProcWorkers) { w.linger = 300 * time.Millisecond })
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
nudge := make(chan struct{}, 1)
go a.Run(ctx, nudge)
+ // A pass that meets that unit refuses admission by design (spec §5.7)
+ // and the read waits for a later pass. This test is about the nudge, so
+ // it nudges once the start probe has run and its unit is gone.
+ ready := time.Now().Add(10 * time.Second)
+ for !(w.dials.Load() >= 1 && w.live.Load() == 0 && a.Capable()) {
+ if time.Now().After(ready) {
+ t.Fatal("the start probe never finished")
+ }
+ time.Sleep(10 * time.Millisecond)
+ }
req := fx.request("SELECT count(*) FROM t", "")
fx.submit(req)
nudge <- struct{}{}