activator: the resident lease tests end their held drains on failure, so a missing watch or kill fails fast instead of hanging Shutdown
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+7
−2
internal/activator/rootfs_resident_lease_test.go+7 −2
diff --git a/internal/activator/rootfs_resident_lease_test.go b/internal/activator/rootfs_resident_lease_test.go| index 0df7f7c9d..ecc25fd49 100644 |
| --- a/internal/activator/rootfs_resident_lease_test.go |
| +++ b/internal/activator/rootfs_resident_lease_test.go |
| @@ -159,8 +159,10 @@ func TestResidentLeaseHangStopsBeforeTheDeadline(t *testing.T) { |
| proc.onStopEnter = func() { stopBegan <- time.Now() } |
| proc.mu.Unlock() |
| var killOnce sync.Once |
| + endDrain := func() { killOnce.Do(func() { proc.exit(); close(drain) }) } |
| + t.Cleanup(endDrain) // a failure below must not leave Shutdown waiting on the drain |
| kb.kmu.Lock() |
| - kb.onKill = func(uint64) { killOnce.Do(func() { proc.exit(); close(drain) }) } // SIGKILL ends the drain |
| + kb.onKill = func(uint64) { endDrain() } // SIGKILL ends the drain |
| kb.kmu.Unlock() |
| var began time.Time |
| @@ -207,6 +209,9 @@ func TestResidentLeaseLossKillsAtOnce(t *testing.T) { |
| proc := kb.lastProc() |
| drain := make(chan struct{}) |
| proc.setStopGate(drain) |
| + var drained sync.Once |
| + endDrain := func() { drained.Do(func() { close(drain) }) } |
| + t.Cleanup(func() { proc.exit(); endDrain() }) // a failure below must not leave Shutdown waiting |
| kb.kmu.Lock() |
| kb.onKill = func(uint64) { proc.exit() } |
| kb.kmu.Unlock() |
| @@ -219,7 +224,7 @@ func TestResidentLeaseLossKillsAtOnce(t *testing.T) { |
| if proc.stopCalls() != 0 { |
| t.Fatal("the drain finished before the kill: the kill did not wait for nothing") |
| } |
| - close(drain) |
| + endDrain() |
| waitFor(t, "the stop to finish", func() bool { return !a.hasEntry(host) }) |
| if st, _ := a.residentOf(host); st.failures != 1 { |
| t.Fatalf("a lost lease: %+v, want one failure", st) |