Make tests that wait for concurrent work wait on the event or a condition with a long deadline (issue 1814)

A test that slept a fixed time and then asserted what a goroutine, process or
watcher did failed under the checker's load. Each now waits for its positive
evidence (a started baseline, a call counted, a state reached) within 30 s, and
the concurrency-limit tests meet at a barrier instead of overlapping by sleep.

Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
This commit is contained in:
2026-11-01 17:24:19 +01:00
parent 3d1a450406
commit b3fcf408f2
52 changed files with 144 additions and 91 deletions
+5 -3
View File
@@ -26,11 +26,11 @@ func TestATimedOutCommandIsEndedWithItsChildren(t *testing.T) {
KillGrace = 300 * time.Millisecond
defer func() { KillGrace = old }()
pidFile := filepath.Join(t.TempDir(), "child")
ctx, cancel := context.WithTimeout(context.Background(), 300*time.Millisecond)
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) // long enough for a loaded machine to start the shell and write the pid
defer cancel()
start := time.Now()
r := ExecRunner(ctx, "sh", "-c", "sleep 30 & echo $! > "+pidFile+"; wait")
if took := time.Since(start); took > 5*time.Second {
if took := time.Since(start); took > 30*time.Second {
t.Fatalf("the call waited %s for a child holding its output", took)
}
if !r.TimedOut {
@@ -41,7 +41,9 @@ func TestATimedOutCommandIsEndedWithItsChildren(t *testing.T) {
t.Fatal(err)
}
pid, _ := strconv.Atoi(strings.TrimSpace(string(b)))
time.Sleep(100 * time.Millisecond)
// the kill is sent before the answer; give the system up to 30 s to take the child away
for end := time.Now().Add(30 * time.Second); time.Now().Before(end) && syscall.Kill(pid, 0) == nil; time.Sleep(10 * time.Millisecond) {
}
if err := syscall.Kill(pid, 0); err == nil {
syscall.Kill(pid, syscall.SIGKILL)
t.Errorf("the child %d outlived the timeout", pid)