mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 10:19:50 +00:00
Actually let hack/e2e.go run kubectl
This commit is contained in:
parent
9f2750694c
commit
d6d6229fea
47
hack/e2e.go
47
hack/e2e.go
@ -31,15 +31,19 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
isup = flag.Bool("isup", false, "Check to see if the e2e cluster is up, then exit.")
|
isup = flag.Bool("isup", false, "Check to see if the e2e cluster is up, then exit.")
|
||||||
build = flag.Bool("build", false, "If true, build a new release. Otherwise, use whatever is there.")
|
build = flag.Bool("build", false, "If true, build a new release. Otherwise, use whatever is there.")
|
||||||
up = flag.Bool("up", false, "If true, start the the e2e cluster. If cluster is already up, recreate it.")
|
up = flag.Bool("up", false, "If true, start the the e2e cluster. If cluster is already up, recreate it.")
|
||||||
push = flag.Bool("push", false, "If true, push to e2e cluster. Has no effect if -up is true.")
|
push = flag.Bool("push", false, "If true, push to e2e cluster. Has no effect if -up is true.")
|
||||||
down = flag.Bool("down", false, "If true, tear down the cluster before exiting.")
|
down = flag.Bool("down", false, "If true, tear down the cluster before exiting.")
|
||||||
test = flag.Bool("test", false, "Run all tests in hack/e2e-suite.")
|
test = flag.Bool("test", false, "Run all tests in hack/e2e-suite.")
|
||||||
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.")
|
||||||
|
checkVersionSkew = flag.Bool("check_version_skew", true, ""+
|
||||||
|
"By default, verify that client and server have exact version match. "+
|
||||||
|
"You can explicitly set to false if you're, e.g., testing client changes "+
|
||||||
|
"for which the server version doesn't make a difference.")
|
||||||
|
|
||||||
cfgCmd = flag.String("cfg", "", "If nonempty, pass this as an argument, and call kubecfg. Implies -v.")
|
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)")
|
ctlCmd = flag.String("ctl", "", "If nonempty, pass this as an argument, and call kubectl. Implies -v. (-test, -cfg, -ctl are mutually exclusive)")
|
||||||
@ -95,7 +99,7 @@ func main() {
|
|||||||
case *cfgCmd != "":
|
case *cfgCmd != "":
|
||||||
failure = !runBash("'kubecfg "+*cfgCmd+"'", "$KUBECFG "+*cfgCmd)
|
failure = !runBash("'kubecfg "+*cfgCmd+"'", "$KUBECFG "+*cfgCmd)
|
||||||
case *ctlCmd != "":
|
case *ctlCmd != "":
|
||||||
failure = !runBash("'kubectl "+*ctlCmd+"'", "$KUBECFG "+*ctlCmd)
|
failure = !runBash("'kubectl "+*ctlCmd+"'", "$KUBECTL "+*ctlCmd)
|
||||||
case *tests != "":
|
case *tests != "":
|
||||||
failed, passed := Test()
|
failed, passed := Test()
|
||||||
log.Printf("Passed tests: %v", passed)
|
log.Printf("Passed tests: %v", passed)
|
||||||
@ -210,7 +214,17 @@ func finishRunning(stepName string, cmd *exec.Cmd) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
var bashCommandPrefix = `
|
// returns either "", or a list of args intended for appending with the
|
||||||
|
// kubecfg or kubectl commands (begining with a space).
|
||||||
|
func kubeClientArgs() string {
|
||||||
|
if *checkVersionSkew {
|
||||||
|
return " -expect_version_match"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func bashWrap(cmd string) string {
|
||||||
|
return `
|
||||||
set -o errexit
|
set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
@ -219,7 +233,8 @@ export KUBE_CONFIG_FILE="config-test.sh"
|
|||||||
|
|
||||||
# TODO(jbeda): This will break on usage if there is a space in
|
# TODO(jbeda): This will break on usage if there is a space in
|
||||||
# ${KUBE_ROOT}. Covert to an array? Or an exported function?
|
# ${KUBE_ROOT}. Covert to an array? Or an exported function?
|
||||||
export KUBECFG="` + *root + `/cluster/kubecfg.sh -expect_version_match"
|
export KUBECFG="` + *root + `/cluster/kubecfg.sh` + kubeClientArgs() + `"
|
||||||
|
export KUBECTL="` + *root + `/cluster/kubectl.sh` + kubeClientArgs() + `"
|
||||||
|
|
||||||
source "` + *root + `/cluster/kube-env.sh"
|
source "` + *root + `/cluster/kube-env.sh"
|
||||||
source "` + *root + `/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
source "` + *root + `/cluster/${KUBERNETES_PROVIDER}/util.sh"
|
||||||
@ -228,12 +243,6 @@ if [[ ${KUBERNETES_PROVIDER} == "gce" ]]; then
|
|||||||
detect-project
|
detect-project
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
` + cmd + `
|
||||||
`
|
`
|
||||||
|
|
||||||
var bashCommandSuffix = `
|
|
||||||
|
|
||||||
`
|
|
||||||
|
|
||||||
func bashWrap(cmd string) string {
|
|
||||||
return bashCommandPrefix + cmd + bashCommandSuffix
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user