mirror of
https://github.com/status-im/consul.git
synced 2025-02-23 10:58:25 +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"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"github.com/hashicorp/consul/sdk/freeport"
|
"github.com/hashicorp/consul/sdk/freeport"
|
||||||
"github.com/hashicorp/consul/sdk/testutil/retry"
|
"github.com/hashicorp/consul/sdk/testutil/retry"
|
||||||
@ -350,10 +351,16 @@ func (s *TestServer) Stop() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if s.cmd.Process != nil {
|
if s.cmd.Process != nil {
|
||||||
|
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 {
|
if err := s.cmd.Process.Signal(os.Interrupt); err != nil {
|
||||||
return errors.Wrap(err, "failed to kill consul server")
|
return errors.Wrap(err, "failed to kill consul server")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// wait for the process to exit to be sure that the data dir can be
|
// wait for the process to exit to be sure that the data dir can be
|
||||||
// deleted on all platforms.
|
// deleted on all platforms.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user