test

package
v0.0.0-...-6886f78 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 31 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// PollInterval is how frequently e2e tests will poll for updates.
	PollInterval = 1 * time.Second
	// PollTimeout is how long e2e tests will wait for resource updates when polling.
	PollTimeout = 10 * time.Minute
)
View Source
const (
	// ServingNamespace is the default namespace for serving e2e tests
	ServingNamespace = "serving-tests"
)

Variables

View Source
var NetworkingFlags = initializeNetworkingFlags()

NetworkingFlags holds the flags or defaults for knative/networking settings in the user's environment.

View Source
var ObjectNameForTest = helpers.ObjectNameForTest

ObjectNameForTest generates a random object name based on the test name.

View Source
var ServingFlags = NetworkingFlags

ServingFlags is an alias of NetworkingFlags. TODO: Delete this variable once all downstream migrate it to NetworkingFlags.

Functions

func AssertProberDefault

func AssertProberDefault(t testing.TB, p Prober)

AssertProberDefault is a helper for stopping the Prober and checking its SLI against the default SLO, which requires perfect responses. This takes `testing.T` so that it may be used in `defer`.

func CheckSLO

func CheckSLO(slo float64, name string, p Prober) error

CheckSLO compares the SLI of the given prober against the SLO, erroring if too low.

func CleanupOnInterrupt

func CleanupOnInterrupt(cleanup func())

CleanupOnInterrupt stores cleanup functions to execute if an interrupt signal is caught

func EnsureCleanup

func EnsureCleanup(t *testing.T, cleanup func())

EnsureCleanup will run the provided cleanup function when the test ends, either via t.Cleanup or on interrupt via CleanupOnInterrupt.

func IsIngressReady

func IsIngressReady(r *v1alpha1.Ingress) (bool, error)

IsIngressReady will check the status conditions of the ingress and return true if the ingress is ready.

func ListenAndServeGracefully

func ListenAndServeGracefully(addr string, handler func(w http.ResponseWriter, r *http.Request))

ListenAndServeGracefully calls into ListenAndServeGracefullyWithHandler by passing handler to handle requests for "/"

func ListenAndServeGracefullyWithHandler

func ListenAndServeGracefullyWithHandler(addr string, handler http.Handler)

ListenAndServeGracefullyWithHandler creates an HTTP server, listens on the defined address and handles incoming requests with the given handler. It blocks until SIGTERM is received and the underlying server has shutdown gracefully.

func ListenAndServeTLSGracefully

func ListenAndServeTLSGracefully(cert, key, addr string, handler func(w http.ResponseWriter, r *http.Request))

ListenAndServeTLSGracefully calls into ListenAndServeTLSGracefullyWithHandler by passing handler to handle requests for "/"

func ListenAndServeTLSGracefullyWithHandler

func ListenAndServeTLSGracefullyWithHandler(cert, key, addr string, handler http.Handler)

ListenAndServeTLSGracefullyWithHandler creates an HTTPS server, listens on the defined address and handles incoming requests with the given handler. It blocks until SIGTERM is received and the underlying server has shutdown gracefully.

func WaitForIngressState

func WaitForIngressState(ctx context.Context, client *NetworkingClients, name string, inState func(r *v1alpha1.Ingress) (bool, error), desc string) error

WaitForIngressState polls the status of the Ingress called name from client every PollInterval until inState returns `true` indicating it is done, returns an error or PollTimeout. desc will be used to name the metric that is emitted to track how long it took for name to get into the state checked by inState.

Types

type Clients

type Clients struct {
	KubeClient       kubernetes.Interface
	NetworkingClient *NetworkingClients
	Dynamic          dynamic.Interface
}

Clients holds instances of interfaces for making requests to Knative Serving.

func NewClientsFromConfig

func NewClientsFromConfig(cfg *rest.Config, namespace string) (*Clients, error)

NewClientsFromConfig instantiates and returns several clientsets required for making request to the Knative Serving cluster specified by the combination of clusterName and configPath. Clients can make requests within namespace.

func Setup

func Setup(t testing.TB) *Clients

Setup creates client to run Knative Service requests

type NetworkingClients

type NetworkingClients struct {
	ServerlessServices networkingv1alpha1.ServerlessServiceInterface
	Ingresses          networkingv1alpha1.IngressInterface
	Certificates       networkingv1alpha1.CertificateInterface
}

NetworkingClients holds instances of interfaces for making requests to Knative networking clients.

type NetworkingEnvironmentFlags

type NetworkingEnvironmentFlags struct {
	ResolvableDomain    bool   // Resolve Route controller's `domainSuffix`
	HTTPS               bool   // Indicates where the test service will be created with https
	IngressClass        string // Indicates the class of Ingress provider to test.
	CertificateClass    string // Indicates the class of Certificate provider to test.
	Buckets             int    // The number of reconciler buckets configured.
	Replicas            int    // The number of controlplane replicas being run.
	EnableAlphaFeatures bool   // Indicates whether we run tests for alpha features
	EnableBetaFeatures  bool   // Indicates whether we run tests for beta features
	SkipTests           string // Indicates the test names we want to skip in alpha or beta features.
	ClusterSuffix       string // Specifies the cluster DNS suffix to be used in tests.
	ServiceDomain       string // Specifies the domain to use when creating the test services.
}

NetworkingEnvironmentFlags holds the e2e flags needed only by the networking repo.

type Prober

type Prober interface {
	// SLI returns the "service level indicator" for the prober, which is the observed
	// success rate of the probes.  This will panic if the prober has not been stopped.
	SLI() (total int64, failures int64)

	// Stop terminates the prober, returning any observed errors.
	// Implementations may choose to put additional requirements on
	// the prober, which may cause this to block (e.g. a minimum number
	// of probes to achieve a population suitable for SLI measurement).
	Stop() error
}

Prober is the interface for a prober, which checks the result of the probes when stopped.

func RunRouteProber

func RunRouteProber(logf logging.FormatLogger, clients *Clients, url *url.URL, opts ...spoof.TransportOption) Prober

RunRouteProber starts a single Prober of the given domain.

type ProberManager

type ProberManager interface {
	// The ProberManager should expose a way to collectively reason about spawned
	// probes as a sort of aggregating Prober.
	Prober

	// Spawn creates a new Prober
	Spawn(url *url.URL) Prober

	// Foreach iterates over the probers spawned by this ProberManager.
	Foreach(func(url *url.URL, p Prober))
}

ProberManager is the interface for spawning probers, and checking their results.

func NewProberManager

func NewProberManager(logf logging.FormatLogger, clients *Clients, minProbes int64, opts ...spoof.TransportOption) ProberManager

NewProberManager creates a new manager for probes.

Jump to

Keyboard shortcuts

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