@@ -362,6 +362,7 @@ func TestScheduler_StopTimeout(t *testing.T) {
362
362
}
363
363
364
364
func TestScheduler_StopLongRunningJobs (t * testing.T ) {
365
+ defer verifyNoGoroutineLeaks (t )
365
366
t .Run ("start, run job, stop jobs before job is completed" , func (t * testing.T ) {
366
367
s := newTestScheduler (t ,
367
368
WithStopTimeout (50 * time .Millisecond ),
@@ -393,6 +394,8 @@ func TestScheduler_StopLongRunningJobs(t *testing.T) {
393
394
// the running job is canceled, no unexpected timeout error
394
395
require .NoError (t , s .StopJobs ())
395
396
time .Sleep (100 * time .Millisecond )
397
+
398
+ require .NoError (t , s .Shutdown ())
396
399
})
397
400
t .Run ("start, run job, stop jobs before job is completed - manual context cancel" , func (t * testing.T ) {
398
401
s := newTestScheduler (t ,
@@ -428,6 +431,8 @@ func TestScheduler_StopLongRunningJobs(t *testing.T) {
428
431
cancel ()
429
432
require .NoError (t , s .StopJobs ())
430
433
time .Sleep (100 * time .Millisecond )
434
+
435
+ require .NoError (t , s .Shutdown ())
431
436
})
432
437
t .Run ("start, run job, stop jobs before job is completed - manual context cancel WithContext" , func (t * testing.T ) {
433
438
s := newTestScheduler (t ,
@@ -464,18 +469,18 @@ func TestScheduler_StopLongRunningJobs(t *testing.T) {
464
469
cancel ()
465
470
require .NoError (t , s .StopJobs ())
466
471
time .Sleep (100 * time .Millisecond )
472
+
473
+ require .NoError (t , s .Shutdown ())
467
474
})
468
475
}
469
476
470
477
func TestScheduler_StopAndStartLongRunningJobs (t * testing.T ) {
478
+ defer verifyNoGoroutineLeaks (t )
471
479
t .Run ("start, run job, stop jobs before job is completed" , func (t * testing.T ) {
472
480
s := newTestScheduler (t ,
473
481
WithStopTimeout (50 * time .Millisecond ),
474
482
)
475
483
476
- restart := false
477
- restartP := & restart
478
-
479
484
_ , err := s .NewJob (
480
485
DurationJob (
481
486
50 * time .Millisecond ,
@@ -484,14 +489,7 @@ func TestScheduler_StopAndStartLongRunningJobs(t *testing.T) {
484
489
func (ctx context.Context ) {
485
490
select {
486
491
case <- ctx .Done ():
487
- if * restartP {
488
- t .Fatal ("job should not been canceled after restart" )
489
- }
490
492
case <- time .After (100 * time .Millisecond ):
491
- if ! * restartP {
492
- t .Fatal ("job can not been canceled" )
493
- }
494
-
495
493
}
496
494
},
497
495
),
@@ -508,11 +506,10 @@ func TestScheduler_StopAndStartLongRunningJobs(t *testing.T) {
508
506
// the running job is canceled, no unexpected timeout error
509
507
require .NoError (t , s .StopJobs ())
510
508
511
- * restartP = true
512
-
513
509
s .Start ()
514
510
515
511
time .Sleep (200 * time .Millisecond )
512
+ require .NoError (t , s .Shutdown ())
516
513
})
517
514
}
518
515
0 commit comments