kubeadm: updated cmd tests as discussed in SIG

After today's SIG meeting, it was discussed how to proceed with these
types of test-cmd tests.  They will live in kubeamd/test/cmd and will
provide a flag that will allow you to skip them (--kubeadm-cmd-skip) and
by default will fail if kubeadm binary is not present
pull/6/head
Derek McQuay 2017-02-07 10:22:27 -08:00
parent 7472adff5b
commit 1459bbade4
No known key found for this signature in database
GPG Key ID: 92A7BC0C86B0B91A
6 changed files with 9 additions and 14 deletions

View File

@ -33,7 +33,7 @@ filegroup(
srcs = [
":package-srcs",
"//cmd/kubeadm/app:all-srcs",
"//cmd/kubeadm/test:all-srcs",
"//cmd/kubeadm/test/cmd:all-srcs",
],
tags = ["automanaged"],
)

View File

@ -17,7 +17,7 @@ go_library(
go_test(
name = "go_default_test",
srcs = ["token_test.go"],
args = ["--kubeadm-path=../kubeadm"],
args = ["--kubeadm-path=../../kubeadm"],
data = ["//cmd/kubeadm"],
library = ":go_default_library",
tags = [

View File

@ -29,17 +29,11 @@ const (
)
var kubeadmPath = flag.String("kubeadm-path", filepath.Join(os.Getenv("KUBE_ROOT"), "cluster/kubeadm.sh"), "Location of kubeadm")
var testCmd = true
func init() {
if _, err := os.Stat(*kubeadmPath); os.IsNotExist(err) {
testCmd = false
}
}
var kubeadmCmdSkip = flag.Bool("kubeadm-cmd-skip", false, "Skip kubeadm cmd tests")
func TestCmdTokenGenerate(t *testing.T) {
if !testCmd {
t.Log("kubeadm not found, skipping")
if *kubeadmCmdSkip {
t.Log("kubeadm cmd tests being skipped")
t.Skip()
}
stdout, _, err := RunCmd(*kubeadmPath, "ex", "token", "generate")
@ -66,8 +60,8 @@ func TestCmdTokenGenerateTypoError(t *testing.T) {
with a non-zero status code after showing the command's usage, so that
the usage itself isn't captured as a token without the user noticing.
*/
if !testCmd {
t.Log("kubeadm not found, skipping")
if *kubeadmCmdSkip {
t.Log("kubeadm cmd tests being skipped")
t.Skip()
}

View File

@ -28,5 +28,5 @@ KUBEADM_PATH="${KUBEADM_PATH:=$(kube::realpath "${KUBE_ROOT}")/cluster/kubeadm.s
make -C "${KUBE_ROOT}" WHAT=cmd/kubeadm
make -C "${KUBE_ROOT}" test \
WHAT=k8s.io/kubernetes/cmd/kubeadm/test \
WHAT=k8s.io/kubernetes/cmd/kubeadm/test/cmd \
KUBE_TEST_ARGS="--kubeadm-path '${KUBEADM_PATH}'"

View File

@ -325,6 +325,7 @@ kube-master
kube-master-url
kube-reserved
kubeadm-path
kubeadm-cmd-skip
kubecfg-file
kubectl-path
kubelet-address