mirror of
https://github.com/status-im/consul.git
synced 2025-02-02 08:56:43 +00:00
Make testutil.TestServer work correctly on Windows.
This commit is contained in:
parent
5d0d61349e
commit
556f20b8c3
@ -127,7 +127,7 @@ type TestKVResponse struct {
|
||||
|
||||
// TestServer is the main server wrapper struct.
|
||||
type TestServer struct {
|
||||
PID int
|
||||
cmd *exec.Cmd
|
||||
Config *TestServerConfig
|
||||
t TestingT
|
||||
|
||||
@ -215,7 +215,7 @@ func NewTestServerConfig(t TestingT, cb ServerConfigCallback) *TestServer {
|
||||
|
||||
server := &TestServer{
|
||||
Config: consulConfig,
|
||||
PID: cmd.Process.Pid,
|
||||
cmd: cmd,
|
||||
t: t,
|
||||
|
||||
HTTPAddr: httpAddr,
|
||||
@ -240,10 +240,13 @@ func NewTestServerConfig(t TestingT, cb ServerConfigCallback) *TestServer {
|
||||
func (s *TestServer) Stop() {
|
||||
defer os.RemoveAll(s.Config.DataDir)
|
||||
|
||||
cmd := exec.Command("kill", "-9", fmt.Sprintf("%d", s.PID))
|
||||
if err := cmd.Run(); err != nil {
|
||||
if err := s.cmd.Process.Kill(); err != nil {
|
||||
s.t.Errorf("err: %s", err)
|
||||
}
|
||||
|
||||
// wait for the process to exit to be sure that the data dir can be
|
||||
// deleted on all platforms.
|
||||
s.cmd.Wait()
|
||||
}
|
||||
|
||||
// waitForAPI waits for only the agent HTTP endpoint to start
|
||||
|
Loading…
x
Reference in New Issue
Block a user