]> Cypherpunks repositories - gostls13.git/commitdiff
os/signal: increase settle time in tests
authorBryan C. Mills <bcmills@google.com>
Wed, 8 Apr 2020 20:28:33 +0000 (16:28 -0400)
committerBryan C. Mills <bcmills@google.com>
Wed, 8 Apr 2020 21:43:14 +0000 (21:43 +0000)
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>
src/os/signal/signal_test.go

index e5dcda4a2b668370730c8e1bba2648485ad485e6..50e21d4e643a6bdc9f8df1a29b94efa3ddbd9903 100644 (file)
@@ -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