# Runs TestValidatePod in pkg/api/validation with the verbose flag setmaketestWHAT=./pkg/api/validationKUBE_GOFLAGS="-v"KUBE_TEST_ARGS='-run ^TestValidatePod$'# Runs tests that match the regex ValidatePod|ValidateConfigMap in pkg/api/validationmaketestWHAT=./pkg/api/validationKUBE_GOFLAGS="-v"KUBE_TEST_ARGS="-run ValidatePod\|ValidateConfigMap$"
# Run integration test TestPodUpdateActiveDeadlineSeconds with the verbose flag set.maketest-integrationKUBE_GOFLAGS="-v"KUBE_TEST_ARGS="-run ^TestPodUpdateActiveDeadlineSeconds$"
End to end (e2e) 测试
End to end (e2e) 测试模拟用户行为操作 Kubernetes,用来保证 Kubernetes 服务或集群的行为完全符合设计预期。
make WHAT='test/e2e/e2e.test'
make ginkgo
export KUBERNETES_PROVIDER=local
启动 cluster,测试,最后停止 cluster
# build Kubernetes, up a cluster, run tests, and tear everything downgorunhack/e2e.go---v--build--up--test--down
仅测试指定的用例
go run hack/e2e.go -v -test --test_args='--ginkgo.focus=Kubectl\sclient\s\[k8s\.io\]\sKubectl\srolling\-update\sshould\ssupport\srolling\-update\sto\ssame\simage\s\[Conformance\]$'
# Run tests in parallel, skip any that must be run seriallyGINKGO_PARALLEL=ygorunhack/e2e.go--v--test--test_args="--ginkgo.skip=\[Serial\]"# Run tests in parallel, skip any that must be run serially and keep the test namespace if test failedGINKGO_PARALLEL=y go run hack/e2e.go --v --test --test_args="--ginkgo.skip=\[Serial\] --delete-namespace-on-failure=false"
清理测试资源
gorunhack/e2e.go---v--down
有用的 -ctl
# -ctl can be used to quickly call kubectl against your e2e cluster. Useful for# cleaning up after a failed test or viewing logs. Use -v to avoid suppressing# kubectl output.gorunhack/e2e.go---v-ctl='get events'gorunhack/e2e.go---v-ctl='delete pod foobar'
Fedaration e2e 测试
export FEDERATION=trueexport E2E_ZONES="us-central1-a us-central1-b us-central1-f"# or export FEDERATION_PUSH_REPO_BASE="quay.io/colin_hom"export FEDERATION_PUSH_REPO_BASE="gcr.io/${GCE_PROJECT_NAME}"# build container imagesKUBE_RELEASE_RUN_TESTS=n KUBE_FASTBUILD=truegorunhack/e2e.go---v-build# push the federation container imagesbuild/push-federation-images.sh# Deploy federation control planegorunhack/e2e.go---v--up# Finally, run the testsgorunhack/e2e.go---v--test--test_args="--ginkgo.focus=\[Feature:Federation\]"# Don't forget to teardown everything downgorunhack/e2e.go---v--down