mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
fix(scheduler): fix a data race in the scheduler EE-2716 (#6629)
This commit is contained in:
parent
ecf5e90783
commit
78150a738f
2 changed files with 26 additions and 0 deletions
|
@ -2,6 +2,7 @@ package scheduler
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -101,3 +102,19 @@ func Test_CanTerminateAllJobs_ByCancellingParentContext(t *testing.T) {
|
|||
<-ctx.Done()
|
||||
assert.False(t, workDone, "job shouldn't had a chance to run")
|
||||
}
|
||||
|
||||
func Test_StartJobEvery_Concurrently(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*jobInterval)
|
||||
s := NewScheduler(ctx)
|
||||
|
||||
f := func() error {
|
||||
return errors.New("error")
|
||||
}
|
||||
|
||||
go s.StartJobEvery(jobInterval, f)
|
||||
s.StartJobEvery(jobInterval, f)
|
||||
|
||||
cancel()
|
||||
|
||||
<-ctx.Done()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue