test

package
Version: v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const ProviderName = "test"

ProviderName is the mock cloud provider name for these tests

Variables

This section is empty.

Functions

func BuildFakeClient

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

BuildFakeClient creates a fake client

func BuildTestNode

func BuildTestNode(opts NodeOpts) *apiv1.Node

BuildTestNode creates a node with specified capacity.

func BuildTestNodes

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

BuildTestNodes creates multiple nodes with the same options

func BuildTestPod

func BuildTestPod(opts PodOpts) *apiv1.Pod

BuildTestPod builds a pod for testing

func BuildTestPods

func BuildTestPods(amount int, opts PodOpts) []*apiv1.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) (listerv1.NodeLister, error)

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

func NewTestPodWatcher

func NewTestPodWatcher(pods []*v1.Pod, opts PodListerOptions) (listerv1.PodLister, error)

NewTestPodWatcher creates a new test PodLister with given pods and options

Types

type CloudProvider

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

CloudProvider implements the CloudProvider interface

func NewCloudProvider

func NewCloudProvider(nodeGroupSize int) *CloudProvider

NewCloudProvider creates a new test CloudProvider

func (*CloudProvider) GetInstance added in v1.3.0

func (c *CloudProvider) GetInstance(node *v1.Node) (cloudprovider.Instance, error)

GetInstance mock implementation for test.CloudProvider

func (*CloudProvider) GetNodeGroup

func (c *CloudProvider) GetNodeGroup(id string) (cloudprovider.NodeGroup, bool)

GetNodeGroup mock implementation for test.CloudProvider

func (*CloudProvider) Name

func (c *CloudProvider) Name() string

Name mock implementation for test.CloudProvider

func (*CloudProvider) NodeGroups

func (c *CloudProvider) NodeGroups() []cloudprovider.NodeGroup

NodeGroups mock implementation for test.CloudProvider

func (*CloudProvider) Refresh

func (c *CloudProvider) Refresh() error

Refresh mock implementation for test.CloudProvider

func (*CloudProvider) RegisterNodeGroup

func (c *CloudProvider) RegisterNodeGroup(nodeGroup *NodeGroup)

RegisterNodeGroup mock implementation for test.CloudProvider

func (*CloudProvider) RegisterNodeGroups

func (c *CloudProvider) RegisterNodeGroups(groups ...cloudprovider.NodeGroupConfig) error

RegisterNodeGroups mock implementation for test.CloudProvider

type Instance added in v1.3.0

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

Instance mock implementation

func (Instance) ID added in v1.6.0

func (i Instance) ID() string

ID mock mock for test.Instance

func (Instance) InstantiationTime added in v1.3.0

func (i Instance) InstantiationTime() time.Time

InstantiationTime mock for test.Instance

type MockAutoscalingService

type MockAutoscalingService struct {
	autoscalingiface.AutoScalingAPI
	*client.Client

	AttachInstanceOutput *autoscaling.AttachInstancesOutput
	AttachInstanceErr    error

	CreateOrUpdateTagsOutput *autoscaling.CreateOrUpdateTagsOutput
	CreateOrUpdateTagsErr    error

	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) AttachInstances added in v1.10.0

AttachInstances mock implementation for MockAutoscalingService

func (MockAutoscalingService) CreateOrUpdateTags added in v1.11.0

CreateOrUpdateTags mock implementation for MockAutoscalingService

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 added in v1.3.0

type MockEc2Service struct {
	ec2iface.EC2API
	*client.Client

	CreateFleetOutput *ec2.CreateFleetOutput
	CreateFleetErr    error

	DescribeInstancesOutput *ec2.DescribeInstancesOutput
	DescribeInstancesErr    error

	DescribeInstanceStatusOutput *ec2.DescribeInstanceStatusOutput
	DescribeInstanceStatusErr    error
	AllInstancesReady            bool

	TerminateInstancesOutput *ec2.TerminateInstancesOutput
	TerminateInstancesErr    error
}

MockEc2Service mocks the EC2API

func (MockEc2Service) CreateFleet added in v1.10.0

CreateFleet mock implementation for MockEc2Service

func (MockEc2Service) DescribeInstanceStatusPages added in v1.10.0

func (m MockEc2Service) DescribeInstanceStatusPages(statusInput *ec2.DescribeInstanceStatusInput, allInstancesReadyHelper func(*ec2.DescribeInstanceStatusOutput, bool) bool) error

DescribeInstanceStatusPages mock implementation for MockEc2Service

func (MockEc2Service) DescribeInstances added in v1.3.0

DescribeInstances mock implementation for MockEc2Service

func (MockEc2Service) TerminateInstances added in v1.12.0

TerminateInstances mock implementation for MockEc2Service

type NodeGroup

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

NodeGroup is a mock implementation of NodeGroup for testing

func NewNodeGroup

func NewNodeGroup(id string, name string, minSize int64, maxSize int64, targetSize int64) *NodeGroup

NewNodeGroup creates a new mock NodeGroup

func (*NodeGroup) Belongs

func (n *NodeGroup) Belongs(node *v1.Node) bool

Belongs mock implementation for NodeGroup

func (*NodeGroup) DecreaseTargetSize

func (n *NodeGroup) DecreaseTargetSize(delta int64) error

DecreaseTargetSize mock implementation for NodeGroup

func (*NodeGroup) DeleteNodes

func (n *NodeGroup) DeleteNodes(nodes ...*v1.Node) error

DeleteNodes mock implementation for NodeGroup

func (*NodeGroup) ID

func (n *NodeGroup) ID() string

ID mock implementation for NodeGroup

func (*NodeGroup) IncreaseSize

func (n *NodeGroup) IncreaseSize(delta int64) error

IncreaseSize mock implementation for NodeGroup

func (*NodeGroup) MaxSize

func (n *NodeGroup) MaxSize() int64

MaxSize mock implementation for NodeGroup

func (*NodeGroup) MinSize

func (n *NodeGroup) MinSize() int64

MinSize mock implementation for NodeGroup

func (*NodeGroup) Name added in v1.9.0

func (n *NodeGroup) Name() string

Name mock implementation for NodeGroup

func (*NodeGroup) Nodes

func (n *NodeGroup) Nodes() []string

Nodes mock implementation for NodeGroup

func (*NodeGroup) Size

func (n *NodeGroup) Size() int64

Size mock implementation for NodeGroup

func (*NodeGroup) String

func (n *NodeGroup) String() string

String mock implementation for NodeGroup

func (*NodeGroup) TargetSize

func (n *NodeGroup) TargetSize() int64

TargetSize mock implementation for NodeGroup

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
	NodeAffinityKey   string
	NodeAffinityValue string
	NodeAffinityOp    v1.NodeSelectorOperator
	NodeName          string
	CPUOverhead       int64
	MemOverhead       int64
	InitContainersCPU []int64
	InitContainersMem []int64
}

PodOpts are options for a pod

Jump to

Keyboard shortcuts

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