From 88dc6121d837e25f51c85d75e48f59fa2810adb5 Mon Sep 17 00:00:00 2001 From: Song Yihan Date: Thu, 23 Jan 2020 00:34:35 +0800 Subject: [PATCH] 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 --- sdk/testutil/server.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sdk/testutil/server.go b/sdk/testutil/server.go index a28591ef1..052505674 100644 --- a/sdk/testutil/server.go +++ b/sdk/testutil/server.go @@ -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") + } } }