mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 02:09:56 +00:00
make e2e test get events in background, for easier debugging after the fact.
This commit is contained in:
parent
01048540bf
commit
c219d138ef
19
hack/e2e.go
19
hack/e2e.go
@ -134,6 +134,7 @@ func tryUp() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test() (failed, passed []string) {
|
func Test() (failed, passed []string) {
|
||||||
|
defer runBashUntil("watchEvents", "$KUBECTL --watch-only get events")()
|
||||||
// run tests!
|
// run tests!
|
||||||
dir, err := os.Open(filepath.Join(*root, "hack", "e2e-suite"))
|
dir, err := os.Open(filepath.Join(*root, "hack", "e2e-suite"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -175,6 +176,24 @@ func runBash(stepName, bashFragment string) bool {
|
|||||||
return finishRunning(stepName, cmd)
|
return finishRunning(stepName, cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// call the returned anonymous function to stop.
|
||||||
|
func runBashUntil(stepName, bashFragment string) func() {
|
||||||
|
cmd := exec.Command("bash", "-s")
|
||||||
|
cmd.Stdin = strings.NewReader(bashWrap(bashFragment))
|
||||||
|
log.Printf("Running in background: %v", stepName)
|
||||||
|
stdout, stderr := bytes.NewBuffer(nil), bytes.NewBuffer(nil)
|
||||||
|
cmd.Stdout, cmd.Stderr = stdout, stderr
|
||||||
|
if err := cmd.Start(); err != nil {
|
||||||
|
log.Printf("Unable to start '%v': '%v'", stepName, err)
|
||||||
|
return func() {}
|
||||||
|
}
|
||||||
|
return func() {
|
||||||
|
cmd.Process.Signal(os.Interrupt)
|
||||||
|
fmt.Printf("%v stdout:\n------\n%v\n------\n", stepName, string(stdout.Bytes()))
|
||||||
|
fmt.Printf("%v stderr:\n------\n%v\n------\n", stepName, string(stderr.Bytes()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func run(stepName, cmdPath string) bool {
|
func run(stepName, cmdPath string) bool {
|
||||||
return finishRunning(stepName, exec.Command(filepath.Join(*root, cmdPath)))
|
return finishRunning(stepName, exec.Command(filepath.Join(*root, cmdPath)))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user