forked from TrueCloudLab/restic
Fix flaky test
This commit is contained in:
parent
553dd00741
commit
f9cd736b33
1 changed files with 5 additions and 3 deletions
|
@ -99,7 +99,7 @@ type Job struct {
|
||||||
func TestPoolCancel(t *testing.T) {
|
func TestPoolCancel(t *testing.T) {
|
||||||
barrier := make(chan struct{})
|
barrier := make(chan struct{})
|
||||||
|
|
||||||
wait := func(job worker.Job, done <-chan struct{}) (interface{}, error) {
|
sendTime := func(job worker.Job, done <-chan struct{}) (interface{}, error) {
|
||||||
j := job.Data.(Job)
|
j := job.Data.(Job)
|
||||||
|
|
||||||
<-barrier
|
<-barrier
|
||||||
|
@ -112,7 +112,7 @@ func TestPoolCancel(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jobCh, resCh, p := newBufferedPool(20, concurrency, wait)
|
jobCh, resCh, p := newBufferedPool(20, concurrency, sendTime)
|
||||||
|
|
||||||
suc := make(chan struct{})
|
suc := make(chan struct{})
|
||||||
for i := 0; i < 20; i++ {
|
for i := 0; i < 20; i++ {
|
||||||
|
@ -120,7 +120,9 @@ func TestPoolCancel(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
close(barrier)
|
close(barrier)
|
||||||
|
for i := 0; i < 10; i++ {
|
||||||
<-suc
|
<-suc
|
||||||
|
}
|
||||||
p.Cancel()
|
p.Cancel()
|
||||||
p.Wait()
|
p.Wait()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue