test

package
v0.18.1 Latest Latest
Warning

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

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

README

Test

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

Running tests with scripts

Presubmit tests

presubmit-tests.sh is the entry point for the tests before code submission.

You can run it simply with:

test/presubmit-tests.sh

By default, this script will run build tests, unit tests and integration tests. If you only want to run one type of tests, you can run this script with corresponding flags like below:

test/presubmit-tests.sh --build-tests
test/presubmit-tests.sh --unit-tests
test/presubmit-tests.sh --integration-tests

Note that if the tests you are running include integration tests, it will create a new GKE cluster in project $PROJECT_ID, start Knative Serving and Eventing system, upload test images to $KO_DOCKER_REPO, and run all e2e-*tests.sh scripts under test. After the tests finish, it will delete the cluster.

E2E tests

e2e-tests.sh is the entry point for running all e2e tests.

You can run it simply with:

test/e2e-tests.sh

By default, it will create a new GKE cluster in project $PROJECT_ID, start Knative Serving and Eventing system, upload test images to $KO_DOCKER_REPO, and run the end-to-end tests. After the tests finishes, it will delete the cluster.

If you have already created your own Kubernetes cluster but haven't installed Knative, you can run with test/e2e-tests.sh --run-tests.

If you have set up a running environment that meets the e2e test environment requirements, you can run with test/e2e-tests.sh --run-tests --skip-knative-setup.

Running tests with go test command

Running unit tests

You can also use go test command to run unit tests:

go test -v ./...

By default go test will not run the e2e tests, which needs -tags=e2e to be enabled.

Running end-to-end tests

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 -v -tags=e2e -count=1 ./test/e2e

By default, it will run all applicable tests against the cluster's default channel.

If you want to run tests against other channels, you can specify them through -channels.

go test -v -tags=e2e -count=1 ./test/e2e -channels=InMemoryChannel,KafkaChannel

By default, tests run against images with the latest tag. To override this bevavior you can specify a different tag through -tag:

go test -v -tags=e2e -count=1 ./test/e2e -tag e2e
One test case

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

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

By default, it will run the test against the default channel.

If you want to run it against another channel, you can specify it through -channels.

go test -v -tags=e2e -count=1 ./test/e2e -run ^TestSingleBinaryEventForChannel$ -channels=InMemoryChannel

Environment requirements

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

  1. A running Knative cluster
  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

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

./test/upload-test-images.sh 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.

If you need to add a new test image imported from eventing, import it in hack/tools.go

Flags

Flags are similar to those in Knative Serving.

Documentation

Overview

Copyright 2019 The Knative Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	KafkaChannelKind string = "KafkaChannel"
	KafkaSourceKind  string = "KafkaSource"
)

Kind for messaging resources.

Variables

ChannelFeatureMap saves the channel-features mapping. Each pair means the channel support the list of features.

View Source
var KafkaSourceTypeMeta = metav1.TypeMeta{
	APIVersion: resources.SourcesV1B1APIVersion,
	Kind:       KafkaSourceKind,
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
e2e
lib
test_images

Jump to

Keyboard shortcuts

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