test

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DaemonSet

func DaemonSet(overrides ...DaemonSetOptions) *appsv1.DaemonSet

DaemonSet creates a test pod with defaults that can be overriden by DaemonSetOptions. Overrides are applied in order, with a last write wins semantic.

func Node

func Node(overrides ...NodeOptions) *v1.Node

func Pod

func Pod(overrides ...PodOptions) *v1.Pod

Pod creates a test pod with defaults that can be overriden by PodOptions. Overrides are applied in order, with a last write wins semantic.

func PodDisruptionBudget

func PodDisruptionBudget(overrides ...PDBOptions) *v1beta1.PodDisruptionBudget

func Pods added in v0.5.3

func Pods(total int, options ...PodOptions) []*v1.Pod

Pods creates homogeneous groups of pods based on the passed in options, evenly divided by the total pods requested

func UnschedulablePod

func UnschedulablePod(options ...PodOptions) *v1.Pod

UnschedulablePod creates a test pod with a pending scheduling status condition

Types

type DaemonSetOptions

type DaemonSetOptions struct {
	Name       string
	Namespace  string
	Selector   map[string]string
	PodOptions PodOptions
}

DaemonSetOptions customizes a DaemonSet.

type Environment

type Environment struct {
	envtest.Environment
	Client client.Client
	Ctx    context.Context
	// contains filtered or unexported fields
}

Environment is for e2e local testing. It stands up an API Server, ETCD, and a controller-runtime manager. It's possible to run multiple environments simultaneously, as the ports are randomized. A common use case for this is parallel tests using ginkgo's parallelization functionality. The environment is typically instantiated once in a test file and re-used between different test cases. Resources for each test should be isolated into its own namespace.

env := new Local(func(local *Local) {
	// Register test controller with manager
	controllerruntime.NewControllerManagedBy(local.Manager).For(...)
	return nil
})

BeforeSuite(func() { env.Start() }) AfterSuite(func() { env.Stop() })

func NewEnvironment

func NewEnvironment(ctx context.Context, options ...EnvironmentOption) *Environment

func (*Environment) Start

func (e *Environment) Start() (err error)

func (*Environment) Stop

func (e *Environment) Stop() error

type EnvironmentOption

type EnvironmentOption func(env *Environment)

EnvironmentOption passes the local environment to an option function. This is useful for registering controllers with the controller-runtime manager or for customizing Client, Scheme, or other variables.

type NodeOptions

type NodeOptions struct {
	Name          string
	Labels        map[string]string
	Annotations   map[string]string
	ReadyStatus   v1.ConditionStatus
	ReadyReason   string
	Conditions    []v1.NodeCondition
	Unschedulable bool
	Taints        []v1.Taint
	Allocatable   v1.ResourceList
	Finalizers    []string
}

type PDBOptions

type PDBOptions struct {
	Name           string
	Namespace      string
	Labels         map[string]string
	MinAvailable   *intstr.IntOrString
	MaxUnavailable *intstr.IntOrString
}

type PodOptions

type PodOptions struct {
	Name                      string
	Namespace                 string
	OwnerReferences           []metav1.OwnerReference
	Image                     string
	NodeName                  string
	ResourceRequirements      v1.ResourceRequirements
	NodeSelector              map[string]string
	NodeRequirements          []v1.NodeSelectorRequirement
	NodePreferences           []v1.NodeSelectorRequirement
	TopologySpreadConstraints []v1.TopologySpreadConstraint
	Tolerations               []v1.Toleration
	Conditions                []v1.PodCondition
	Annotations               map[string]string
	Labels                    map[string]string
	Finalizers                []string
	DeletionTimestamp         *metav1.Time
	Phase                     v1.PodPhase
}

PodOptions customizes a Pod.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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