test

package
v0.0.0-...-d4de337 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: Apache-2.0 Imports: 15 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 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