mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
Add handy -cfg and -ctl options to make it easy to run a kubecfg or kubectl command against your e2e cluster.
This commit is contained in:
parent
9bb0d33a3f
commit
b8aa87ed50
21
hack/e2e.go
21
hack/e2e.go
@ -40,6 +40,9 @@ var (
|
|||||||
tests = flag.String("tests", "", "Run only tests in hack/e2e-suite matching this glob. Ignored if -test is set.")
|
tests = flag.String("tests", "", "Run only tests in hack/e2e-suite matching this glob. Ignored if -test is set.")
|
||||||
root = flag.String("root", absOrDie(filepath.Clean(filepath.Join(path.Base(os.Args[0]), ".."))), "Root directory of kubernetes repository.")
|
root = flag.String("root", absOrDie(filepath.Clean(filepath.Join(path.Base(os.Args[0]), ".."))), "Root directory of kubernetes repository.")
|
||||||
verbose = flag.Bool("v", false, "If true, print all command output.")
|
verbose = flag.Bool("v", false, "If true, print all command output.")
|
||||||
|
|
||||||
|
cfgCmd = flag.String("cfg", "", "If nonempty, pass this as an argument, and call kubecfg. Implies -v.")
|
||||||
|
ctlCmd = flag.String("ctl", "", "If nonempty, pass this as an argument, and call kubectl. Implies -v. (-test, -cfg, -ctl are mutually exclusive)")
|
||||||
)
|
)
|
||||||
|
|
||||||
var signals = make(chan os.Signal, 100)
|
var signals = make(chan os.Signal, 100)
|
||||||
@ -87,18 +90,24 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
failed, passed := []string{}, []string{}
|
failure := false
|
||||||
if *tests != "" {
|
switch {
|
||||||
failed, passed = Test()
|
case *cfgCmd != "":
|
||||||
|
failure = !runBash("'kubecfg "+*cfgCmd+"'", "$KUBECFG "+*cfgCmd)
|
||||||
|
case *ctlCmd != "":
|
||||||
|
failure = !runBash("'kubectl "+*ctlCmd+"'", "$KUBECFG "+*ctlCmd)
|
||||||
|
case *tests != "":
|
||||||
|
failed, passed := Test()
|
||||||
|
log.Printf("Passed tests: %v", passed)
|
||||||
|
log.Printf("Failed tests: %v", failed)
|
||||||
|
failure = len(failed) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if *down {
|
if *down {
|
||||||
TearDown()
|
TearDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Passed tests: %v", passed)
|
if failure {
|
||||||
log.Printf("Failed tests: %v", failed)
|
|
||||||
if len(failed) > 0 {
|
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user