diff --git a/cmd/dynamic-timeouts_test.go b/cmd/dynamic-timeouts_test.go index b353b983b..dd0e306c2 100644 --- a/cmd/dynamic-timeouts_test.go +++ b/cmd/dynamic-timeouts_test.go @@ -180,12 +180,14 @@ func testDynamicTimeoutAdjust(t *testing.T, timeout *dynamicTimeout, f func() fl func TestDynamicTimeoutAdjustExponential(t *testing.T) { timeout := newDynamicTimeout(time.Minute, time.Second) - rand.Seed(0) + // A private source keeps the sample independent of other tests that use + // the global generator concurrently. + rng := rand.New(rand.NewSource(0)) initial := timeout.Timeout() for range 10 { - testDynamicTimeoutAdjust(t, timeout, rand.ExpFloat64) + testDynamicTimeoutAdjust(t, timeout, rng.ExpFloat64) } adjusted := timeout.Timeout() @@ -197,13 +199,13 @@ func TestDynamicTimeoutAdjustExponential(t *testing.T) { func TestDynamicTimeoutAdjustNormalized(t *testing.T) { timeout := newDynamicTimeout(time.Minute, time.Second) - rand.Seed(0) + rng := rand.New(rand.NewSource(0)) initial := timeout.Timeout() for range 10 { testDynamicTimeoutAdjust(t, timeout, func() float64 { - return 1.0 + rand.NormFloat64() + return 1.0 + rng.NormFloat64() }) }