ingress

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: Apache-2.0 Imports: 44 Imported by: 0

README

Ingress Conformance Testing

This directory contains Ingress conformance tests for Knative Ingress resource.

Environment requirements

Development tools
  1. go: The language Knative Serving is built in (1.13 or later)
  2. ko: Build tool to setup the environment.
  3. kubectl: For managing development environments.
Test environment
  1. A running Knative Serving cluster., with the Ingress implementation of choice installed.

    # Set the Ingress class annotation to use in tests.
    # Some examples:
    #   export INGRESS_CLASS=gloo.ingress.networking.knative.dev      # Gloo Ingress
    #   export INGRESS_CLASS=istio.ingress.networking.knative.dev     # Istio Ingress
    #   export INGRESS_CLASS=kourier.ingress.networking.knative.dev   # Kourier Ingress
    export INGRESS_CLASS=<your-ingress-class-annotation>
    
  2. Knative Serving source code check out at ${SERVING_ROOT}. Often this is $GO_PATH/src/go/knative.dev/serving. This contains all the tests and the test images.

    export SERVING_ROOT=<where-you-checked-out-knative/serving>
    
  3. A docker repo containing the test images KO_DOCKER_REPO: The docker repository to which developer images should be pushed (e.g. gcr.io/[gcloud-project]).

    export KO_DOCKER_REPO=<your-docker-repository>
    
  4. The knative-testing resources

    ko apply -f "$SERVING_ROOT/test/config"
    

Building the test images

Note: this is only required when you run conformance/e2e tests locally with go test commands.

The upload-test-images.sh script can be used to build and push the test images used by the conformance and e2e tests. The script expects your environment to be setup as described in DEVELOPMENT.md.

To run the script for all end to end test images:

$SERVING_ROOT/test/upload-test-images.sh

Adding a test

Tests need to be exported and accessible downstream so they should be placed in non-test files (ie. sometest.go). Additionally, invoke your test in the default RunConformance function in run.go. This function is the entry point by which tests are executed.

This approach aims to reduce the changes required when tests are added & removed.

Running the tests

cd "$SERVING_ROOT"

# Set the endpoint of your Ingress installation.
#
# For example:
#    export INGRESS_ENDPOINT="$(minikube ip):31380"
export INGRESS_ENDPOINT=<your-ingress-ip/url>:<your-ingress-port>

go test -v -tags=e2e -count=1 test/conformance/ingress \
    --ingressClass="$INGRESS_CLASS" \
    --ingressendpoint=$INGRESSENDPOINT

Running the tests downstream

To run all the conformance tests in your own repo we encourage adopting the RunConformance function to run all your tests.

To do so would look something like:

package conformance

import (
	"testing"
	"knative.dev/serving/test/conformance/ingress"
)

func TestYourIngressConformance(t *testing.T) {
	ingress.RunConformance(t)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDialContext

func CreateDialContext(t *testing.T, ing *v1alpha1.Ingress, clients *test.Clients) func(context.Context, string, string) (net.Conn, error)

CreateDialContext looks up the endpoint information to create a "dialer" for the provided Ingress' public ingress loas balancer. It can be used to contact external-visibility services with an HTTP client via:

client := &http.Client{
	Transport: &http.Transport{
		DialContext: CreateDialContext(t, ing, clients),
	},
}

func CreateFlakyService

func CreateFlakyService(t *testing.T, clients *test.Clients, period int) (string, int, context.CancelFunc)

CreateFlakyService creates a Kubernetes service where the backing pod will succeed only every Nth request.

func CreateGRPCService

func CreateGRPCService(t *testing.T, clients *test.Clients, suffix string) (string, int, context.CancelFunc)

CreateGRPCService creates a Kubernetes service that will upgrade the connection to use GRPC and echo back the received messages with the provided suffix.

func CreateIngress

func CreateIngress(t *testing.T, clients *test.Clients, spec v1alpha1.IngressSpec) (*v1alpha1.Ingress, context.CancelFunc)

CreateIngress creates a Knative Ingress resource

func CreateIngressReady

func CreateIngressReady(t *testing.T, clients *test.Clients, spec v1alpha1.IngressSpec) (*v1alpha1.Ingress, *http.Client, context.CancelFunc)

func CreateIngressReadyDialContext

func CreateIngressReadyDialContext(t *testing.T, clients *test.Clients, spec v1alpha1.IngressSpec) (*v1alpha1.Ingress, func(context.Context, string, string) (net.Conn, error), context.CancelFunc)

func CreateProxyService added in v0.13.0

func CreateProxyService(t *testing.T, clients *test.Clients, target string, gatewayDomain string) (string, int, context.CancelFunc)

CreateProxyService creates a Kubernetes service that will forward requests to the specified target. It returns the service name, the port on which the service is listening, and a "cancel" function to clean up the created resources.

func CreateRuntimeService

func CreateRuntimeService(t *testing.T, clients *test.Clients, portName string) (string, int, context.CancelFunc)

CreateRuntimeService creates a Kubernetes service that will respond to the protocol specified with the given portName. It returns the service name, the port on which the service is listening, and a "cancel" function to clean up the created resources.

func CreateTLSSecret

func CreateTLSSecret(t *testing.T, clients *test.Clients, hosts []string) (string, context.CancelFunc)

This is based on https://golang.org/src/crypto/tls/generate_cert.go

func CreateTLSSecretWithCertPool

func CreateTLSSecretWithCertPool(t *testing.T, clients *test.Clients, hosts []string, ns string, cas *x509.CertPool) (string, context.CancelFunc)

CreateTLSSecretWithCertPool creates TLS certificate with given CertPool.

func CreateTimeoutService

func CreateTimeoutService(t *testing.T, clients *test.Clients) (string, int, context.CancelFunc)

CreateTimeoutService creates a Kubernetes service that will respond to the protocol specified with the given portName. It returns the service name, the port on which the service is listening, and a "cancel" function to clean up the created resources.

func CreateWebsocketService

func CreateWebsocketService(t *testing.T, clients *test.Clients, suffix string) (string, int, context.CancelFunc)

CreateWebsocketService creates a Kubernetes service that will upgrade the connection to use websockets and echo back the received messages with the provided suffix.

func DumpResponse

func DumpResponse(t *testing.T, resp *http.Response)

func IsDialError added in v0.14.0

func IsDialError(err error) bool

func RunConformance added in v0.16.0

func RunConformance(t *testing.T)

func RuntimeRequest

func RuntimeRequest(t *testing.T, client *http.Client, url string, opts ...RequestOption) *types.RuntimeInfo

func RuntimeRequestWithExpectations added in v0.14.0

func RuntimeRequestWithExpectations(t *testing.T, client *http.Client, url string,
	responseExpectations []ResponseExpectation,
	allowDialError bool,
	opts ...RequestOption) *types.RuntimeInfo

RuntimeRequestWithExpectations attempts to make a request to url and return runtime information. If connection is successful only then it will validate all response expectations. If allowDialError is set to true then function will not fail if connection is a dial error.

func TestBasics added in v0.16.0

func TestBasics(t *testing.T)

TestBasics verifies that a no frills Ingress exposes a simple Pod/Service via the public load balancer.

func TestBasicsHTTP2 added in v0.16.0

func TestBasicsHTTP2(t *testing.T)

TestBasicsHTTP2 verifies that the same no-frills Ingress over a Service with http/2 configured will see a ProtoMajor of 2.

func TestGRPC added in v0.16.0

func TestGRPC(t *testing.T)

TestGRPC verifies that GRPC may be used via a simple Ingress.

func TestGRPCSplit added in v0.16.0

func TestGRPCSplit(t *testing.T)

TestGRPCSplit verifies that websockets may be used across a traffic split.

func TestIngressTLS added in v0.16.0

func TestIngressTLS(t *testing.T)

TestIngressTLS verifies that the Ingress properly handles the TLS field.

func TestMultipleHosts added in v0.16.0

func TestMultipleHosts(t *testing.T)

TestMultipleHosts verifies that an Ingress can respond to multiple hosts.

func TestPath added in v0.16.0

func TestPath(t *testing.T)

TestPath verifies that an Ingress properly dispatches to backends based on the path of the URL.

func TestPathAndPercentageSplit added in v0.16.0

func TestPathAndPercentageSplit(t *testing.T)

func TestPercentage added in v0.16.0

func TestPercentage(t *testing.T)

TestPercentage verifies that an Ingress splitting over multiple backends respects the given percentage distribution.

func TestPostSplitSetHeaders added in v0.16.0

func TestPostSplitSetHeaders(t *testing.T)

TestPostSplitSetHeaders verifies that an Ingress that specified AppendHeaders post-split has the appropriate header(s) set.

func TestPreSplitSetHeaders added in v0.16.0

func TestPreSplitSetHeaders(t *testing.T)

TestPreSplitSetHeaders verifies that an Ingress that specified AppendHeaders pre-split has the appropriate header(s) set.

func TestRetry added in v0.16.0

func TestRetry(t *testing.T)

TestRetry verifies that an Ingress configured to retry N times properly masks transient failures.

func TestTagHeaders added in v0.16.0

func TestTagHeaders(t *testing.T)

TestTagHeaders verifies that an Ingress properly dispaches to backends based on the tag header

See proposal doc for reference: https://docs.google.com/document/d/12t_3NE4EqvW_l0hfVlQcAGKkwkAM56tTn2wN_JtHbSQ/edit?usp=sharing

func TestTimeout added in v0.16.0

func TestTimeout(t *testing.T)

TestTimeout verifies that an Ingress configured with a timeout respects that.

func TestUpdate added in v0.16.0

func TestUpdate(t *testing.T)

TestUpdate verifies that when the network programming changes that traffic isn't dropped.

func TestVisibility added in v0.16.0

func TestVisibility(t *testing.T)

func TestVisibilityPath added in v0.16.0

func TestVisibilityPath(t *testing.T)

func TestVisibilitySplit added in v0.16.0

func TestVisibilitySplit(t *testing.T)

func TestWebsocket added in v0.16.0

func TestWebsocket(t *testing.T)

TestWebsocket verifies that websockets may be used via a simple Ingress.

func TestWebsocketSplit added in v0.16.0

func TestWebsocketSplit(t *testing.T)

TestWebsocketSplit verifies that websockets may be used across a traffic split.

func UpdateIngress

func UpdateIngress(t *testing.T, clients *test.Clients, name string, spec v1alpha1.IngressSpec)

UpdateIngress updates a Knative Ingress resource

func UpdateIngressReady

func UpdateIngressReady(t *testing.T, clients *test.Clients, name string, spec v1alpha1.IngressSpec)

Types

type RequestOption

type RequestOption func(*http.Request)

type ResponseExpectation added in v0.14.0

type ResponseExpectation func(response *http.Response) error

func StatusCodeExpectation added in v0.14.0

func StatusCodeExpectation(statusCodes sets.Int) ResponseExpectation

Jump to

Keyboard shortcuts

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