mirror of https://github.com/k3s-io/k3s
commit
0133d14170
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"],
|
||||
|
|
|
@ -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.
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue