From c90380f3ddfcf199796c285466061948e97f6406 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 27 Jul 2026 13:07:06 +0000 Subject: [PATCH] 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 Change-Id: I673a4918bbb5fea6b650e0dc1bc491c4af922b19 --- prober/prober_test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/prober/prober_test.go b/prober/prober_test.go index 14b75d5b5..80c85ccb5 100644 --- a/prober/prober_test.go +++ b/prober/prober_test.go @@ -205,11 +205,14 @@ func TestProberConcurrency(t *testing.T) { p.Run("foo", time.Second, nil, pfunc) waitActiveProbes(t, p, clk, 1) - for range 50 { - clk.Advance(time.Second) - } - + // The fake ticker drops ticks when the probe loop goroutine isn't + // 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 { + clk.Advance(time.Second) if got, want := ran.Load(), int64(3); got != want { return fmt.Errorf("expected %d probes to run concurrently, got %d", want, got) }