kubernetes: Kubeadm tests fail when run using go test ./...
What happened:
When I do go test ./...
from the kubernetes root, it fails because the tests in cmd/kubeadm/test have external dependencies. KUBEADM_PATH is required for example.
...
--- FAIL: TestCmdCompletion (0.00s)
panic: the environment variable KUBEADM_PATH must point to the kubeadm binary path [recovered]
panic: the environment variable KUBEADM_PATH must point to the kubeadm binary path
goroutine 21 [running]:
testing.tRunner.func1(0xc0000f2400)
/usr/local/go/src/testing/testing.go:874 +0x3a3
panic(0x1231680, 0x15a2570)
/usr/local/go/src/runtime/panic.go:679 +0x1b2
k8s.io/kubernetes/cmd/kubeadm/test/cmd.getKubeadmPath(...)
/home/bpursley/go/src/k8s.io/kubernetes/cmd/kubeadm/test/cmd/util.go:89
k8s.io/kubernetes/cmd/kubeadm/test/cmd.TestCmdCompletion(0xc0000f2400)
/home/bpursley/go/src/k8s.io/kubernetes/cmd/kubeadm/test/cmd/completion_test.go:22 +0x1f8
testing.tRunner(0xc0000f2400, 0x14a5370)
/usr/local/go/src/testing/testing.go:909 +0xc9
created by testing.(*T).Run
/usr/local/go/src/testing/testing.go:960 +0x350
FAIL k8s.io/kubernetes/cmd/kubeadm/test/cmd 0.012s
? k8s.io/kubernetes/cmd/kubeadm/test/kubeconfig [no test files]
? k8s.io/kubernetes/cmd/kubeadm/test/resources [no test files]
FAIL
What you expected to happen:
The Kubernetes Testing Guide says I should be able to run all unit tests using go test ./...
How to reproduce it (as minimally and precisely as possible):
Clone the repository and run go test ./...
from the project root.
Or, you can more quickly see the problem if you rjust un that from the cmd/kubeadm subfolder like this:
cd cmd/kubeadm
go test ./...
Anything else we need to know?:
make test
specifically excludes cmd/kubeadm/test so that the problem does not occur if you use make test.
When this issue is fixed, we should probably remove this exclusion as well.
Environment:
- Kubernetes version (use
kubectl version
): 1.19 (master branch) - Cloud provider or hardware configuration: n/a
- OS (e.g:
cat /etc/os-release
):
NAME="Ubuntu"
VERSION="20.04 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
- Kernel (e.g.
uname -a
):
Linux cinlogic-xps13 5.4.0-31-generic #35-Ubuntu SMP Thu May 7 20:20:34 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
- Install tools:
- Network plugin and version (if this is a network-related bug):
- Others:
go version go1.13.4 linux/amd64
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (15 by maintainers)
I would expect go tests outside the test/integration and test/e2e packages to be unit tests, and to be able to run
go test ./cmd/...