@@ -13,6 +13,7 @@ import (
13
13
"encoding/json"
14
14
"fmt"
15
15
"log"
16
+ "runtime"
16
17
"runtime/debug"
17
18
"sort"
18
19
"strconv"
@@ -3363,6 +3364,12 @@ func TestUpdateCalculatedStatsPanic(t *testing.T) {
3363
3364
}
3364
3365
3365
3366
func Test_waitForBackgroundManagersToStop (t * testing.T ) {
3367
+ // use testing/synctest to have fake time once go 1.25 is available. In the meantime, windows and -race are
3368
+ // slow enough thatthe time is increased, but this keeps interactive testing fast.
3369
+ waitTime := 50 * time .Millisecond
3370
+ if runtime .GOOS == "windows" || base .IsRaceDetectorEnabled (t ) {
3371
+ waitTime = 1 * time .Second
3372
+ }
3366
3373
t .Run ("single unstoppable process" , func (t * testing.T ) {
3367
3374
bgMngr := & BackgroundManager {
3368
3375
name : "test_unstoppable_runner" ,
@@ -3375,7 +3382,7 @@ func Test_waitForBackgroundManagersToStop(t *testing.T) {
3375
3382
require .NoError (t , err )
3376
3383
3377
3384
startTime := time .Now ()
3378
- deadline := 50 * time . Millisecond
3385
+ deadline := waitTime
3379
3386
waitForBackgroundManagersToStop (ctx , deadline , []* BackgroundManager {bgMngr })
3380
3387
assert .Greater (t , time .Since (startTime ), deadline )
3381
3388
assert .Equal (t , BackgroundProcessStateStopping , bgMngr .GetRunState ())
@@ -3393,7 +3400,7 @@ func Test_waitForBackgroundManagersToStop(t *testing.T) {
3393
3400
require .NoError (t , err )
3394
3401
3395
3402
startTime := time .Now ()
3396
- deadline := 100 * time . Millisecond
3403
+ deadline := waitTime
3397
3404
waitForBackgroundManagersToStop (ctx , deadline , []* BackgroundManager {bgMngr })
3398
3405
assert .Less (t , time .Since (startTime ), deadline )
3399
3406
assert .Equal (t , BackgroundProcessStateStopped , bgMngr .GetRunState ())
@@ -3421,7 +3428,7 @@ func Test_waitForBackgroundManagersToStop(t *testing.T) {
3421
3428
require .NoError (t , err )
3422
3429
3423
3430
startTime := time .Now ()
3424
- deadline := 100 * time . Millisecond
3431
+ deadline := waitTime
3425
3432
waitForBackgroundManagersToStop (ctx , deadline , []* BackgroundManager {stoppableBgMngr , unstoppableBgMngr })
3426
3433
assert .Greater (t , time .Since (startTime ), deadline )
3427
3434
assert .Equal (t , BackgroundProcessStateStopped , stoppableBgMngr .GetRunState ())
0 commit comments