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
This commit is contained in:
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 = [ srcs = [
":package-srcs", ":package-srcs",
"//cmd/kubeadm/app:all-srcs", "//cmd/kubeadm/app:all-srcs",
"//cmd/kubeadm/test:all-srcs", "//cmd/kubeadm/test/cmd:all-srcs",
], ],
tags = ["automanaged"], tags = ["automanaged"],
) )

View File

@ -17,7 +17,7 @@ go_library(
go_test( go_test(
name = "go_default_test", name = "go_default_test",
srcs = ["token_test.go"], srcs = ["token_test.go"],
args = ["--kubeadm-path=../kubeadm"], args = ["--kubeadm-path=../../kubeadm"],
data = ["//cmd/kubeadm"], data = ["//cmd/kubeadm"],
library = ":go_default_library", library = ":go_default_library",
tags = [ 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 kubeadmPath = flag.String("kubeadm-path", filepath.Join(os.Getenv("KUBE_ROOT"), "cluster/kubeadm.sh"), "Location of kubeadm")
var testCmd = true var kubeadmCmdSkip = flag.Bool("kubeadm-cmd-skip", false, "Skip kubeadm cmd tests")
func init() {
if _, err := os.Stat(*kubeadmPath); os.IsNotExist(err) {
testCmd = false
}
}
func TestCmdTokenGenerate(t *testing.T) { func TestCmdTokenGenerate(t *testing.T) {
if !testCmd { if *kubeadmCmdSkip {
t.Log("kubeadm not found, skipping") t.Log("kubeadm cmd tests being skipped")
t.Skip() t.Skip()
} }
stdout, _, err := RunCmd(*kubeadmPath, "ex", "token", "generate") 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 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. the usage itself isn't captured as a token without the user noticing.
*/ */
if !testCmd { if *kubeadmCmdSkip {
t.Log("kubeadm not found, skipping") t.Log("kubeadm cmd tests being skipped")
t.Skip() 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}" WHAT=cmd/kubeadm
make -C "${KUBE_ROOT}" test \ 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}'" KUBE_TEST_ARGS="--kubeadm-path '${KUBEADM_PATH}'"

View File

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