Skip to content

Commit

Permalink
Fix CRI test on windows.
Browse files Browse the repository at this point in the history
Signed-off-by: Lantao Liu <lantaol@google.com>
  • Loading branch information
Random-Liu committed Sep 4, 2019
1 parent 8c8c91c commit 89634cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions cmd/critest/cri_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main
import (
"flag"
"fmt"
"io/ioutil"
"math/rand"
"os"
"os/exec"
Expand Down Expand Up @@ -73,13 +74,17 @@ func runTestSuite(t *testing.T) {
ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "CRI validation", reporter)
}

func generateTempTestName() string {
func generateTempTestName() (string, error) {
suffix := make([]byte, 10)
for i := range suffix {
suffix[i] = letterBytes[rand.Intn(len(letterBytes))]
}

return "/tmp/critest-" + string(suffix) + ".test"
dir, err := ioutil.TempDir("", "cri-test")
if err != nil {
return "", err
}
return dir + "/critest-" + string(suffix) + ".test", nil
}

func runParallelTestSuite(t *testing.T) {
Expand All @@ -88,7 +93,10 @@ func runParallelTestSuite(t *testing.T) {
t.Fatalf("Failed to lookup path of critest: %v", err)
}

tempFileName := generateTempTestName()
tempFileName, err := generateTempTestName()
if err != nil {
t.Fatalf("Failed to generate temp test name: %v", err)
}
err = os.Symlink(criPath, tempFileName)
if err != nil {
t.Fatalf("Failed to lookup path of critest: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/validate/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var (
// Windows defaults
echoHelloWindowsCmd = []string{"powershell", "-c", "echo hello"}
sleepWindowsCmd = []string{"powershell", "-c", "sleep", "4321"}
checkSleepWindowsCmd = []string{"powershell", "-c", "tasklist powershell | findstr sleep"}
checkSleepWindowsCmd = []string{"powershell", "-c", "tasklist | findstr sleep; exit 0"}
shellWindowsCmd = []string{"cmd", "/Q"}
pauseWindowsCmd = []string{"powershell", "-c", "ping -t localhost"}
logDefaultWindowsCmd = []string{"powershell", "-c", "echo '" + defaultLog + "'"}
Expand Down

0 comments on commit 89634cc

Please sign in to comment.