From 0ab6bdfa368706df83bd72499662ef6704da73de Mon Sep 17 00:00:00 2001 From: Hemant Kumar Date: Mon, 20 May 2019 16:16:16 -0400 Subject: [PATCH] Wait for waitforattach goroutine before exiting This test suite fails in weird ways without waiting for the goroutine --- pkg/volume/csi/csi_attacher_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/volume/csi/csi_attacher_test.go b/pkg/volume/csi/csi_attacher_test.go index ebf71093a44..bfbf0779057 100644 --- a/pkg/volume/csi/csi_attacher_test.go +++ b/pkg/volume/csi/csi_attacher_test.go @@ -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() }) } }