integration

package
v0.0.0-...-283c5ec Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2019 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureReconcile

func CaptureReconcile(inner reconcile.Reconciler) (reconcile.Reconciler, chan ReconcileCall)

CaptureReconcile wraps the given reconciler and returns a channel that emits all reconciliation calls that the inner reconciler has received.

func CaptureWebhook

func CaptureWebhook(mgr manager.Manager, inner admission.Handler) (admission.Handler, chan HandleCall)

CaptureWebhook wraps the given handler and returns a handler that, when called, will send a record of the request and response it received down the given channel. This can be used to test webhooks inside of integration tests.

func CreateNamespace

func CreateNamespace(clientset *kubernetes.Clientset) (string, func())

CreateNamespace creates a test namespace with a random name for use in integration tests. We return the name of the namespace and a closure that can be used to destroy the namespace.

func Drain

func Drain(calls chan ReconcileCall)

Drain can be used to drain all calls from the channel before continuing with a test

func HandleResource

func HandleResource(namespace, name string) types.GomegaMatcher

func MustController

func MustController(ctrl controller.Controller, err error) controller.Controller

MustController cleans up tests when you just want to create a controller and don't care what the error might be.

func MustWebhook

func MustWebhook(wh *admission.Webhook, err error) *admission.Webhook

MustWebhook cleans up tests when you just want to create a webhook and don't care what the error might be.

func NewServer

func NewServer(mgr manager.Manager, awhs ...*admission.Webhook) *webhook.Server

NewServer generates a webhook server attached to the given manager that listens on an ephemeral localhost port. It should be used in integration tests to register webhooks into the api-server that point at localhost, allowing us to test the functionality against a local server.

The value in using NewServer is to provide a simple API to install webhooks into a cluster and ensure that once called, both the server and webhooks are all running correctly.

func ReconcileNoRetry

func ReconcileNoRetry() types.GomegaMatcher

func ReconcileResource

func ReconcileResource(namespace, name string) types.GomegaMatcher

func ReconcileResourceSuccess

func ReconcileResourceSuccess(namespace, name string) types.GomegaMatcher

func ReconcileSuccessfully

func ReconcileSuccessfully() types.GomegaMatcher

func StartAPIServer

func StartAPIServer(crdDirectoryPath string) (*rest.Config, *envtest.Environment, *kubernetes.Clientset)

StartAPIServer creates a fake Kubernetes API server that can be used for integration testing Kubernetes controllers. Returns the rest.Config that can be used to connect to the API server.

func StartTestManager

func StartTestManager(ctx context.Context, cfg *rest.Config) manager.Manager

StartTestManager generates a new Manager connected to the given cluster configuration.

Types

type HandleCall

type HandleCall struct {
	Namespace, Name string
	runtime.Object
	atypes.Request
	atypes.Response
}

HandleCall is a record of each request received and response provided by a webhook handler. This can be used to assert against the behaviour of a webhook handler from outside of the manager.

type ReconcileCall

type ReconcileCall struct {
	Namespace, Name string
	reconcile.Request
	reconcile.Result
	Error error
}

ReconcileCall is a record of each requested reconciliation, both the request and the returned response/error. This can be used to assert against the behaviour of a reconciliation loop.

Jump to

Keyboard shortcuts

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