integration: Adds Windows equivalent for TestSandboxRemoveWithoutIPLeakage

Adds an equivalent TestSandboxRemoveWithoutIPLeakage for Windows, in which
we assert that the IPs are not leaked when a Pod's HNS namespace dissapears
and the Pod is deleted afterwards.

Signed-off-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
This commit is contained in:
Claudiu Belu
2021-10-07 18:47:36 -07:00
parent ff7fd4eb2e
commit 894af07e37
2 changed files with 155 additions and 2 deletions

View File

@@ -377,8 +377,12 @@ func KillProcess(name string) error {
}
// KillPid kills the process by pid. kill is used.
func KillPid(pid int) error { //nolint:unused
output, err := exec.Command("kill", strconv.Itoa(pid)).CombinedOutput()
func KillPid(pid int) error {
command := "kill"
if goruntime.GOOS == "windows" {
command = "tskill"
}
output, err := exec.Command(command, strconv.Itoa(pid)).CombinedOutput()
if err != nil {
return errors.Errorf("failed to kill %d - error: %v, output: %q", pid, err, output)
}