test

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFakeClient

func BuildFakeClient(nodes []*corev1.Node, pods []*corev1.Pod) (*fake.Clientset, <-chan string)

BuildFakeClient creates a fake client

func BuildTestNode

func BuildTestNode(opts NodeOpts) *corev1.Node

BuildTestNode creates a node with specified capacity.

func BuildTestNodes

func BuildTestNodes(amount int, opts NodeOpts) []*corev1.Node

BuildTestNodes creates multiple nodes with the same options

func BuildTestPod

func BuildTestPod(opts PodOpts) *corev1.Pod

BuildTestPod builds a pod for testing

func BuildTestPods

func BuildTestPods(amount int, opts PodOpts) []*corev1.Pod

BuildTestPods creates multiple pods with the same options

func NameFromChan

func NameFromChan(c <-chan string, timeout time.Duration) string

NameFromChan returns a name from a channel update fails if timeout

func NewTestNodeWatcher

func NewTestNodeWatcher(nodes []*v1.Node, opts NodeListerOptions) *nodeLister

NewTestNodeWatcher creates a new mock NodeLister with the given nodes and options

func NewTestPodWatcher

func NewTestPodWatcher(pods []*v1.Pod, opts PodListerOptions) *podLister

NewTestPodWatcher creates a new test PodLister with given pods and options

Types

type FlatScenario

type FlatScenario struct {
	Nodegroups          []*atlassianv1.NodeGroup
	Nodes               []*corev1.Node
	Pods                []*corev1.Pod
	Daemonsets          []*appsv1.DaemonSet
	ControllerRevisions []*appsv1.ControllerRevision
}

FlatScenario is a scenario of nodegroups and related components flatted into a single list

func FlattenScenario

func FlattenScenario(scenario *Scenario, includeKeys ...string) *FlatScenario

FlattenScenario turns a Scenario into a FlatScenario

func (*FlatScenario) NodeGroupList

func (f *FlatScenario) NodeGroupList() atlassianv1.NodeGroupList

type MockAutoscalingService

type MockAutoscalingService struct {
	autoscalingiface.AutoScalingAPI
	*client.Client

	DescribeAutoScalingGroupsOutput *autoscaling.DescribeAutoScalingGroupsOutput
	DescribeAutoScalingGroupsErr    error

	SetDesiredCapacityOutput *autoscaling.SetDesiredCapacityOutput
	SetDesiredCapacityErr    error

	TerminateInstanceInAutoScalingGroupOutput *autoscaling.TerminateInstanceInAutoScalingGroupOutput
	TerminateInstanceInAutoScalingGroupErr    error
}

MockAutoscalingService is a mock implementation of a cloud provider interface

func (MockAutoscalingService) DescribeAutoScalingGroups

DescribeAutoScalingGroups mock implementation for MockAutoscalingService

func (MockAutoscalingService) SetDesiredCapacity

SetDesiredCapacity mock implementation for MockAutoscalingService

func (MockAutoscalingService) TerminateInstanceInAutoScalingGroup

TerminateInstanceInAutoScalingGroup mock implementation for MockAutoscalingService

type MockEc2Service

type MockEc2Service struct {
	ec2iface.EC2API
	*client.Client

	DescribeInstancesOutput *ec2.DescribeInstancesOutput
	DescribeInstancesErr    error
}

MockEc2Service mocks the EC2API for DescribeInstances

func (MockEc2Service) DescribeInstances

DescribeInstances mock implementation for MockAutoscalingService

type NodeListerOptions

type NodeListerOptions struct {
	ReturnErrorOnList bool
}

NodeListerOptions options for creating test NodeLister

type NodeOpts

type NodeOpts struct {
	Name       string
	CPU        int64
	Mem        int64
	LabelKey   string
	LabelValue string
	Creation   time.Time
	Tainted    bool
}

NodeOpts minimal options for configuring a node object in testing

type PodListerOptions

type PodListerOptions struct {
	ReturnErrorOnList bool
}

PodListerOptions for creating a new test PodLister

type PodOpts

type PodOpts struct {
	Name              string
	Namespace         string
	CPU               []int64
	Mem               []int64
	NodeSelectorKey   string
	NodeSelectorValue string
	Owner             string
	OwnerName         string
	NodeAffinityKey   string
	NodeAffinityValue string
	NodeAffinityOp    corev1.NodeSelectorOperator
	NodeName          string
}

PodOpts are options for a pod

type Scenario

type Scenario struct {
	Nodegroups          map[string]*atlassianv1.NodeGroup
	Nodes               map[string][]*corev1.Node
	Pods                map[string][]*corev1.Pod
	Daemonsets          map[string][]*appsv1.DaemonSet
	ControllerRevisions map[string][]*appsv1.ControllerRevision
}

Scenario is a scenario of nodegroups and related components as a map to list

func BuildTestScenario

func BuildTestScenario(opts ScenarioOpts) *Scenario

BuildTestScenario from a ScenarioOpts

func (*Scenario) Flatten

func (s *Scenario) Flatten() *FlatScenario

type ScenarioOpts

type ScenarioOpts struct {
	Keys      []string
	NodeCount int
	PodCount  int

	PodsUpToDate map[string]bool
}

ScenarioOpts for creating Scenario

Jump to

Keyboard shortcuts

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