diff options
| author | Bryan C. Mills <bcmills@google.com> | 2020-04-08 16:28:33 -0400 |
|---|---|---|
| committer | Bryan C. Mills <bcmills@google.com> | 2020-04-08 21:43:14 +0000 |
| commit | ddfc55b076d945f215875d6b65c36fc53b332cc1 (patch) | |
| tree | 94f85db0291f8db9a7ffe3d6e312ce70407f609f /src | |
| parent | 7694bf329d89c15d34e9b58d48de472ec50d537a (diff) | |
| download | go-ddfc55b076d945f215875d6b65c36fc53b332cc1.tar.xz | |
os/signal: increase settle time in tests
I noticed a timeout in TestIgnore in
https://build.golang.org/log/52d83a72f3a5ea9a16eb5d670c729694144f9624,
which suggests that the settle time is currently set too low.
I've also added a check for the same GO_TEST_TIMEOUT_SCALE used in
TestTerminalSignal, so that if this builder remains too slow we can
increase the builder's scale factor rather than the test's baseline
running time.
Updates #33174
Change-Id: I18b10eaa3bb5ae2f604300aedaaf6f79ee7ad567
Reviewed-on: https://go-review.googlesource.com/c/go/+/227649
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/os/signal/signal_test.go | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/os/signal/signal_test.go b/src/os/signal/signal_test.go index e5dcda4a2b..50e21d4e64 100644 --- a/src/os/signal/signal_test.go +++ b/src/os/signal/signal_test.go @@ -25,16 +25,30 @@ import ( // settleTime is an upper bound on how long we expect signals to take to be // delivered. Lower values make the test faster, but also flakier — especially // on heavily loaded systems. -const settleTime = 100 * time.Millisecond +// +// The current value is set based on flakes observed in the Go builders. +var settleTime = 250 * time.Millisecond + +func init() { + if s := os.Getenv("GO_TEST_TIMEOUT_SCALE"); s != "" { + if scale, err := strconv.Atoi(s); err == nil { + settleTime *= time.Duration(scale) + } + } +} func waitSig(t *testing.T, c <-chan os.Signal, sig os.Signal) { + t.Helper() waitSig1(t, c, sig, false) } func waitSigAll(t *testing.T, c <-chan os.Signal, sig os.Signal) { + t.Helper() waitSig1(t, c, sig, true) } func waitSig1(t *testing.T, c <-chan os.Signal, sig os.Signal, all bool) { + t.Helper() + // Sleep multiple times to give the kernel more tries to // deliver the signal. start := time.Now() @@ -58,7 +72,7 @@ func waitSig1(t *testing.T, c <-chan os.Signal, sig os.Signal, all bool) { timer.Reset(settleTime / 10) } } - t.Fatalf("timeout waiting for %v", sig) + t.Fatalf("timeout after %v waiting for %v", settleTime, sig) } // quiesce waits until we can be reasonably confident that all pending signals |
