test

package
v0.0.0-...-3080b95 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractPodNames

func ExtractPodNames(pods []*apiv1.Pod) []string

ExtractPodNames extract pod names from a list of pods

func NewBackoff

func NewBackoff() backoff.Backoff

NewBackoff creates a new backoff object

func NewScaleTestAutoscalingContext

func NewScaleTestAutoscalingContext(
	options config.AutoscalingOptions, fakeClient kube_client.Interface,
	listers kube_util.ListerRegistry, provider cloudprovider.CloudProvider,
	processorCallbacks processor_callbacks.ProcessorCallbacks, debuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter,
) (context.AutoscalingContext, error)

NewScaleTestAutoscalingContext creates a new test autoscaling context for scaling tests.

Types

type GroupSizeChange

type GroupSizeChange struct {
	GroupName  string
	SizeChange int
}

GroupSizeChange represents a change in group size

type MockAutoprovisioningNodeGroupListProcessor

type MockAutoprovisioningNodeGroupListProcessor struct {
	T *testing.T
}

MockAutoprovisioningNodeGroupListProcessor is a fake node group list processor to be used in tests

func (*MockAutoprovisioningNodeGroupListProcessor) CleanUp

CleanUp doesn't do anything; it's here to satisfy the interface

func (*MockAutoprovisioningNodeGroupListProcessor) Process

Process extends the list of node groups

type MockAutoprovisioningNodeGroupManager

type MockAutoprovisioningNodeGroupManager struct {
	T           *testing.T
	ExtraGroups int
}

MockAutoprovisioningNodeGroupManager is a mock node group manager to be used in tests

func (*MockAutoprovisioningNodeGroupManager) CleanUp

CleanUp doesn't do anything; it's here to satisfy the interface

func (*MockAutoprovisioningNodeGroupManager) CreateNodeGroup

CreateNodeGroup creates a new node group

func (*MockAutoprovisioningNodeGroupManager) CreateNodeGroupAsync

CreateNodeGroupAsync simulates async node group creation. Returns upcoming node groups, never calls initializer.

func (*MockAutoprovisioningNodeGroupManager) RemoveUnneededNodeGroups

func (p *MockAutoprovisioningNodeGroupManager) RemoveUnneededNodeGroups(context *context.AutoscalingContext) (removedNodeGroups []cloudprovider.NodeGroup, err error)

RemoveUnneededNodeGroups removes uneeded node groups

type MockBinpackingLimiter

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

MockBinpackingLimiter is a fake BinpackingLimiter to be used in tests.

func (*MockBinpackingLimiter) FinalizeBinpacking

func (p *MockBinpackingLimiter) FinalizeBinpacking(context *context.AutoscalingContext, finalOptions []expander.Option)

FinalizeBinpacking is here to satisfy the interface.

func (*MockBinpackingLimiter) InitBinpacking

func (p *MockBinpackingLimiter) InitBinpacking(context *context.AutoscalingContext, nodeGroups []cloudprovider.NodeGroup)

InitBinpacking initialises the MockBinpackingLimiter and sets requiredExpansionOptions to 1.

func (*MockBinpackingLimiter) MarkProcessed

func (p *MockBinpackingLimiter) MarkProcessed(context *context.AutoscalingContext, nodegroupId string)

MarkProcessed is here to satisfy the interface.

func (*MockBinpackingLimiter) StopBinpacking

func (p *MockBinpackingLimiter) StopBinpacking(context *context.AutoscalingContext, evaluatedOptions []expander.Option) bool

StopBinpacking stops the binpacking early, if we already have requiredExpansionOptions i.e. 1.

type MockReportingStrategy

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

MockReportingStrategy implements expander.Strategy

func NewMockRepotingStrategy

func NewMockRepotingStrategy(t *testing.T, optionToChoose *GroupSizeChange) *MockReportingStrategy

NewMockRepotingStrategy creates an expander strategy with reporting and mocking capabilities.

func (*MockReportingStrategy) BestOption

func (r *MockReportingStrategy) BestOption(options []expander.Option, nodeInfo map[string]*framework.NodeInfo) *expander.Option

BestOption satisfies the Strategy interface. Picks the best option from those passed as an argument. When parameter optionToChoose is defined, it's picked as the best one. Otherwise, random option is used.

func (*MockReportingStrategy) LastInputOptions

func (r *MockReportingStrategy) LastInputOptions() []GroupSizeChange

LastInputOptions provides access to expansion options passed as an input in recent strategy execution

type NodeConfig

type NodeConfig struct {
	Name   string
	Cpu    int64
	Memory int64
	Gpu    int64
	Ready  bool
	Group  string
}

NodeConfig is a node config used in tests

type NodeGroupConfig

type NodeGroupConfig struct {
	Name    string
	MinSize int
	MaxSize int
}

NodeGroupConfig is a node group config used in tests

type NodeTemplateConfig

type NodeTemplateConfig struct {
	MachineType   string
	NodeInfo      *framework.NodeInfo
	NodeGroupName string
}

NodeTemplateConfig is a structure to provide node info in tests

type PodConfig

type PodConfig struct {
	Name         string
	Cpu          int64
	Memory       int64
	Gpu          int64
	Node         string
	ToleratesGpu bool
}

PodConfig is a pod config used in tests

type ScaleTestConfig

type ScaleTestConfig struct {
	Nodes                   []NodeConfig
	Pods                    []PodConfig
	ExtraPods               []PodConfig
	Options                 config.AutoscalingOptions
	NodeDeletionTracker     *deletiontracker.NodeDeletionTracker
	ExpansionOptionToChoose GroupSizeChange // this will be selected by assertingStrategy.BestOption

	ExpectedScaleDowns     []string
	ExpectedScaleDownCount int
}

ScaleTestConfig represents a config of a scale test

type ScaleTestResults

type ScaleTestResults struct {
	ExpansionOptions []GroupSizeChange
	GroupTargetSizes map[string]int
	FinalOption      GroupSizeChange
	NoScaleUpReason  string
	FinalScaleDowns  []string
	Events           []string
	ScaleUpStatus    ScaleUpStatusInfo
}

ScaleTestResults contains results of a scale test

type ScaleUpStatusInfo

type ScaleUpStatusInfo struct {
	Result                  status.ScaleUpResult
	PodsTriggeredScaleUp    []string
	PodsRemainUnschedulable []string
	PodsAwaitEvaluation     []string
}

ScaleUpStatusInfo is a simplified form of a ScaleUpStatus, to avoid mocking actual NodeGroup and Pod objects in test config.

func (*ScaleUpStatusInfo) WasSuccessful

func (s *ScaleUpStatusInfo) WasSuccessful() bool

WasSuccessful returns true iff scale up was successful

type ScaleUpTestConfig

type ScaleUpTestConfig struct {
	Groups                  []NodeGroupConfig
	Nodes                   []NodeConfig
	Pods                    []PodConfig
	ExtraPods               []PodConfig
	OnScaleUp               testcloudprovider.OnScaleUpFunc
	OnCreateGroup           testcloudprovider.OnNodeGroupCreateFunc
	ExpansionOptionToChoose *GroupSizeChange
	Options                 *config.AutoscalingOptions
	NodeTemplateConfigs     map[string]*NodeTemplateConfig
	EnableAutoprovisioning  bool
	AllOrNothing            bool
}

ScaleUpTestConfig represents a config of a scale test

type ScaleUpTestResult

type ScaleUpTestResult struct {
	ScaleUpError     errors.AutoscalerError
	ScaleUpStatus    ScaleUpStatusInfo
	GroupSizeChanges []GroupSizeChange
	ExpansionOptions []GroupSizeChange
	Events           []string
	GroupTargetSizes map[string]int
}

ScaleUpTestResult represents a node groups scale up result

Jump to

Keyboard shortcuts

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