prober: deflake TestProberConcurrency
The fake ticker has a one-element channel buffer and drops ticks when the probe loop goroutine isn't already blocked on the channel, so advancing the fake clock 50 times in a tight loop didn't guarantee that the loop observed enough ticks to start three concurrent probe runs. Under CI load, only two of the three run goroutines could be spawned before the convergence timeout expired. Advance the clock inside the polling loop instead, so ticks keep firing until all three probe goroutines have started. Verified with flakestress: the old test failed within ~41k runs, while the fixed test passed 175,214 runs with no failures. See http://flakes/analyze-test?name=tailscale.com%2Fprober.TestProberConcurrency Updates #deflake Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com> Change-Id: I673a4918bbb5fea6b650e0dc1bc491c4af922b19
This commit is contained in:
committed by
Brad Fitzpatrick
parent
420a8e5a1a
commit
c90380f3dd
@@ -205,11 +205,14 @@ func TestProberConcurrency(t *testing.T) {
|
|||||||
p.Run("foo", time.Second, nil, pfunc)
|
p.Run("foo", time.Second, nil, pfunc)
|
||||||
waitActiveProbes(t, p, clk, 1)
|
waitActiveProbes(t, p, clk, 1)
|
||||||
|
|
||||||
for range 50 {
|
// The fake ticker drops ticks when the probe loop goroutine isn't
|
||||||
clk.Advance(time.Second)
|
// already blocked on its channel (buffer of one, non-blocking send),
|
||||||
}
|
// so advancing the clock in a tight loop doesn't guarantee that the
|
||||||
|
// loop observes enough ticks to start three concurrent probe runs.
|
||||||
|
// Instead, advance the clock inside the polling loop so ticks keep
|
||||||
|
// firing until all three probe goroutines have started.
|
||||||
if err := tstest.WaitFor(convergenceTimeout, func() error {
|
if err := tstest.WaitFor(convergenceTimeout, func() error {
|
||||||
|
clk.Advance(time.Second)
|
||||||
if got, want := ran.Load(), int64(3); got != want {
|
if got, want := ran.Load(), int64(3); got != want {
|
||||||
return fmt.Errorf("expected %d probes to run concurrently, got %d", want, got)
|
return fmt.Errorf("expected %d probes to run concurrently, got %d", want, got)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user