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:
@@ -38,7 +38,7 @@ func TestRunStartsTheWatcherEvenWhenStdinIsAtEOF(t *testing.T) {
|
||||
|
||||
select {
|
||||
case <-started:
|
||||
case <-time.After(time.Second):
|
||||
case <-time.After(30 * time.Second):
|
||||
t.Fatal("the watcher was not started before stdio.Serve returned")
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func TestRunStartsTheWatcherEvenWhenStdinIsAtEOF(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("run over stdin at EOF: %v", err)
|
||||
}
|
||||
case <-time.After(time.Second):
|
||||
case <-time.After(30 * time.Second):
|
||||
t.Fatal("run did not return once stdin reached EOF, as systemd gives a process nobody talks to")
|
||||
}
|
||||
|
||||
@@ -55,12 +55,12 @@ func TestRunStartsTheWatcherEvenWhenStdinIsAtEOF(t *testing.T) {
|
||||
// not yet torn down. A watcher that stopped when run returned would never take this ping.
|
||||
select {
|
||||
case ping <- struct{}{}:
|
||||
case <-time.After(time.Second):
|
||||
case <-time.After(30 * time.Second):
|
||||
t.Fatal("the watcher is no longer running once run returned: it must not stop just because stdio.Serve did")
|
||||
}
|
||||
select {
|
||||
case <-pong:
|
||||
case <-time.After(time.Second):
|
||||
case <-time.After(30 * time.Second):
|
||||
t.Fatal("the watcher did not answer once run returned")
|
||||
}
|
||||
close(ping)
|
||||
@@ -98,13 +98,13 @@ func TestWatchRetriesASubscribeRefusalWithBackoffAndNeverExits(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("run over stdin at EOF: %v", err)
|
||||
}
|
||||
case <-time.After(time.Second):
|
||||
case <-time.After(30 * time.Second):
|
||||
t.Fatal("run did not return once stdin reached EOF: a subscribe refusal must not hold up or kill the process")
|
||||
}
|
||||
|
||||
select {
|
||||
case <-subscribed:
|
||||
case <-time.After(time.Second):
|
||||
case <-time.After(30 * time.Second):
|
||||
t.Fatal("the watcher never subscribed after its first two refusals")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user