]> Cypherpunks repositories - gostls13.git/commit
internal/singleflight: deflake TestDoDupSuppress
authorAustin Clements <austin@google.com>
Sun, 26 Jul 2015 20:03:13 +0000 (16:03 -0400)
committerAustin Clements <austin@google.com>
Sun, 26 Jul 2015 20:35:09 +0000 (20:35 +0000)
commite3ba0977beacc018fe9136284507298ce2d5e829
treebf21926f049e6bbe4a183dd711435d784db8428f
parent9b7e728ee8ddacad70cbf5bced36c8f72af65f38
internal/singleflight: deflake TestDoDupSuppress

Currently TestDoDupSuppress can fail if the goroutines created by its
loop run sequentially. This is rare, but it has caused failures on the
dashboard and in stress testing.

While I think there's no way to eliminate all possible thread
schedules that could make this test fail because it depends on waiting
until a Group.Do blocks, it is possible to make it much more robust.

This commit deflakes this test by forcing at least one invocation of
fn to start and all goroutines to reach the line just before the Do
call before allowing fn to proceed. fn then waits 10 milliseconds
before returning to allow the goroutines to pass through the Do.

With this change, in 50,000 runs of the stress testing configuration,
the number of calls to fn never even exceeded 1.

Fixes #11784.

Change-Id: Ie5adf5764545050ec407619769a656251c4cff04
Reviewed-on: https://go-review.googlesource.com/12681
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/internal/singleflight/singleflight_test.go