mirror of https://github.com/hashicorp/consul
tests: fix zombie consul process while invoking TestServer.Stop() method in sdk/testutil in Windows (#6032)
* Fix zombie consul process in Windows Windows doesn't support Interrupt signal, thus while stop it on Windows platform it would fail and left zombie consul processpull/7109/head
parent
7b17f789d3
commit
04305be555
|
@ -26,6 +26,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
"runtime"
|
||||
|
||||
"github.com/hashicorp/consul/sdk/freeport"
|
||||
"github.com/hashicorp/consul/sdk/testutil/retry"
|
||||
|
@ -350,8 +351,14 @@ func (s *TestServer) Stop() error {
|
|||
}
|
||||
|
||||
if s.cmd.Process != nil {
|
||||
if err := s.cmd.Process.Signal(os.Interrupt); err != nil {
|
||||
return errors.Wrap(err, "failed to kill consul server")
|
||||
if runtime.GOOS == "windows" {
|
||||
if err := s.cmd.Process.Kill(); err != nil {
|
||||
return errors.Wrap(err, "failed to kill consul server")
|
||||
}
|
||||
} else { // interrupt is not supported in windows
|
||||
if err := s.cmd.Process.Signal(os.Interrupt); err != nil {
|
||||
return errors.Wrap(err, "failed to kill consul server")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue