package job
import "k8s.io/kubernetes/test/e2e/framework/job"
Index ¶
- Constants
- func CreateJob(ctx context.Context, c clientset.Interface, ns string, job *batchv1.Job) (*batchv1.Job, error)
- func GetAllRunningJobPods(ctx context.Context, c clientset.Interface, ns, jobName string) ([]v1.Pod, error)
- func GetJob(ctx context.Context, c clientset.Interface, ns, name string) (*batchv1.Job, error)
- func GetJobPods(ctx context.Context, c clientset.Interface, ns, jobName string) (*v1.PodList, error)
- func NewTestJob(behavior, name string, rPol v1.RestartPolicy, parallelism, completions int32, activeDeadlineSeconds *int64, backoffLimit int32) *batchv1.Job
- func NewTestJobOnNode(behavior, name string, rPol v1.RestartPolicy, parallelism, completions int32, activeDeadlineSeconds *int64, backoffLimit int32, nodeName string) *batchv1.Job
- func UpdateJob(ctx context.Context, c clientset.Interface, ns string, job *batchv1.Job) (*batchv1.Job, error)
- func WaitForAllJobPodsGone(ctx context.Context, c clientset.Interface, ns, jobName string) error
- func WaitForJobComplete(ctx context.Context, c clientset.Interface, ns, jobName string, reason string, completions int32) error
- func WaitForJobCondition(ctx context.Context, c clientset.Interface, ns, jobName string, cType batchv1.JobConditionType, reason *string) error
- func WaitForJobFailed(ctx context.Context, c clientset.Interface, ns, jobName string) error
- func WaitForJobFinish(ctx context.Context, c clientset.Interface, ns, jobName string) error
- func WaitForJobFinishWithTimeout(ctx context.Context, c clientset.Interface, ns, jobName string, timeout time.Duration) error
- func WaitForJobGone(ctx context.Context, c clientset.Interface, ns, jobName string, timeout time.Duration) error
- func WaitForJobPodsRunning(ctx context.Context, c clientset.Interface, ns, jobName string, expectedCount int32) error
- func WaitForJobPodsRunningWithTimeout(ctx context.Context, c clientset.Interface, ns, jobName string, expectedCount int32, timeout time.Duration) error
- func WaitForJobPodsSucceeded(ctx context.Context, c clientset.Interface, ns, jobName string, expectedCount int32) error
- func WaitForJobReady(ctx context.Context, c clientset.Interface, ns, jobName string, ready *int32) error
- func WaitForJobState(ctx context.Context, c clientset.Interface, ns, jobName string, timeout time.Duration, state JobState) error
- func WaitForJobSuspend(ctx context.Context, c clientset.Interface, ns, jobName string) error
- type JobState
Constants ¶
const ( // JobTimeout is how long to wait for a job to finish. JobTimeout = 15 * time.Minute // JobSelectorKey is a job selector name JobSelectorKey = "job" )
Functions ¶
func CreateJob ¶
func CreateJob(ctx context.Context, c clientset.Interface, ns string, job *batchv1.Job) (*batchv1.Job, error)
CreateJob uses c to create job in namespace ns. If the returned error is nil, the returned Job is valid and has been created.
func GetAllRunningJobPods ¶
func GetAllRunningJobPods(ctx context.Context, c clientset.Interface, ns, jobName string) ([]v1.Pod, error)
GetAllRunningJobPods returns a list of all running Pods belonging to a Job.
func GetJob ¶
GetJob uses c to get the Job in namespace ns named name. If the returned error is nil, the returned Job is valid.
func GetJobPods ¶
func GetJobPods(ctx context.Context, c clientset.Interface, ns, jobName string) (*v1.PodList, error)
GetJobPods returns a list of Pods belonging to a Job.
func NewTestJob ¶
func NewTestJob(behavior, name string, rPol v1.RestartPolicy, parallelism, completions int32, activeDeadlineSeconds *int64, backoffLimit int32) *batchv1.Job
NewTestJob returns a Job which does one of several testing behaviors. notTerminate starts a Job that will run effectively forever. fail starts a Job that will fail immediately. succeed starts a Job that will succeed immediately. randomlySucceedOrFail starts a Job that will succeed or fail randomly. failOnce fails the Job the first time it is run and succeeds subsequently. name is the Name of the Job. RestartPolicy indicates the restart policy of the containers in which the Pod is running. Parallelism is the Job's parallelism, and completions is the Job's required number of completions.
func NewTestJobOnNode ¶
func NewTestJobOnNode(behavior, name string, rPol v1.RestartPolicy, parallelism, completions int32, activeDeadlineSeconds *int64, backoffLimit int32, nodeName string) *batchv1.Job
NewTestJobOnNode is similar to NewTestJob but supports specifying a Node on which the Job's Pods will run. Empty nodeName means no node selection constraints.
func UpdateJob ¶
func UpdateJob(ctx context.Context, c clientset.Interface, ns string, job *batchv1.Job) (*batchv1.Job, error)
UpdateJob uses c to update a job in namespace ns. If the returned error is nil, the returned Job is valid and has been updated.
func WaitForAllJobPodsGone ¶
WaitForAllJobPodsGone waits for all pods for the Job named jobName in namespace ns to be deleted.
func WaitForJobComplete ¶
func WaitForJobComplete(ctx context.Context, c clientset.Interface, ns, jobName string, reason string, completions int32) error
WaitForJobComplete uses c to wait for completions to complete for the Job jobName in namespace ns. This function checks if the number of succeeded Job Pods reached expected completions and the Job has a "Complete" condition with the expected reason.
func WaitForJobCondition ¶
func WaitForJobCondition(ctx context.Context, c clientset.Interface, ns, jobName string, cType batchv1.JobConditionType, reason *string) error
WaitForJobCondition waits for the specified Job to have the expected condition with the specific reason. When the nil reason is passed, the "reason" string in the condition is not checked.
func WaitForJobFailed ¶
WaitForJobFailed uses c to wait for the Job jobName in namespace ns to fail
func WaitForJobFinish ¶
WaitForJobFinish uses c to wait for the Job jobName in namespace ns to finish (either Failed or Complete).
func WaitForJobFinishWithTimeout ¶
func WaitForJobFinishWithTimeout(ctx context.Context, c clientset.Interface, ns, jobName string, timeout time.Duration) error
WaitForJobFinishWithTimeout uses c to wait for the Job jobName in namespace ns to finish (either Failed or Complete).
func WaitForJobGone ¶
func WaitForJobGone(ctx context.Context, c clientset.Interface, ns, jobName string, timeout time.Duration) error
WaitForJobGone uses c to wait for up to timeout for the Job named jobName in namespace ns to be removed.
func WaitForJobPodsRunning ¶
func WaitForJobPodsRunning(ctx context.Context, c clientset.Interface, ns, jobName string, expectedCount int32) error
WaitForJobPodsRunning wait for all pods for the Job named JobName in namespace ns to become Running. Only use when pods will run for a long time, or it will be racy.
func WaitForJobPodsRunningWithTimeout ¶
func WaitForJobPodsRunningWithTimeout(ctx context.Context, c clientset.Interface, ns, jobName string, expectedCount int32, timeout time.Duration) error
WaitForJobPodsRunningWithTimeout wait for all pods for the Job named JobName in namespace ns to become Running. Only use when pods will run for a long time, or it will be racy. same as WaitForJobPodsRunning but with an additional timeout parameter
func WaitForJobPodsSucceeded ¶
func WaitForJobPodsSucceeded(ctx context.Context, c clientset.Interface, ns, jobName string, expectedCount int32) error
WaitForJobPodsSucceeded wait for all pods for the Job named JobName in namespace ns to become Succeeded.
func WaitForJobReady ¶
func WaitForJobReady(ctx context.Context, c clientset.Interface, ns, jobName string, ready *int32) error
WaitForJobReady waits for particular value of the Job .status.ready field
func WaitForJobState ¶
func WaitForJobState(ctx context.Context, c clientset.Interface, ns, jobName string, timeout time.Duration, state JobState) error
WaitForJobState waits for a job to be matched to the given state function.
func WaitForJobSuspend ¶
WaitForJobSuspend uses c to wait for suspend condition for the Job jobName in namespace ns.
Types ¶
type JobState ¶
JobState is used to verify if Job matches a particular condition. If it matches, an empty string is returned. Otherwise, the string explains why the condition is not matched. This should be a short string. A dump of the job object will get added by the caller.
Source Files ¶
const.go fixtures.go rest.go wait.go
- Version
- v1.33.0 (latest)
- Published
- Apr 23, 2025
- Platform
- linux/amd64
- Imports
- 16 packages
- Last checked
- 3 hours ago –
Tools for package owners.