Merge pull request #5579 from claudiubelu/integration/restart-containerd

integration: Enables Windows containerd restart test
This commit is contained in:
Derek McGowan
2021-10-08 10:33:10 -07:00
committed by GitHub
2 changed files with 23 additions and 10 deletions

View File

@@ -23,6 +23,7 @@ import (
"fmt"
"os"
"path/filepath"
goruntime "runtime"
"strconv"
"strings"
"testing"
@@ -360,7 +361,14 @@ func Randomize(str string) string {
// KillProcess kills the process by name. pkill is used.
func KillProcess(name string) error {
output, err := exec.Command("pkill", "-x", fmt.Sprintf("^%s$", name)).CombinedOutput()
var command []string
if goruntime.GOOS == "windows" {
command = []string{"tskill", strings.TrimSuffix(name, ".exe")}
} else {
command = []string{"pkill", "-x", fmt.Sprintf("^%s$", name)}
}
output, err := exec.Command(command[0], command[1:]...).CombinedOutput()
if err != nil {
return errors.Errorf("failed to kill %q - error: %v, output: %q", name, err, output)
}