@@ -362,6 +362,7 @@ func TestScheduler_StopTimeout(t *testing.T) {
362362}
363363
364364func TestScheduler_StopLongRunningJobs (t * testing.T ) {
365+ defer verifyNoGoroutineLeaks (t )
365366 t .Run ("start, run job, stop jobs before job is completed" , func (t * testing.T ) {
366367 s := newTestScheduler (t ,
367368 WithStopTimeout (50 * time .Millisecond ),
@@ -393,6 +394,8 @@ func TestScheduler_StopLongRunningJobs(t *testing.T) {
393394 // the running job is canceled, no unexpected timeout error
394395 require .NoError (t , s .StopJobs ())
395396 time .Sleep (100 * time .Millisecond )
397+
398+ require .NoError (t , s .Shutdown ())
396399 })
397400 t .Run ("start, run job, stop jobs before job is completed - manual context cancel" , func (t * testing.T ) {
398401 s := newTestScheduler (t ,
@@ -428,6 +431,8 @@ func TestScheduler_StopLongRunningJobs(t *testing.T) {
428431 cancel ()
429432 require .NoError (t , s .StopJobs ())
430433 time .Sleep (100 * time .Millisecond )
434+
435+ require .NoError (t , s .Shutdown ())
431436 })
432437 t .Run ("start, run job, stop jobs before job is completed - manual context cancel WithContext" , func (t * testing.T ) {
433438 s := newTestScheduler (t ,
@@ -464,18 +469,18 @@ func TestScheduler_StopLongRunningJobs(t *testing.T) {
464469 cancel ()
465470 require .NoError (t , s .StopJobs ())
466471 time .Sleep (100 * time .Millisecond )
472+
473+ require .NoError (t , s .Shutdown ())
467474 })
468475}
469476
470477func TestScheduler_StopAndStartLongRunningJobs (t * testing.T ) {
478+ defer verifyNoGoroutineLeaks (t )
471479 t .Run ("start, run job, stop jobs before job is completed" , func (t * testing.T ) {
472480 s := newTestScheduler (t ,
473481 WithStopTimeout (50 * time .Millisecond ),
474482 )
475483
476- restart := false
477- restartP := & restart
478-
479484 _ , err := s .NewJob (
480485 DurationJob (
481486 50 * time .Millisecond ,
@@ -484,14 +489,7 @@ func TestScheduler_StopAndStartLongRunningJobs(t *testing.T) {
484489 func (ctx context.Context ) {
485490 select {
486491 case <- ctx .Done ():
487- if * restartP {
488- t .Fatal ("job should not been canceled after restart" )
489- }
490492 case <- time .After (100 * time .Millisecond ):
491- if ! * restartP {
492- t .Fatal ("job can not been canceled" )
493- }
494-
495493 }
496494 },
497495 ),
@@ -508,11 +506,10 @@ func TestScheduler_StopAndStartLongRunningJobs(t *testing.T) {
508506 // the running job is canceled, no unexpected timeout error
509507 require .NoError (t , s .StopJobs ())
510508
511- * restartP = true
512-
513509 s .Start ()
514510
515511 time .Sleep (200 * time .Millisecond )
512+ require .NoError (t , s .Shutdown ())
516513 })
517514}
518515
0 commit comments