summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josh@tailscale.com>2022-01-13 15:49:34 -0800
committerJosh Bleecher Snyder <josharian@gmail.com>2022-01-13 16:48:29 -0800
commit8cf1af8a0703c36256fc58e98ddb63b8907848f1 (patch)
tree5d79eae8bf6ec5c4a17776650e662d66d16ae30a
parent463b3e8f62e86055c520d17643c2347240ebf68e (diff)
downloadtailscale-Xe/winui-bugreport-without-tailscaled.tar.xz
tailscale-Xe/winui-bugreport-without-tailscaled.zip
tstime/rate: deflake TestLongRunningQPSXe/winui-bugreport-without-tailscaled
This test set the bar too high. Just a couple of missed timers was enough to fail. Change the test to more of a sanity check. While we're here, run it for just 1s instead of 5s. Prior to this change, on a 13" M1 MPB, with stress -p 512 ./rate.test -test.run=QPS I saw 90%+ failures. After this change, I'm at 30k runs with no failures yet. Fixes #3733 Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
-rw-r--r--tstime/rate/rate_test.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/tstime/rate/rate_test.go b/tstime/rate/rate_test.go
index fc4d1e115..3e74cf6db 100644
--- a/tstime/rate/rate_test.go
+++ b/tstime/rate/rate_test.go
@@ -185,7 +185,7 @@ func TestLongRunningQPS(t *testing.T) {
// This will still offer ~500 requests per second,
// but won't consume outrageous amount of CPU.
start := time.Now()
- end := start.Add(5 * time.Second)
+ end := start.Add(1 * time.Second)
ticker := time.NewTicker(2 * time.Millisecond)
defer ticker.Stop()
for now := range ticker.C {
@@ -203,8 +203,9 @@ func TestLongRunningQPS(t *testing.T) {
if want := int32(ideal + 1); numOK > want {
t.Errorf("numOK = %d, want %d (ideal %f)", numOK, want, ideal)
}
- // We should get very close to the number of requests allowed.
- if want := int32(0.995 * ideal); numOK < want {
+ // We should get close-ish to the number of requests allowed.
+ // Trying to get too close causes flakes. Treat this as a sanity check.
+ if want := int32(0.9 * ideal); numOK < want {
t.Errorf("numOK = %d, want %d (ideal %f)", numOK, want, ideal)
}
}