api: added sysbatch job type constant to match other schedulers. (#13359)

This commit is contained in:
James Rasell 2022-06-16 11:53:04 +02:00 committed by GitHub
parent 4aa96d5bfc
commit f1f7c5040b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 0 deletions

3
.changelog/13359.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvements
api: Added `NewSysbatchJob` helper function to create a base sysbatch job object
```

View File

@ -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{

View File

@ -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}