Merge pull request #78132 from gnufied/fix-goroutie-wait

Wait for waitforattach goroutine before exiting
k3s-v1.15.3
Kubernetes Prow Robot 2019-05-21 08:24:52 -07:00 committed by GitHub
commit 13c11de135
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -21,6 +21,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"sync"
"testing"
"time"
@ -360,9 +361,12 @@ func TestAttacherWithCSIDriver(t *testing.T) {
t.Log("plugin is not attachable")
return
}
var wg sync.WaitGroup
wg.Add(1)
go func(volSpec *volume.Spec, expectAttach bool) {
attachID, err := csiAttacher.Attach(volSpec, types.NodeName("node"))
defer wg.Done()
if err != nil {
t.Errorf("Attach() failed: %s", err)
}
@ -378,6 +382,7 @@ func TestAttacherWithCSIDriver(t *testing.T) {
}
markVolumeAttached(t, csiAttacher.k8s, fakeWatcher, expectedAttachID, status)
}
wg.Wait()
})
}
}