aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2016-12-15 17:42:53 -0800
committerBrad Fitzpatrick <bradfitz@golang.org>2016-12-16 15:17:36 +0000
commitecc4474341504f5893c8333dbb68c520dbe93ca5 (patch)
tree2d2d62912d2cc3f6ac6a8198b7eaf82b876f7013
parent115e9cac8033163a6edfdce6b28a9be21475bed5 (diff)
downloadgo-ecc4474341504f5893c8333dbb68c520dbe93ca5.tar.gz
go-ecc4474341504f5893c8333dbb68c520dbe93ca5.zip
runtime/pprof: deflake tests for heavily loaded systems
In the sampling tests, let the test pass if we get at least 10 samples. Fixes #18332. Change-Id: I8aad083d1a0ba179ad6663ff43f6b6b3ce1e18cd Reviewed-on: https://go-review.googlesource.com/34507 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r--src/runtime/pprof/pprof_test.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go
index fd06607805..2a242a151e 100644
--- a/src/runtime/pprof/pprof_test.go
+++ b/src/runtime/pprof/pprof_test.go
@@ -204,7 +204,11 @@ func profileOk(t *testing.T, need []string, prof bytes.Buffer, duration time.Dur
}
// Check that we got a reasonable number of samples.
- if ideal := uintptr(duration * 100 / time.Second); samples == 0 || samples < ideal/4 {
+ // We used to always require at least ideal/4 samples,
+ // but that is too hard to guarantee on a loaded system.
+ // Now we accept 10 or more samples, which we take to be
+ // enough to show that at least some profiling is ocurring.
+ if ideal := uintptr(duration * 100 / time.Second); samples == 0 || (samples < ideal/4 && samples < 10) {
t.Logf("too few samples; got %d, want at least %d, ideally %d", samples, ideal/4, ideal)
ok = false
}