test

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTestPolicy

func BuildTestPolicy(containerName, minCPU, maxCPU, minMemory, maxMemory string) *vpa_types.PodResourcePolicy

BuildTestPolicy creates ResourcesPolicy with specified constraints

func Container

func Container() *containerBuilder

Container returns object that helps build containers for tests.

func FakeEventRecorder

func FakeEventRecorder() record.EventRecorder

FakeEventRecorder returns a dummy implementation of record.EventRecorder.

func LimitRange

func LimitRange() *limitRangeBuilder

LimitRange returns an object that helps build a LimitRangeItem object for tests.

func Resources

func Resources(cpu, mem string) apiv1.ResourceList

Resources creates a ResourceList with given amount of cpu and memory.

Types

type FakeRecommendationProcessor

type FakeRecommendationProcessor struct{}

FakeRecommendationProcessor is a dummy implementation of RecommendationProcessor

func (*FakeRecommendationProcessor) Apply

Apply is a dummy implementation of RecommendationProcessor.Apply which returns provided podRecommendation

type PodBuilder

type PodBuilder interface {
	WithName(name string) PodBuilder
	AddContainer(container apiv1.Container) PodBuilder
	WithCreator(creatorObjectMeta *metav1.ObjectMeta, creatorTypeMeta *metav1.TypeMeta) PodBuilder
	WithLabels(labels map[string]string) PodBuilder
	WithAnnotations(annotations map[string]string) PodBuilder
	WithPhase(phase apiv1.PodPhase) PodBuilder
	Get() *apiv1.Pod
}

PodBuilder helps building pods for tests.

func Pod

func Pod() PodBuilder

Pod returns new PodBuilder.

type PodListerMock

type PodListerMock struct {
	mock.Mock
}

PodListerMock is a mock of PodLister

func (*PodListerMock) Get

func (m *PodListerMock) Get(name string) (*apiv1.Pod, error)

Get is not implemented for this mock

func (*PodListerMock) List

func (m *PodListerMock) List(selector labels.Selector) (ret []*apiv1.Pod, err error)

List is a mock implementation of PodLister.List

func (*PodListerMock) Pods

func (m *PodListerMock) Pods(namespace string) v1.PodNamespaceLister

Pods is a mock implementation of PodLister.Pods

type PodsEvictionRestrictionMock

type PodsEvictionRestrictionMock struct {
	mock.Mock
}

PodsEvictionRestrictionMock is a mock of PodsEvictionRestriction

func (*PodsEvictionRestrictionMock) CanEvict

func (m *PodsEvictionRestrictionMock) CanEvict(pod *apiv1.Pod) bool

CanEvict is a mock implementation of PodsEvictionRestriction.CanEvict

func (*PodsEvictionRestrictionMock) Evict

func (m *PodsEvictionRestrictionMock) Evict(pod *apiv1.Pod, eventRecorder record.EventRecorder) error

Evict is a mock implementation of PodsEvictionRestriction.Evict

type RecommendationBuilder

type RecommendationBuilder interface {
	WithContainer(containerName string) RecommendationBuilder
	WithTarget(cpu, memory string) RecommendationBuilder
	WithTargetResource(resource apiv1.ResourceName, value string) RecommendationBuilder
	WithLowerBound(cpu, memory string) RecommendationBuilder
	WithUpperBound(cpu, memory string) RecommendationBuilder
	Get() *vpa_types.RecommendedPodResources
	GetContainerResources() vpa_types.RecommendedContainerResources
}

RecommendationBuilder helps building test instances of RecommendedPodResources.

func Recommendation

func Recommendation() RecommendationBuilder

Recommendation returns a new RecommendationBuilder.

type RecommendationProcessorMock

type RecommendationProcessorMock struct {
	mock.Mock
}

RecommendationProcessorMock is mock implementation of RecommendationProcessor

func (*RecommendationProcessorMock) Apply

Apply is a mock implementation of RecommendationProcessor.Apply

type RecommenderAPIMock

type RecommenderAPIMock struct {
	mock.Mock
}

RecommenderAPIMock is a mock of RecommenderAPI

func (*RecommenderAPIMock) GetRecommendation

func (m *RecommenderAPIMock) GetRecommendation(spec *apiv1.PodSpec) (*vpa_types.RecommendedPodResources, error)

GetRecommendation is mock implementation of RecommenderAPI.GetRecommendation

type RecommenderMock

type RecommenderMock struct {
	mock.Mock
}

RecommenderMock is a mock of Recommender

func (*RecommenderMock) Get

Get is a mock implementation of Recommender.Get

type VerticalPodAutoscalerBuilder

type VerticalPodAutoscalerBuilder interface {
	WithName(vpaName string) VerticalPodAutoscalerBuilder
	WithContainer(containerName string) VerticalPodAutoscalerBuilder
	WithNamespace(namespace string) VerticalPodAutoscalerBuilder
	WithUpdateMode(updateMode vpa_types.UpdateMode) VerticalPodAutoscalerBuilder
	WithCreationTimestamp(timestamp time.Time) VerticalPodAutoscalerBuilder
	WithMinAllowed(containerName, cpu, memory string) VerticalPodAutoscalerBuilder
	WithMaxAllowed(containerName, cpu, memory string) VerticalPodAutoscalerBuilder
	WithControlledValues(containerName string, mode vpa_types.ContainerControlledValues) VerticalPodAutoscalerBuilder
	WithScalingMode(containerName string, scalingMode vpa_types.ContainerScalingMode) VerticalPodAutoscalerBuilder
	WithTarget(cpu, memory string) VerticalPodAutoscalerBuilder
	WithTargetResource(resource core.ResourceName, value string) VerticalPodAutoscalerBuilder
	WithLowerBound(cpu, memory string) VerticalPodAutoscalerBuilder
	WithTargetRef(targetRef *autoscaling.CrossVersionObjectReference) VerticalPodAutoscalerBuilder
	WithUpperBound(cpu, memory string) VerticalPodAutoscalerBuilder
	WithAnnotations(map[string]string) VerticalPodAutoscalerBuilder
	WithRecommender(string2 string) VerticalPodAutoscalerBuilder
	WithGroupVersion(gv meta.GroupVersion) VerticalPodAutoscalerBuilder
	WithEvictionRequirements([]*vpa_types.EvictionRequirement) VerticalPodAutoscalerBuilder
	WithMinReplicas(minReplicas *int32) VerticalPodAutoscalerBuilder
	AppendCondition(conditionType vpa_types.VerticalPodAutoscalerConditionType,
		status core.ConditionStatus, reason, message string, lastTransitionTime time.Time) VerticalPodAutoscalerBuilder
	AppendRecommendation(vpa_types.RecommendedContainerResources) VerticalPodAutoscalerBuilder
	Get() *vpa_types.VerticalPodAutoscaler
}

VerticalPodAutoscalerBuilder helps building test instances of VerticalPodAutoscaler.

func VerticalPodAutoscaler

func VerticalPodAutoscaler() VerticalPodAutoscalerBuilder

VerticalPodAutoscaler returns a new VerticalPodAutoscalerBuilder.

type VerticalPodAutoscalerListerMock

type VerticalPodAutoscalerListerMock struct {
	mock.Mock
}

VerticalPodAutoscalerListerMock is a mock of VerticalPodAutoscalerLister or VerticalPodAutoscalerNamespaceLister - the crucial List method is the same.

func (*VerticalPodAutoscalerListerMock) Get

Get is not implemented for this mock

func (*VerticalPodAutoscalerListerMock) List

List is a mock implementation of VerticalPodAutoscalerLister.List

func (*VerticalPodAutoscalerListerMock) VerticalPodAutoscalers

VerticalPodAutoscalers is a mock implementation of returning a lister for namespace.

type VerticalPodAutoscalerV1Beta1ListerMock

type VerticalPodAutoscalerV1Beta1ListerMock struct {
	mock.Mock
}

VerticalPodAutoscalerV1Beta1ListerMock is a mock of VerticalPodAutoscalerLister or VerticalPodAutoscalerNamespaceLister - the crucial List method is the same.

func (*VerticalPodAutoscalerV1Beta1ListerMock) Get

Get is not implemented for this mock

func (*VerticalPodAutoscalerV1Beta1ListerMock) List

List is a mock implementation of VerticalPodAutoscalerLister.List

func (*VerticalPodAutoscalerV1Beta1ListerMock) VerticalPodAutoscalers

VerticalPodAutoscalers is a mock implementation of returning a lister for namespace.

Jump to

Keyboard shortcuts

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