Merge pull request #72939 from runyontr/test-cmd-what

Test cmd what
pull/564/head
Kubernetes Prow Robot 2019-02-23 02:54:36 -08:00 committed by GitHub
commit 0133d14170
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 75 additions and 23 deletions

View File

@ -291,7 +291,6 @@ test-cmd:
@echo "$$TEST_CMD_HELP_INFO"
else
test-cmd: generated_files
hack/make-rules/test-kubeadm-cmd.sh
hack/make-rules/test-cmd.sh
endif

View File

@ -68,7 +68,6 @@
./hack/make-rules/test-cmd.sh
./hack/make-rules/test-e2e-node.sh
./hack/make-rules/test-integration.sh
./hack/make-rules/test-kubeadm-cmd.sh
./hack/make-rules/test.sh
./hack/make-rules/update.sh
./hack/make-rules/verify.sh

View File

@ -41,14 +41,6 @@ sh_binary(
],
)
sh_binary(
name = "test-kubeadm-cmd",
srcs = ["test-kubeadm-cmd.sh"],
deps = [
"//hack/lib",
],
)
sh_binary(
name = "build",
srcs = ["build.sh"],

44
test/cmd/README.md Normal file
View File

@ -0,0 +1,44 @@
# Kubernetes Command-Line Integration Test Suite
This document describes how you can use the Kubernetes command-line integration test-suite.
## Running Tests
### All Tests
To run this entire suite, execute `make test-cmd` from the top level. This will import each file containing tests functions
### Specific Tests
To run a subset of tests (e.g. `run_deployment_test` and `run_impersonation_test`), execute `make test-cmd WHAT="deployment impersonation"`. Running specific
tests will not try and validate any required resources are available on the server.
## Adding Tests
Test functions need to have the format `run_*_test` so they can executed individually. Once a test has been added, insert a section in `legacy-script.sh` like
```bash
######################
# Replica Sets #
######################
if kube::test::if_supports_resource "${replicasets}" ; then
record_command run_rs_tests
fi
```
Be sure to validate any supported resouces required for the test by using the `kube::test::if_supports_resource` function.
### New File
If the test resides in a new file, source the file in the top of the `legacy-script.sh` file by adding a new line in
```bash
source "${KUBE_ROOT}/test/cmd/apply.sh"
source "${KUBE_ROOT}/test/cmd/apps.sh"
source "${KUBE_ROOT}/test/cmd/authorization.sh"
source "${KUBE_ROOT}/test/cmd/batch.sh"
...
```
Please keep the order of the source list alphabetical.

View File

@ -18,15 +18,19 @@ set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/hack/lib/init.sh"
run_kubeadm_tests() {
set -o nounset
set -o errexit
KUBEADM_PATH="${KUBEADM_PATH:=$(kube::realpath "${KUBE_ROOT}")/cluster/kubeadm.sh}"
KUBEADM_PATH="${KUBEADM_PATH:=$(kube::realpath "${KUBE_ROOT}")/cluster/kubeadm.sh}"
# If testing a different version of kubeadm than the current build, you can
# comment this out to save yourself from needlessly building here.
make -C "${KUBE_ROOT}" WHAT=cmd/kubeadm
# If testing a different version of kubeadm than the current build, you can
# comment this out to save yourself from needlessly building here.
make -C "${KUBE_ROOT}" WHAT=cmd/kubeadm
make -C "${KUBE_ROOT}" test \
make -C "${KUBE_ROOT}" test \
WHAT=k8s.io/kubernetes/cmd/kubeadm/test/cmd \
KUBE_TEST_ARGS="--kubeadm-path '${KUBEADM_PATH}'"
set +o nounset
set +o errexit
}

View File

@ -40,6 +40,7 @@ source "${KUBE_ROOT}/test/cmd/diff.sh"
source "${KUBE_ROOT}/test/cmd/discovery.sh"
source "${KUBE_ROOT}/test/cmd/generic-resources.sh"
source "${KUBE_ROOT}/test/cmd/get.sh"
source "${KUBE_ROOT}/test/cmd/kubeadm.sh"
source "${KUBE_ROOT}/test/cmd/kubeconfig.sh"
source "${KUBE_ROOT}/test/cmd/node-management.sh"
source "${KUBE_ROOT}/test/cmd/old-print.sh"
@ -385,6 +386,23 @@ runTests() {
kubectl get "${kube_flags[@]}" -f hack/testdata/kubernetes-service.yaml
fi
cleanup_tests(){
kube::test::clear_all
if [[ -n "${foundError}" ]]; then
echo "FAILED TESTS: ""${foundError}"
exit 1
fi
}
if [[ -n "${WHAT-}" ]]; then
for pkg in ${WHAT}
do
record_command run_${pkg}_tests
done
cleanup_tests
return
fi
#########################
# Kubectl version #
#########################
@ -836,6 +854,7 @@ runTests() {
record_command run_plugins_tests
#################
# Impersonation #
#################
@ -847,10 +866,5 @@ runTests() {
record_command run_wait_tests
kube::test::clear_all
if [[ -n "${foundError}" ]]; then
echo "FAILED TESTS: ""${foundError}"
exit 1
fi
cleanup_tests
}