File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -1226,13 +1226,21 @@ func TestJitterCalculation(t *testing.T) {
12261226 },
12271227 } {
12281228 t .Run (test .name , func (t * testing.T ) {
1229- interval := jitter (test .input )
1229+ interval := test .input
1230+ testutils .SucceedsSoon (t , func () error {
1231+ interval = jitter (test .input )
1232+ // This check will sometimes fail due to a randomly picking a value
1233+ // that rounds to 1/2. The frequency of this is a bit higher than one
1234+ // would expect because the rounding behavior depends on the width of
1235+ // the duration, not the width of a float64.
1236+ if interval == test .input && test .input != 0 {
1237+ return errors .New ("jitter returned same value as input" )
1238+ }
1239+ return nil
1240+ })
12301241 rangeMin , rangeMax := outputRange (test .input )
12311242 require .GreaterOrEqual (t , rangeMax , interval )
12321243 require .LessOrEqual (t , rangeMin , interval )
1233- if test .input != 0 {
1234- require .NotEqual (t , test .input , interval )
1235- }
12361244 })
12371245 }
12381246}
You can’t perform that action at this time.
0 commit comments