Skip to content

Latest commit

 

History

History
122 lines (84 loc) · 3.87 KB

README.md

File metadata and controls

122 lines (84 loc) · 3.87 KB

Test

This directory contains tests and testing docs for Knative Eventing Sources.

Running unit tests

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

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

Running end-to-end tests

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

One test case

To run one e2e test case, e.g. , use the -run flag with go test:

go test -v -tags=e2e -count=1 ./test/e2e -run ^TODOTEST

Environment requirements

There's couple of things you need to install before running e2e tests locally.

  1. kubetest installed:

    go get -u k8s.io/test-infra/kubetest
  2. [A running Knative Serving cluster.]

  3. 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.

Test images

Building the test images

Note: this is only required when you run e2e tests locally with go test commands. Running tests through 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:

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.

Adding new test images

New test images should be placed in ./test/test_images. For each image create a new sub-folder and include a Go file that will be an entry point to the application. This Go file should use the package "main" and include the function main(). It is a good practice to include a readme file as well. When uploading test images, ko will build an image from this folder.

Flags

Flags are similar to those in Knative Serving