]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/pprof: deflake tests for heavily loaded systems
authorIan Lance Taylor <iant@golang.org>
Fri, 16 Dec 2016 01:42:53 +0000 (17:42 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 16 Dec 2016 15:17:36 +0000 (15:17 +0000)
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>
src/runtime/pprof/pprof_test.go

index fd0660780584807909ddedd9e21cad8c0b9aa0f0..2a242a151e20af558214cd433bee90992beeafe5 100644 (file)
@@ -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
        }