Unit Test and Integration Test
Unit Testing
Unit testing is solely dependent on the source code, serving as the simplest method to test if the code logic aligns with expectations.
Run all Unit Tests
make testTest Specific Package(s) Only
# Single package
make test WHAT=./pkg/api
# Multiple packages
make test WHAT=./pkg/{api,kubelet}Or, you can directly use go test
go test -v k8s.io/kubernetes/pkg/kubeletTest a Specific Test Case in a Given Package Only
Or simply use go test
Parallel Testing
Parallel testing is an effective way to root out flakes:
Generate Test Reports
Benchmark Testing
Integration Testing
Kubernetes integration tests require the installation of etcd (just the installation, no need to start it up), like:
Integration tests will automatically start etcd and Kubernetes services when needed and run the tests within test/integration.
Run All Integration Tests
Specify Integration Test Cases
End-to-End (e2e) Testing
End-to-End (e2e) testing simulates user actions on Kubernetes, ensuring that the behavior of the Kubernetes services or clusters is fully in line with the design expectations.
Before starting e2e testing, you need to compile the test files and set KUBERNETES_PROVIDER (default is gce):
Start Cluster, Test, and Stop Cluster Eventually
Test Specific Case Only
Skip Test Cases
Parallel Testing
Clean Up Testing Resources
Useful -ctl
-ctlFederation E2E Testing
You can use cluster/log-dump.sh <directory> to download related logs conveniently, which can help troubleshoot issues encountered during testing.
Node E2E Testing
Node e2e only tests Kubelet-related functionalities and can be conducted either locally or inside clusters.
Additional Explanation
You can conveniently obtain desired data with the assistance of the kubectl template. For example, the method to query the image of a certain container is:
Referenced Documents
最后更新于