Skip to content

Commit a541000

Browse files
author
Timo Reimann
committed
Shut down test driver properly
1 parent 8a4c5f8 commit a541000

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

driver/driver_test.go

+10-8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/digitalocean/godo"
3030
"github.com/kubernetes-csi/csi-test/pkg/sanity"
3131
"github.com/sirupsen/logrus"
32+
"golang.org/x/sync/errgroup"
3233
)
3334

3435
func init() {
@@ -83,22 +84,23 @@ func TestDriverSuite(t *testing.T) {
8384
}
8485

8586
ctx, cancel := context.WithCancel(context.Background())
86-
defer cancel()
8787

88-
go func() {
89-
err := driver.Run(ctx)
90-
if err != nil {
91-
t.Error(err)
92-
}
93-
}()
88+
var eg errgroup.Group
89+
eg.Go(func() error {
90+
return driver.Run(ctx)
91+
})
9492

9593
cfg := &sanity.Config{
9694
TargetPath: os.TempDir() + "/csi-target",
9795
StagingPath: os.TempDir() + "/csi-staging",
9896
Address: endpoint,
9997
}
100-
10198
sanity.Test(t, cfg)
99+
100+
cancel()
101+
if err := eg.Wait(); err != nil {
102+
t.Errorf("driver run failed: %s", err)
103+
}
102104
}
103105

104106
type fakeAccountDriver struct{}

0 commit comments

Comments
 (0)