diff --git a/test/integration/framework/etcd.go b/test/integration/framework/etcd.go index d816f623dca..9f2f4b943c2 100644 --- a/test/integration/framework/etcd.go +++ b/test/integration/framework/etcd.go @@ -26,6 +26,7 @@ import ( "os/exec" "strconv" "strings" + "sync" "syscall" "testing" "time" @@ -146,7 +147,10 @@ func RunCustomEtcd(dataDir string, customFlags []string, output io.Writer) (url // try to exit etcd gracefully defer cancel() cmd.Process.Signal(syscall.SIGTERM) + var wg sync.WaitGroup + wg.Add(1) go func() { + defer wg.Done() select { case <-ctx.Done(): klog.Infof("etcd exited gracefully, context cancelled") @@ -156,6 +160,7 @@ func RunCustomEtcd(dataDir string, customFlags []string, output io.Writer) (url } }() err := cmd.Wait() + wg.Wait() klog.Infof("etcd exit status: %v", err) err = os.RemoveAll(etcdDataDir) if err != nil {