From 460900a7b51f917888cb17608367979243178fe1 Mon Sep 17 00:00:00 2001 From: "Andrew G. Morgan" Date: Sat, 19 Jun 2021 09:46:52 -0700 Subject: [PATCH] os/signal: test with a significantly longer fatal timeout We've observed some occasional os-arch specific timeouts in signal.TestSignalTrace(). While the main purpose of a short timeout is to ensure the passing tests complete quickly, the unexpected failure path can tolerate waiting longer (the test is not intended to test how slow or overloaded the OS is at the time it is run). Fixes #46736 Change-Id: Ib392fc6ce485a919612784ca88ed76c30f4898e2 Reviewed-on: https://go-review.googlesource.com/c/go/+/329502 Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor Reviewed-by: Emmanuel Odeke Trust: Emmanuel Odeke --- src/os/signal/signal_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/os/signal/signal_test.go b/src/os/signal/signal_test.go index cea68742d264b9..649854b746c149 100644 --- a/src/os/signal/signal_test.go +++ b/src/os/signal/signal_test.go @@ -32,6 +32,11 @@ import ( // The current value is set based on flakes observed in the Go builders. var settleTime = 100 * time.Millisecond +// fatalWaitingTime is an absurdly long time to wait for signals to be +// delivered but, using it, we (hopefully) eliminate test flakes on the +// build servers. See #46736 for discussion. +var fatalWaitingTime = 30 * time.Second + func init() { if testenv.Builder() == "solaris-amd64-oraclerel" { // The solaris-amd64-oraclerel builder has been observed to time out in @@ -84,7 +89,7 @@ func waitSig1(t *testing.T, c <-chan os.Signal, sig os.Signal, all bool) { // General user code should filter out all unexpected signals instead of just // SIGURG, but since os/signal is tightly coupled to the runtime it seems // appropriate to be stricter here. - for time.Since(start) < settleTime { + for time.Since(start) < fatalWaitingTime { select { case s := <-c: if s == sig { @@ -97,7 +102,7 @@ func waitSig1(t *testing.T, c <-chan os.Signal, sig os.Signal, all bool) { timer.Reset(settleTime / 10) } } - t.Fatalf("timeout after %v waiting for %v", settleTime, sig) + t.Fatalf("timeout after %v waiting for %v", fatalWaitingTime, sig) } // quiesce waits until we can be reasonably confident that all pending signals