test

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AWSNodeTemplate added in v0.11.0

func AWSNodeTemplate(overrides ...v1alpha1.AWSNodeTemplateSpec) *v1alpha1.AWSNodeTemplate

func DaemonSet

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

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

func Deployment added in v0.14.0

func Deployment(overrides ...DeploymentOptions) *appsv1.Deployment

func MustMerge added in v0.14.0

func MustMerge[T interface{}](dest T, srcs ...T) T

func Node

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

func ObjectMeta added in v0.5.4

func ObjectMeta(overrides ...metav1.ObjectMeta) metav1.ObjectMeta

func PersistentVolume added in v0.5.4

func PersistentVolume(overrides ...PersistentVolumeOptions) *v1.PersistentVolume

func PersistentVolumeClaim added in v0.5.4

func PersistentVolumeClaim(overrides ...PersistentVolumeClaimOptions) *v1.PersistentVolumeClaim

func Pod

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

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

func PodDisruptionBudget

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

PodDisruptionBudget creates a PodDisruptionBudget. To function properly, it should have its status applied

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 Provisioner added in v0.9.1

func Provisioner(overrides ...ProvisionerOptions) *v1alpha5.Provisioner

Provisioner creates a test provisioner with defaults that can be overridden by ProvisionerOptions. Overrides are applied in order, with a last write wins semantic.

func RandomName added in v0.14.0

func RandomName() string

func ReplicaSet added in v0.15.0

func ReplicaSet(overrides ...ReplicaSetOptions) *appsv1.ReplicaSet

ReplicaSet creates a test ReplicaSet with defaults that can be overridden by ReplicaSetOptions. Overrides are applied in order, with a last write wins semantic.

func StorageClass added in v0.5.4

func StorageClass(overrides ...StorageClassOptions) *storagev1.StorageClass

func UnschedulablePod

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

UnschedulablePod creates a test pod with a pending scheduling status condition

Types

type Binding added in v0.10.0

type Binding struct {
	Pod  *v1.Pod
	Node *v1.Node
}

Binding is a potential binding that was reported through event recording.

type Config added in v0.11.0

type Config struct {
	Mu       sync.Mutex
	Handlers []config.ChangeHandler
	// contains filtered or unexported fields
}

func NewConfig added in v0.11.0

func NewConfig() *Config

func (*Config) BatchIdleDuration added in v0.11.0

func (c *Config) BatchIdleDuration() time.Duration

func (*Config) BatchMaxDuration added in v0.11.0

func (c *Config) BatchMaxDuration() time.Duration

func (*Config) OnChange added in v0.11.0

func (c *Config) OnChange(handler config.ChangeHandler)

func (*Config) SetBatchIdleDuration added in v0.11.0

func (c *Config) SetBatchIdleDuration(d time.Duration)

func (*Config) SetBatchMaxDuration added in v0.11.0

func (c *Config) SetBatchMaxDuration(d time.Duration)

type DaemonSetOptions

type DaemonSetOptions struct {
	metav1.ObjectMeta
	Selector   map[string]string
	PodOptions PodOptions
}

DaemonSetOptions customizes a DaemonSet.

type DeploymentOptions added in v0.14.0

type DeploymentOptions struct {
	metav1.ObjectMeta
	Labels     map[string]string
	Replicas   int32
	PodOptions PodOptions
}

type Environment

type Environment struct {
	envtest.Environment
	Client client.Client
	Ctx    context.Context
	K8sVer *version.Version
	// 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 EventRecorder added in v0.10.0

type EventRecorder struct {
	// contains filtered or unexported fields
}

EventRecorder is a mock event recorder that is used to facilitate testing.

func NewEventRecorder added in v0.10.0

func NewEventRecorder() *EventRecorder

func (*EventRecorder) EvictPod added in v0.14.0

func (e *EventRecorder) EvictPod(pod *v1.Pod)

func (*EventRecorder) ForEachBinding added in v0.10.0

func (e *EventRecorder) ForEachBinding(f func(pod *v1.Pod, node *v1.Node))

func (*EventRecorder) LaunchingNodeForConsolidation added in v0.15.0

func (e *EventRecorder) LaunchingNodeForConsolidation(node *v1.Node, reason string)

func (*EventRecorder) NodeFailedToDrain added in v0.14.0

func (e *EventRecorder) NodeFailedToDrain(node *v1.Node, err error)

func (*EventRecorder) NominatePod added in v0.11.0

func (e *EventRecorder) NominatePod(pod *v1.Pod, node *v1.Node)

func (*EventRecorder) PodFailedToSchedule added in v0.10.0

func (e *EventRecorder) PodFailedToSchedule(pod *v1.Pod, err error)

func (*EventRecorder) Reset added in v0.10.0

func (e *EventRecorder) Reset()

func (*EventRecorder) ResetBindings added in v0.10.0

func (e *EventRecorder) ResetBindings()

func (*EventRecorder) TerminatingNodeForConsolidation added in v0.15.0

func (e *EventRecorder) TerminatingNodeForConsolidation(node *v1.Node, reason string)

func (*EventRecorder) WaitingOnDeletionForConsolidation added in v0.16.1

func (e *EventRecorder) WaitingOnDeletionForConsolidation(node *v1.Node)

func (*EventRecorder) WaitingOnReadinessForConsolidation added in v0.15.0

func (e *EventRecorder) WaitingOnReadinessForConsolidation(v *v1.Node)

type NodeOptions

type NodeOptions struct {
	metav1.ObjectMeta
	ReadyStatus   v1.ConditionStatus
	ReadyReason   string
	Conditions    []v1.NodeCondition
	Unschedulable bool
	Taints        []v1.Taint
	Allocatable   v1.ResourceList
}

type PDBOptions

type PDBOptions struct {
	metav1.ObjectMeta
	Labels         map[string]string
	MinAvailable   *intstr.IntOrString
	MaxUnavailable *intstr.IntOrString
	Status         *policyv1.PodDisruptionBudgetStatus
}

type PersistentVolumeClaimOptions added in v0.5.4

type PersistentVolumeClaimOptions struct {
	metav1.ObjectMeta
	StorageClassName *string
	VolumeName       string
	Resources        v1.ResourceRequirements
}

type PersistentVolumeOptions added in v0.5.4

type PersistentVolumeOptions struct {
	metav1.ObjectMeta
	Zones            []string
	StorageClassName string
	Driver           string
}

type PodOptions

type PodOptions struct {
	metav1.ObjectMeta
	Image                     string
	InitImage                 string
	NodeName                  string
	PriorityClassName         string
	InitResourceRequirements  v1.ResourceRequirements
	ResourceRequirements      v1.ResourceRequirements
	NodeSelector              map[string]string
	NodeRequirements          []v1.NodeSelectorRequirement
	NodePreferences           []v1.NodeSelectorRequirement
	PodRequirements           []v1.PodAffinityTerm
	PodPreferences            []v1.WeightedPodAffinityTerm
	PodAntiRequirements       []v1.PodAffinityTerm
	PodAntiPreferences        []v1.WeightedPodAffinityTerm
	TopologySpreadConstraints []v1.TopologySpreadConstraint
	Tolerations               []v1.Toleration
	PersistentVolumeClaims    []string
	Conditions                []v1.PodCondition
	Phase                     v1.PodPhase
	RestartPolicy             v1.RestartPolicy
}

PodOptions customizes a Pod.

func UnscheduleablePodOptions added in v0.9.1

func UnscheduleablePodOptions(overrides ...PodOptions) PodOptions

type ProvisionerOptions added in v0.9.1

type ProvisionerOptions struct {
	metav1.ObjectMeta
	Limits                 v1.ResourceList
	Provider               interface{}
	ProviderRef            *v1alpha5.ProviderRef
	Kubelet                *v1alpha5.KubeletConfiguration
	Labels                 map[string]string
	Taints                 []v1.Taint
	StartupTaints          []v1.Taint
	Requirements           []v1.NodeSelectorRequirement
	Status                 v1alpha5.ProvisionerStatus
	TTLSecondsUntilExpired *int64
	Weight                 *int32
	TTLSecondsAfterEmpty   *int64
	Consolidation          *v1alpha5.Consolidation
}

ProvisionerOptions customizes a Provisioner.

type ReplicaSetOptions added in v0.15.0

type ReplicaSetOptions struct {
	metav1.ObjectMeta
	Selector   map[string]string
	PodOptions PodOptions
}

ReplicaSetOptions customizes a ReplicaSet.

type StorageClassOptions added in v0.5.4

type StorageClassOptions struct {
	metav1.ObjectMeta
	Zones             []string
	Provisioner       *string
	VolumeBindingMode *storagev1.VolumeBindingMode
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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