Running and debugging tests
Running presubmission verification tests
Running unit tests
To run all unit tests:
To run unit tests for webhooks:
To run tests that match TestValidateClusterQueue
regular expression ref:
Running unit tests with race detection
Use -race
to enable Go’s built-in race detector:
Running unit tests with stress
To run unit tests in a loop and collect failures:
Running integration tests
For running a subset of tests, see Running subset of tests.
Running e2e tests using custom build
You can also change kind
version by modifying E2E_KIND_VERSION
variable:
For running a subset of tests, see Running subset of tests.
Increase logging verbosity
You can change log level (for example, set -5 to increase verbosity) using TEST_LOG_LEVEL
variables.
By default, TEST_LOG_LEVEL=-3
.
Debug tests in VSCode
It is possible to debug unit and integration tests in VSCode.
You need to have the Go extension installed.
Now you will have run test | debug test
text buttons above lines like
You can click on the debug test
to debug a specific test.
For integration tests, an additional step is needed. In settings.json, you need to add two variables inside go.testEnvVars
:
- Run
ENVTEST_K8S_VERSION=1.32 make envtest && ./bin/setup-envtest use $ENVTEST_K8S_VERSION -p path
and assign the path to theKUBEBUILDER_ASSETS
variable - Set
KUEUE_BIN
to thebin
directory within your cloned Kueue repository
For e2e tests, you can also use Ginkgo Test Explorer. You need to add the following variables to settings.json:
and then you can use GUI of the Ginkgo Test Explorer to run individual tests, provided you started kind clanter (see here for the instructions).
Attaching e2e tests to an existing kind cluster
You can use the following approach to start up a kind cluster and then run e2e tests from commandline or VSCode, attaching them to the existing cluster. For example, suppose you want to test some of the multikueue-e2e tests. Comment the last line of the hack/multikueue-e2e-test.sh
and add read -p "run your tests now"
instead:
Then, run make kind-image-build test-multikueue-e2e
and wait for the "run your tests now"
to appear. The cluster is ready, and now you can run tests from another terminal:
or from VSCode.
Running subset of integration or e2e tests
Use Ginkgo –focus arg
Use ginkgo.FIt
If you want to focus on specific tests, you can change
ginkgo.It
to ginkgo.FIt
for these tests.
For more details, see here.
Then the other tests will be skipped.
For example, you can change
to
and then run
to test a particular TAS e2e test.
Use INTEGRATION_TARGET
Flaky integration/e2e tests
You can use –until-it-fails or –repeat=N arguments to Ginkgo to run tests repeatedly, such as:
See more here
Adding stress
You can run stress tool to increase CPU load during tests. For example, if you’re on Debian-based Linux:
Analyzing logs
Kueue runs as a regular pod on a worker node, and in e2e tests there are 2 replicas running. The Kueue logs are located in kind-worker/pods/kueue-system_kueue-controller-manager*/manager
and kind-worker2/pods/kueue-system_kueue-controller-manager*/manager
folders.
For each log message you can from which file and line the message is coming from:
Here, it’s core/clusterqueue_controller.go:341
.
See also
- Kubernetes testing guide
- Integration Testing in Kubernetes
- End-to-End Testing in Kubernetes
- Flaky Tests in Kubernetes
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.