This directory contains tests and testing docs for Knative Eventing Sources
.
- Unit tests reside in the codebase alongside the code they test
- End-to-end tests reside in
/test/e2e
Use go test
:
go test -v ./pkg/...
By default go test
will not run the e2e tests,
which need -tags=e2e
to be enabled.
presubmit-tests.sh
is the entry point for the
end-to-end tests.
This script, and consequently, the e2e tests will be run before every code submission. You can run these tests manually with:
test/presubmit-tests.sh
Note that to run presubmit-tests.sh
or e2e-tests.sh
scripts, you need to
have a running environment that meets
the e2e test environment requirements
To run the e2e tests, you need to have a running environment that meets
the e2e test environment requirements, and you need
to specify the build tag e2e
.
go test -v -tags=e2e -count=1 ./test/e2e
To run one e2e test case, e.g. TestKubernetesEvents, use
the -run
flag with go test
:
go test -v -tags=e2e -count=1 ./test/e2e -run ^TestKubernetesEvents$
There's couple of things you need to install before running e2e tests locally.
kubetest
installed:go get -u k8s.io/test-infra/kubetest
- [A running
Knative Serving
cluster.] - A docker repo containing the test images
Simply run the ./test/e2e-tests.sh
script. It will create a GKE cluster,
install Knative Serving stack with Istio, upload test images to your Docker repo
and run the end-to-end tests against the Knative Eventing Sources built from
source.
If you already have the KO_DOCKER_REPO
environment variable set and a cluster
setup and currently selected in your kubeconfig, call the script
with the --run-tests
argument and it will use the cluster and run the tests.
Note that this requires you to have Serving and Istio installed and configured
to your particular configuration setup. Knative Eventing Sources will still
built and deployed from source.
Otherwise, calling this script without arguments will create a new cluster in
project $PROJECT_ID
, start Knative Serving and the eventing system, upload
test images, run the tests and delete the cluster.
Note: this is only required when you run e2e tests locally with go test
commands. Running tests throught e2e-tests.sh will publish the images
automatically.
The upload-test-images.sh
script can be used to
build and push the test images used by the e2e tests. It requires:
KO_DOCKER_REPO
to be set- You to be
authenticated with your
KO_DOCKER_REPO
docker
to be installed
To run the script for all end to end test images:
./test/upload-test-images.sh e2e
A docker tag is mandatory to avoid issues with using latest
tag for images
deployed in GCR.
New test image paths should be placed in ./test/image_paths.txt
.
Flags are similar to those in
Knative Serving