uthelper

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains[T comparable](elements []T, key T) bool

Contains compares a key in a slice and returns true if exist in it

func RegisterPlugins added in v1.10.0

func RegisterPlugins(plugins map[string]framework.PluginBuilder)

RegisterPlugins plugins

Types

type Interface

type Interface interface {
	// Run executes the actions
	Run(actions []framework.Action)
	// RegisterSession init the session
	RegisterSession(tiers []conf.Tier, config []conf.Configuration) *framework.Session
	// Close release session and do cleanup
	Close()
	// CheckAll do all checks
	CheckAll(caseIndex int) (err error)
	// CheckBind just check bind results in allocate action
	CheckBind(caseIndex int) error
	// CheckEvict just check evict results in preempt or reclaim action
	CheckEvict(caseIndex int) error
	// CheckPipelined check the pipelined results
	CheckPipelined(caseIndex int) error
	// CheckPGStatus check job's status
	CheckPGStatus(caseIndex int) error
}

Interface is UT framework interface

type TestCommonStruct

type TestCommonStruct struct {
	// Name test case name
	Name string
	// Plugins plugins for each case
	Plugins map[string]framework.PluginBuilder
	// Resource objects that need to be added to schedulercache
	Pods           []*v1.Pod
	Nodes          []*v1.Node
	PodGroups      []*vcapisv1.PodGroup
	Queues         []*vcapisv1.Queue
	PriClass       []*schedulingv1.PriorityClass
	ResourceQuotas []*v1.ResourceQuota

	// ExpectBindMap the expected bind results.
	// bind results: ns/podName -> nodeName
	ExpectBindMap map[string]string
	// ExpectPipeLined the expected pipelined results.
	// pipelined results: map[jobID][]{nodeName}
	ExpectPipeLined map[string][]string
	// ExpectEvicted the expected evicted results.
	// evicted pods list of ns/podName
	ExpectEvicted []string
	// ExpectStatus the expected final podgroup status.
	ExpectStatus map[api.JobID]scheduling.PodGroupPhase
	// ExpectBindsNum the expected bind events numbers.
	ExpectBindsNum int
	// ExpectEvictNum the expected evict events numbers, include preempted and reclaimed evict events
	ExpectEvictNum int
	// contains filtered or unexported fields
}

TestCommonStruct is the most common used resource when do UT others can wrap it in a new struct

func (*TestCommonStruct) CheckAll

func (test *TestCommonStruct) CheckAll(caseIndex int) (err error)

CheckAll checks all the need status

func (*TestCommonStruct) CheckBind

func (test *TestCommonStruct) CheckBind(caseIndex int) error

CheckBind check expected bind result

func (*TestCommonStruct) CheckEvict

func (test *TestCommonStruct) CheckEvict(caseIndex int) error

CheckEvict check the evicted result

func (*TestCommonStruct) CheckPGStatus

func (test *TestCommonStruct) CheckPGStatus(caseIndex int) error

CheckPGStatus check job's podgroups status

func (*TestCommonStruct) CheckPipelined

func (test *TestCommonStruct) CheckPipelined(caseIndex int) error

CheckPipelined checks pipeline results

func (*TestCommonStruct) Close

func (test *TestCommonStruct) Close()

Close do release resource and clean up

func (*TestCommonStruct) RegisterSession added in v1.10.0

func (test *TestCommonStruct) RegisterSession(tiers []conf.Tier, config []conf.Configuration) *framework.Session

RegisterSession open session with tiers and configuration, and mock schedulerCache with self-defined FakeBinder and FakeEvictor

func (*TestCommonStruct) Run

func (test *TestCommonStruct) Run(actions []framework.Action)

Run choose to run passed in actions; if no actions provided, will panic

Jump to

Keyboard shortcuts

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