api: added sysbatch job type constant to match other schedulers. (#13359)
This commit is contained in:
parent
4aa96d5bfc
commit
f1f7c5040b
|
@ -0,0 +1,3 @@
|
|||
```release-note:improvements
|
||||
api: Added `NewSysbatchJob` helper function to create a base sysbatch job object
|
||||
```
|
11
api/jobs.go
11
api/jobs.go
|
@ -20,6 +20,10 @@ const (
|
|||
// JobTypeSystem indicates a system process that should run on all clients
|
||||
JobTypeSystem = "system"
|
||||
|
||||
// JobTypeSysbatch indicates a short-lived system process that should run
|
||||
// on all clients.
|
||||
JobTypeSysbatch = "sysbatch"
|
||||
|
||||
// PeriodicSpecCron is used for a cron spec.
|
||||
PeriodicSpecCron = "cron"
|
||||
|
||||
|
@ -1085,6 +1089,13 @@ func NewSystemJob(id, name, region string, pri int) *Job {
|
|||
return newJob(id, name, region, JobTypeSystem, pri)
|
||||
}
|
||||
|
||||
// NewSysbatchJob creates and returns a new sysbatch-style job for short-lived
|
||||
// processes designed to run on all clients, using the provided name and ID
|
||||
// along with the relative job priority.
|
||||
func NewSysbatchJob(id, name, region string, pri int) *Job {
|
||||
return newJob(id, name, region, JobTypeSysbatch, pri)
|
||||
}
|
||||
|
||||
// newJob is used to create a new Job struct.
|
||||
func newJob(id, name, region, typ string, pri int) *Job {
|
||||
return &Job{
|
||||
|
|
|
@ -1993,6 +1993,19 @@ func TestJobs_NewSystemJob(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestJobs_NewSysbatchJob(t *testing.T) {
|
||||
testutil.Parallel(t)
|
||||
job := NewSysbatchJob("job1", "myjob", "global", 5)
|
||||
expect := &Job{
|
||||
Region: stringToPtr("global"),
|
||||
ID: stringToPtr("job1"),
|
||||
Name: stringToPtr("myjob"),
|
||||
Type: stringToPtr(JobTypeSysbatch),
|
||||
Priority: intToPtr(5),
|
||||
}
|
||||
require.Equal(t, expect, job)
|
||||
}
|
||||
|
||||
func TestJobs_SetMeta(t *testing.T) {
|
||||
testutil.Parallel(t)
|
||||
job := &Job{Meta: nil}
|
||||
|
|
Loading…
Reference in New Issue