e2e

package
v0.0.0-...-c52b3dd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

README

E2E Tests

Prow will run ./e2e-tests.sh.

Adding E2E Tests

E2E tests are tagged with // +build e2e but tagging a Go file this way will prevent the compiler from compiling the test code. To work around this, for the test code we separate them into different files:

test/e2e
├── e2e_test.go
└── test_xxx.go
  • e2e_test.go is the testing file entry point (tagged with e2e).
  • test_xxx.go are the test implementations (not tagged with e2e).

We leverage the test library in Eventing as much as possible for implementing the e2e tests. Logic specific to knative-gcp should be added under knative-gcp e2e test lib.

Running E2E Tests on an existing cluster

To run the e2e tests with go test command, 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 --tags=e2e ./test/e2e/...

And count is supported too:

go test --tags=e2e ./test/e2e/... --count=3

If you want to run a specific test:

go test --tags=e2e ./test/e2e/... -run NameOfTest

For example, to run TestPullSubscription:

GOOGLE_APPLICATION_CREDENTIALS=<path to json creds file> \
E2E_PROJECT_ID=<project name> \
  go test --tags=e2e ./test/e2e/... -run TestPullSubscription

Note that if you plan on running metrics-related E2E tests using the StackDriver backend, you need to give your Service Account the Monitoring Editor role on your Google Cloud project:

gcloud projects add-iam-policy-binding $PROJECT_ID \
  --member=serviceAccount:cloudrunevents-pullsub@$PROJECT_ID.iam.gserviceaccount.com \
  --role roles/monitoring.editor

Environment requirements

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

  1. A running Kubernetes cluster with knative-gcp installed and configured
  2. A docker repo containing the test images

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 ./test/test_images
./test/upload-test-images.sh ./vendor/knative.dev/eventing/test/test_images/

For images deployed in GCR, a docker tag is mandatory to avoid issues with using latest tag:

./test/upload-test-images.sh ./test/test_images e2e
./test/upload-test-images.sh ./vendor/knative.dev/eventing/test/test_images/ e2e
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 and upload to the Docker repository configured as KO_DOCKER_REPO.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuditLogsSourceBrokerWithPubSubChannelTestImpl

func AuditLogsSourceBrokerWithPubSubChannelTestImpl(t *testing.T)

func BrokerWithPubSubChannelTestImpl

func BrokerWithPubSubChannelTestImpl(t *testing.T)

func CloudAuditLogsSourceWithTestImpl

func CloudAuditLogsSourceWithTestImpl(t *testing.T)

func CloudPubSubSourceWithTargetTestImpl

func CloudPubSubSourceWithTargetTestImpl(t *testing.T, assertMetrics bool)

CloudPubSubSourceWithTargetTestImpl tests we can receive an event from a CloudPubSubSource. If assertMetrics is set to true, we also assert for StackDriver metrics.

func CloudSchedulerSourceWithTargetTestImpl

func CloudSchedulerSourceWithTargetTestImpl(t *testing.T)

CloudSchedulerSourceWithTargetTestImpl injects a scheduler event and checks if it is in the log of the receiver.

func CloudStorageSourceWithTestImpl

func CloudStorageSourceWithTestImpl(t *testing.T, assertMetrics bool)

func PubSubSourceBrokerWithPubSubChannelTestImpl

func PubSubSourceBrokerWithPubSubChannelTestImpl(t *testing.T)

func PullSubscriptionWithTargetTestImpl

func PullSubscriptionWithTargetTestImpl(t *testing.T)

PullSubscriptionWithTargetTestImpl tests we can receive an event from a PullSubscription.

func SchedulerSourceBrokerWithPubSubChannelTestImpl

func SchedulerSourceBrokerWithPubSubChannelTestImpl(t *testing.T)

func SmokeCloudPubSubSourceTestImpl

func SmokeCloudPubSubSourceTestImpl(t *testing.T)

SmokeCloudPubSubSourceTestImpl tests we can create a CloudPubSubSource to ready state.

func SmokeCloudSchedulerSourceSetup

func SmokeCloudSchedulerSourceSetup(t *testing.T)

SmokeCloudSchedulerSourceSetup tests if a CloudSchedulerSource object can be created and be made ready.

func SmokePullSubscriptionTestImpl

func SmokePullSubscriptionTestImpl(t *testing.T)

SmokePullSubscriptionTestImpl tests we can create a pull subscription to ready state.

func SmokeTestChannelImpl

func SmokeTestChannelImpl(t *testing.T)

SmokeTestChannelImpl makes sure we can run tests.

func StorageSourceBrokerWithPubSubChannelTestImpl

func StorageSourceBrokerWithPubSubChannelTestImpl(t *testing.T)

Types

This section is empty.

Directories

Path Synopsis
lib

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL