mirror of
https://github.com/status-im/consul.git
synced 2025-02-22 18:38:19 +00:00
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 process
This commit is contained in:
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…
x
Reference in New Issue
Block a user