mirror of
https://github.com/status-im/consul.git
synced 2025-02-02 17:03:31 +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.
|
// TestServer is the main server wrapper struct.
|
||||||
type TestServer struct {
|
type TestServer struct {
|
||||||
PID int
|
cmd *exec.Cmd
|
||||||
Config *TestServerConfig
|
Config *TestServerConfig
|
||||||
t TestingT
|
t TestingT
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ func NewTestServerConfig(t TestingT, cb ServerConfigCallback) *TestServer {
|
|||||||
|
|
||||||
server := &TestServer{
|
server := &TestServer{
|
||||||
Config: consulConfig,
|
Config: consulConfig,
|
||||||
PID: cmd.Process.Pid,
|
cmd: cmd,
|
||||||
t: t,
|
t: t,
|
||||||
|
|
||||||
HTTPAddr: httpAddr,
|
HTTPAddr: httpAddr,
|
||||||
@ -240,10 +240,13 @@ func NewTestServerConfig(t TestingT, cb ServerConfigCallback) *TestServer {
|
|||||||
func (s *TestServer) Stop() {
|
func (s *TestServer) Stop() {
|
||||||
defer os.RemoveAll(s.Config.DataDir)
|
defer os.RemoveAll(s.Config.DataDir)
|
||||||
|
|
||||||
cmd := exec.Command("kill", "-9", fmt.Sprintf("%d", s.PID))
|
if err := s.cmd.Process.Kill(); err != nil {
|
||||||
if err := cmd.Run(); err != nil {
|
|
||||||
s.t.Errorf("err: %s", err)
|
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
|
// waitForAPI waits for only the agent HTTP endpoint to start
|
||||||
|
Loading…
x
Reference in New Issue
Block a user