util

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeOutMessage               = "timed out waiting for the condition"
	WorkerPriority               = "worker-pri"
	WorkerPriorityValue          = -50
	MasterPriority               = "master-pri"
	MasterPriorityValue          = 100
	NodeFieldSelectorKeyNodeName = "metadata.name"
	SchedulerName                = "volcano"
	ExecuteAction                = "ExecuteAction"
	DefaultQueue                 = "default"
	NumStress                    = 10
)
View Source
const (
	DefaultBusyBoxImage = "busybox"
	DefaultNginxImage   = "nginx"
	DefaultMPIImage     = "volcanosh/example-mpi:0.0.3"
	DefaultTFImage      = "volcanosh/dist-mnist-tf-example:0.0.1"
	// "volcanosh/pytorch-mnist-v1beta1-9ee8fda-example:0.0.1" is from "docker.io/kubeflowkatib/pytorch-mnist:v1beta1-9ee8fda"
	DefaultPytorchImage = "volcanosh/pytorch-mnist-v1beta1-9ee8fda-example:0.0.1"
	LogTimeFormat       = "[ 2006/01/02 15:04:05.000 ]"
)

Variables

View Source
var (
	OneMinute  = 1 * time.Minute
	TwoMinute  = 2 * time.Minute
	FiveMinute = 5 * time.Minute
	TenMinute  = 10 * time.Minute
	OneCPU     = v1.ResourceList{"cpu": resource.MustParse("1000m")}
	TwoCPU     = v1.ResourceList{"cpu": resource.MustParse("2000m")}
	ThreeCPU   = v1.ResourceList{"cpu": resource.MustParse("3000m")}
	ThirtyCPU  = v1.ResourceList{"cpu": resource.MustParse("30000m")}
	HalfCPU    = v1.ResourceList{"cpu": resource.MustParse("500m")}
	CPU1Mem1   = v1.ResourceList{"cpu": resource.MustParse("1000m"), "memory": resource.MustParse("1024Mi")}
	CPU2Mem2   = v1.ResourceList{"cpu": resource.MustParse("2000m"), "memory": resource.MustParse("2048Mi")}
	CPU4Mem4   = v1.ResourceList{"cpu": resource.MustParse("4000m"), "memory": resource.MustParse("4096Mi")}
)
View Source
var KubeClient *kubernetes.Clientset

Functions

func CPUResource added in v1.8.0

func CPUResource(request string) v1.ResourceList

func CleanupTestContext

func CleanupTestContext(ctx *TestContext)

func ClusterNodeNumber

func ClusterNodeNumber(ctx *TestContext) int

ClusterNodeNumber returns the number of untainted nodes

func ClusterSize

func ClusterSize(ctx *TestContext, req v1.ResourceList) int32

func ComputeNode

func ComputeNode(ctx *TestContext, req v1.ResourceList) (string, int32)

func CreateContainers

func CreateContainers(img, command, workingDir string, req, limit v1.ResourceList, hostport int32) []v1.Container

func CreateDeployment added in v1.8.0

func CreateDeployment(ctx *TestContext, name string, rep int32, img string, req v1.ResourceList) *appv1.Deployment

func CreateDeploymentGated added in v1.10.0

func CreateDeploymentGated(ctx *TestContext, name string, rep int32, img string, req v1.ResourceList, schGates []v1.PodSchedulingGate) *appv1.Deployment

CreateDeployment creates a new deployment

func CreateFailK8sJob added in v1.11.0

func CreateFailK8sJob(ctx *TestContext, name string, img string, req v1.ResourceList) *batchv1.Job

CreateFailK8sJob creates a new k8s job that fails

func CreateJob

func CreateJob(context *TestContext, jobSpec *JobSpec) *batchv1alpha1.Job

func CreateJobInner

func CreateJobInner(ctx *TestContext, jobSpec *JobSpec) (*batchv1alpha1.Job, error)

func CreateJobWithPodGroup

func CreateJobWithPodGroup(ctx *TestContext, jobSpec *JobSpec,
	pgName string, annotations map[string]string) *batchv1alpha1.Job

func CreatePodGroup added in v1.4.0

func CreatePodGroup(ctx *TestContext, pg string, namespace string) *schedulingv1beta1.PodGroup

CreatePodGroup creates a PodGroup with the specified name in the namespace

func CreateQueue added in v1.4.0

func CreateQueue(ctx *TestContext, q string, deservedResource v1.ResourceList, parent string)

CreateQueue creates Queue with the specified name

func CreateQueueWithQueueSpec added in v1.5.0

func CreateQueueWithQueueSpec(ctx *TestContext, queueSpec *QueueSpec)

func CreateQueues

func CreateQueues(ctx *TestContext)

CreateQueues create Queues specified in the test context

func CreateReplicaSet

func CreateReplicaSet(ctx *TestContext, name string, rep int32, img string, req v1.ResourceList) *appv1.ReplicaSet

CreateReplicaSet creates a new replica set

func CreateSampleK8sJob added in v1.8.0

func CreateSampleK8sJob(ctx *TestContext, name string, img string, req v1.ResourceList) *batchv1.Job

CreateSampleK8sJob creates a new k8s job

func DeleteDeployment added in v1.8.0

func DeleteDeployment(ctx *TestContext, name string) error

func DeleteK8sJob added in v1.8.0

func DeleteK8sJob(ctx *TestContext, name string) error

func DeletePodGroup added in v1.4.0

func DeletePodGroup(ctx *TestContext, pg string, namespace string)

DeletePodGroup deletes a PodGroup with the specified name in the namespace

func DeleteQueue added in v1.4.0

func DeleteQueue(ctx *TestContext, q string)

DeleteQueue deletes Queue with the specified name

func DeleteReplicaSet

func DeleteReplicaSet(ctx *TestContext, name string) error

func FileExist

func FileExist(name string) bool

func GetPodGroupStatistics added in v1.11.0

func GetPodGroupStatistics(ctx *TestContext, namespace, queue string) *podgroup.PodGroupStatistics

func GetTasksOfJob

func GetTasksOfJob(ctx *TestContext, job *batchv1alpha1.Job) []*v1.Pod

GetTasksOfJob returns the tasks belongs to the job

func HomeDir

func HomeDir() string

func IsNodeReady

func IsNodeReady(node *v1.Node) bool

IsNodeReady returns the node ready status

func IsPodScheduled

func IsPodScheduled(pod *v1.Pod) bool

IsPodScheduled returns whether the Pod is scheduled

func JobEvicted

func JobEvicted(ctx *TestContext, job *batchv1alpha1.Job, time time.Time) wait.ConditionFunc

func KubeconfigPath

func KubeconfigPath(home string) string

func MasterURL

func MasterURL() string

func Namespace

func Namespace(context *TestContext, job *JobSpec) string

func NamespaceNotExist

func NamespaceNotExist(ctx *TestContext) wait.ConditionFunc

func NamespaceNotExistWithName

func NamespaceNotExistWithName(ctx *TestContext, name string) wait.ConditionFunc

func PodGroupIsReady

func PodGroupIsReady(ctx *TestContext, namespace string) (bool, error)

PodGroupIsReady returns whether the status of PodGroup is ready

func RemovePodSchGates added in v1.10.0

func RemovePodSchGates(ctx *TestContext, targetJob *batchv1alpha1.Job) error

Remove the scheduling gates (if any) of the tasks of a job at Pod level

func RemoveTaintsFromAllNodes

func RemoveTaintsFromAllNodes(ctx *TestContext, taints []v1.Taint) error

func SetQueueReclaimable

func SetQueueReclaimable(ctx *TestContext, queues []string, reclaimable bool)

SeyQueueReclaimable sets the Queue to be reclaimable

func TaintAllNodes

func TaintAllNodes(ctx *TestContext, taints []v1.Taint) error

TaintAllNodes taints all nodes in the cluster

func UpdateJob

func UpdateJob(ctx *TestContext, job *batchv1alpha1.Job) error

func VolcanoCliBinary

func VolcanoCliBinary() string

VolcanoCliBinary function gets the volcano cli binary.

func WaitDeploymentReady added in v1.8.0

func WaitDeploymentReady(ctx *TestContext, name string) error

func WaitJobCleanedUp

func WaitJobCleanedUp(ctx *TestContext, cleanupjob *batchv1alpha1.Job) error

WaitJobCleanedUp waits for the Job to be cleaned up

func WaitJobPending

func WaitJobPending(ctx *TestContext, job *batchv1alpha1.Job) error

WaitJobPending waits for the Job to be pending

func WaitJobPhaseReady

func WaitJobPhaseReady(ctx *TestContext, job *batchv1.Job) error

func WaitJobPhases

func WaitJobPhases(ctx *TestContext, job *batchv1alpha1.Job, phases []batchv1alpha1.JobPhase) error

func WaitJobReady

func WaitJobReady(ctx *TestContext, job *batchv1alpha1.Job) error

WaitJobReady waits for the Job to be ready

func WaitJobStateAborted

func WaitJobStateAborted(ctx *TestContext, job *batchv1alpha1.Job) error

WaitJobStateAborted waits for the state of a Job to be aborted

func WaitJobStatePending

func WaitJobStatePending(ctx *TestContext, job *batchv1alpha1.Job) error

WaitJobStatePending waits for the state of a Job to be pending

func WaitJobStateReady

func WaitJobStateReady(ctx *TestContext, job *batchv1alpha1.Job) error

WaitJobStateReady waits for the state of a Job to be ready

func WaitJobStates

func WaitJobStates(ctx *TestContext, job *batchv1alpha1.Job, phases []batchv1alpha1.JobPhase, waitTime time.Duration) error

func WaitJobTerminateAction

func WaitJobTerminateAction(ctx *TestContext, pg *batchv1alpha1.Job) error

WaitJobTerminateAction waits for the Job to be terminated

func WaitJobUnschedulable

func WaitJobUnschedulable(ctx *TestContext, job *batchv1alpha1.Job) error

func WaitPodGone

func WaitPodGone(ctx *TestContext, podName, namespace string) error

WaitPodGone waits the Pod to be deleted when aborting a Job

func WaitPodGroupPhase

func WaitPodGroupPhase(ctx *TestContext, podGroup *schedulingv1beta1.PodGroup, state schedulingv1beta1.PodGroupPhase) error

WaitPodGroupPhase waits for the PodGroup to be the specified state

func WaitPodPhase

func WaitPodPhase(ctx *TestContext, pod *v1.Pod, phase []v1.PodPhase) error

WaitPodPhase waits for the Pod to be the specified phase

func WaitPodPhaseRunningMoreThanNum

func WaitPodPhaseRunningMoreThanNum(ctx *TestContext, namespace string, num int) error

WaitPodPhaseRunningMoreThanNum waits for the number of running pods to be more than specified number

func WaitQueueStatus

func WaitQueueStatus(condition func() (bool, error)) error

func WaitReplicaSetReady

func WaitReplicaSetReady(ctx *TestContext, name string) error

func WaitTaskPhase

func WaitTaskPhase(ctx *TestContext, job *batchv1alpha1.Job, phase []v1.PodPhase, taskNum int) error

func WaitTasksCompleted

func WaitTasksCompleted(ctx *TestContext, job *batchv1alpha1.Job, successNum int32) error

WaitTasksCompleted waits for the tasks of a job to be completed

func WaitTasksPending

func WaitTasksPending(ctx *TestContext, job *batchv1alpha1.Job, taskNum int) error

WaitTasksPending waits for the tasks of a Job to be pending

func WaitTasksReady

func WaitTasksReady(ctx *TestContext, job *batchv1alpha1.Job, taskNum int) error

WaitTasksReady waits for the tasks of a Job to be ready

func WaitTasksReadyEx

func WaitTasksReadyEx(ctx *TestContext, job *batchv1alpha1.Job, taskNum map[string]int) error

func Waitk8sJobCompleted added in v1.8.0

func Waitk8sJobCompleted(ctx *TestContext, name string) error

Types

type ConfigMapCase added in v1.6.1

type ConfigMapCase struct {
	NameSpace string
	Name      string // configmap.name
	// contains filtered or unexported fields
}

func NewConfigMapCase added in v1.6.1

func NewConfigMapCase(ns, name string) *ConfigMapCase

func (*ConfigMapCase) ChangeBy added in v1.6.1

func (c *ConfigMapCase) ChangeBy(fn func(data map[string]string) (changed bool, changedBefore map[string]string)) error

ChangeBy call fn and update configmap by changed

func (*ConfigMapCase) UndoChanged added in v1.6.1

func (c *ConfigMapCase) UndoChanged() error

UndoChanged restore configmap if exist undoData

type Configuration added in v1.6.1

type Configuration struct {
	// Name is name of action
	Name string `yaml:"name"`
	// Arguments defines the different arguments that can be given to specified action
	Arguments map[string]string `yaml:"arguments,omitempty"`
}

Configuration is configuration of action

type JobSpec

type JobSpec struct {
	Name      string
	Namespace string
	Queue     string
	Tasks     []TaskSpec
	Policies  []batchv1alpha1.LifecyclePolicy
	Min       int32
	Pri       string
	Plugins   map[string][]string
	Volumes   []batchv1alpha1.VolumeSpec
	NodeName  string
	// ttl seconds after job finished
	TTL        *int32
	MinSuccess *int32
	// job max retry
	MaxRetry int32
}

type Options

type Options struct {
	Namespace          string
	Queues             []string
	DeservedResource   map[string]v1.ResourceList
	QueueParent        map[string]string
	PriorityClasses    map[string]int32
	NodesNumLimit      int
	NodesResourceLimit v1.ResourceList
}

type PluginOption added in v1.6.1

type PluginOption struct {
	// The name of Plugin
	Name string `yaml:"name"`
	// EnabledJobOrder defines whether jobOrderFn is enabled
	EnabledJobOrder *bool `yaml:"enableJobOrder,omitempty"`
	// EnabledHierachy defines whether hierarchical sharing is enabled
	EnabledHierarchy *bool `yaml:"enableHierarchy,omitempty"`
	// EnabledJobReady defines whether jobReadyFn is enabled
	EnabledJobReady *bool `yaml:"enableJobReady,omitempty"`
	// EnabledJobPipelined defines whether jobPipelinedFn is enabled
	EnabledJobPipelined *bool `yaml:"enableJobPipelined,omitempty"`
	// EnabledTaskOrder defines whether taskOrderFn is enabled
	EnabledTaskOrder *bool `yaml:"enableTaskOrder,omitempty"`
	// EnabledPreemptable defines whether preemptableFn is enabled
	EnabledPreemptable *bool `yaml:"enablePreemptable,omitempty"`
	// EnabledReclaimable defines whether reclaimableFn is enabled
	EnabledReclaimable *bool `yaml:"enableReclaimable,omitempty"`
	// EnabledQueueOrder defines whether queueOrderFn is enabled
	EnabledQueueOrder *bool `yaml:"enableQueueOrder,omitempty"`
	// EnabledPredicate defines whether predicateFn is enabled
	EnabledClusterOrder *bool `yaml:"EnabledClusterOrder,omitempty"`
	// EnableClusterOrder defines whether clusterOrderFn is enabled
	EnabledPredicate *bool `yaml:"enablePredicate,omitempty"`
	// EnabledBestNode defines whether bestNodeFn is enabled
	EnabledBestNode *bool `yaml:"enableBestNode,omitempty"`
	// EnabledNodeOrder defines whether NodeOrderFn is enabled
	EnabledNodeOrder *bool `yaml:"enableNodeOrder,omitempty"`
	// EnabledTargetJob defines whether targetJobFn is enabled
	EnabledTargetJob *bool `yaml:"enableTargetJob,omitempty"`
	// EnabledReservedNodes defines whether reservedNodesFn is enabled
	EnabledReservedNodes *bool `yaml:"enableReservedNodes,omitempty"`
	// EnabledJobEnqueued defines whether jobEnqueuedFn is enabled
	EnabledJobEnqueued *bool `yaml:"enableJobEnqueued,omitempty"`
	// EnabledVictim defines whether victimsFn is enabled
	EnabledVictim *bool `yaml:"enabledVictim,omitempty"`
	// EnabledJobStarving defines whether jobStarvingFn is enabled
	EnabledJobStarving *bool `yaml:"enableJobStarving,omitempty"`
	// Arguments defines the different arguments that can be given to different plugins
	Arguments map[string]string `yaml:"arguments,omitempty"`
}

PluginOption defines the options of plugin

type QueueSpec added in v1.5.0

type QueueSpec struct {
	Name              string
	Weight            int32
	GuaranteeResource v1.ResourceList
}

type SchedulerConfiguration added in v1.6.1

type SchedulerConfiguration struct {
	// Actions defines the actions list of scheduler in order
	Actions string `yaml:"actions"`
	// Tiers defines plugins in different tiers
	Tiers []Tier `yaml:"tiers,omitempty"`
	// Configurations is configuration for actions
	Configurations []Configuration `yaml:"configurations,omitempty"`
}

SchedulerConfiguration defines the configuration of scheduler.

type TaskSpec

type TaskSpec struct {
	Name                  string
	Min, Rep              int32
	Img                   string
	Command               string
	WorkingDir            string
	Hostport              int32
	Req                   v1.ResourceList
	Limit                 v1.ResourceList
	Affinity              *v1.Affinity
	Labels                map[string]string
	Policies              []batchv1alpha1.LifecyclePolicy
	RestartPolicy         v1.RestartPolicy
	Tolerations           []v1.Toleration
	DefaultGracefulPeriod *int64
	Taskpriority          string
	MaxRetry              int32
	SchGates              []v1.PodSchedulingGate
}

type TestContext

type TestContext struct {
	Kubeclient *kubernetes.Clientset
	Vcclient   *vcclient.Clientset

	Namespace        string
	Queues           []string
	DeservedResource map[string]v1.ResourceList
	QueueParent      map[string]string
	PriorityClasses  map[string]int32
	UsingPlaceHolder bool
}

func InitTestContext

func InitTestContext(o Options) *TestContext

type Tier added in v1.6.1

type Tier struct {
	Plugins []PluginOption `yaml:"plugins,omitempty"`
}

Tier defines plugin tier

func (Tier) ContainsPlugin added in v1.6.1

func (t Tier) ContainsPlugin(name string) bool

func (Tier) GetPluginIdxOf added in v1.6.1

func (t Tier) GetPluginIdxOf(name string) int

Jump to

Keyboard shortcuts

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