Wait for waitforattach goroutine before exiting
This test suite fails in weird ways without waiting for the goroutine
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -360,9 +361,12 @@ func TestAttacherWithCSIDriver(t *testing.T) {
|
|||||||
t.Log("plugin is not attachable")
|
t.Log("plugin is not attachable")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
wg.Add(1)
|
||||||
go func(volSpec *volume.Spec, expectAttach bool) {
|
go func(volSpec *volume.Spec, expectAttach bool) {
|
||||||
attachID, err := csiAttacher.Attach(volSpec, types.NodeName("node"))
|
attachID, err := csiAttacher.Attach(volSpec, types.NodeName("node"))
|
||||||
|
defer wg.Done()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Attach() failed: %s", err)
|
t.Errorf("Attach() failed: %s", err)
|
||||||
}
|
}
|
||||||
@@ -378,6 +382,7 @@ func TestAttacherWithCSIDriver(t *testing.T) {
|
|||||||
}
|
}
|
||||||
markVolumeAttached(t, csiAttacher.k8s, fakeWatcher, expectedAttachID, status)
|
markVolumeAttached(t, csiAttacher.k8s, fakeWatcher, expectedAttachID, status)
|
||||||
}
|
}
|
||||||
|
wg.Wait()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user