mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-19 08:40:42 +00:00
commit
9ee2535f29
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)))
|
||||||
}
|
}
|
||||||
|
@ -73,11 +73,13 @@ Examples:
|
|||||||
obj, err := restHelper.Get(namespace, name, labelSelector)
|
obj, err := restHelper.Get(namespace, name, labelSelector)
|
||||||
checkErr(err)
|
checkErr(err)
|
||||||
|
|
||||||
if err := printer.PrintObj(obj, out); err != nil {
|
if !GetFlagBool(cmd, "watch-only") {
|
||||||
checkErr(fmt.Errorf("Unable to output the provided object: %v", err))
|
if err := printer.PrintObj(obj, out); err != nil {
|
||||||
|
checkErr(fmt.Errorf("Unable to output the provided object: %v", err))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if GetFlagBool(cmd, "watch") {
|
if GetFlagBool(cmd, "watch") || GetFlagBool(cmd, "watch-only") {
|
||||||
vi, err := latest.InterfacesFor(outputVersion)
|
vi, err := latest.InterfacesFor(outputVersion)
|
||||||
checkErr(err)
|
checkErr(err)
|
||||||
|
|
||||||
@ -97,5 +99,6 @@ Examples:
|
|||||||
cmd.Flags().StringP("template", "t", "", "Template string or path to template file to use when --output=template or --output=templatefile")
|
cmd.Flags().StringP("template", "t", "", "Template string or path to template file to use when --output=template or --output=templatefile")
|
||||||
cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on")
|
cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on")
|
||||||
cmd.Flags().BoolP("watch", "w", false, "After listing/getting the requested object, watch for changes.")
|
cmd.Flags().BoolP("watch", "w", false, "After listing/getting the requested object, watch for changes.")
|
||||||
|
cmd.Flags().Bool("watch-only", false, "Watch for changes to the requseted object(s), without listing/getting first.")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user