Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Add test for SCHED_BATCH
Browse files Browse the repository at this point in the history
  • Loading branch information
sargun committed Jun 6, 2018
1 parent 9a599d4 commit c2a70b0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions executor/mock/jobrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ type JobInput struct {
IgnoreLaunchGuard bool
// StopTimeoutSeconds is the duration we wait after SIGTERM for the container to exit
KillWaitSeconds uint32
// Batch sets batch mode on the task
Batch bool
}

// JobRunResponse returned from RunJob
Expand Down Expand Up @@ -196,6 +198,7 @@ func (jobRunner *JobRunner) StartJob(jobInput *JobInput) *JobRunResponse {
Capabilities: jobInput.Capabilities,
TitusProvidedEnv: env,
IgnoreLaunchGuard: protobuf.Bool(jobInput.IgnoreLaunchGuard),
Batch: protobuf.Bool(jobInput.Batch),
}

if jobInput.KillWaitSeconds > 0 {
Expand Down
28 changes: 28 additions & 0 deletions executor/mock/standalone/standalone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ func TestStandalone(t *testing.T) {
testTerminateTimeoutNotTooSlow,
testOOMAdj,
testOOMKill,
testSchedBatch,
testSchedNormal,
}
for _, fun := range testFunctions {
fullName := runtime.FuncForPC(reflect.ValueOf(fun).Pointer()).Name()
Expand Down Expand Up @@ -575,3 +577,29 @@ func testOOMKill(t *testing.T, jobID string) {
}
t.Fail()
}

func testSchedBatch(t *testing.T, jobID string) {
ji := &mock.JobInput{
ImageName: ubuntu.name,
Version: ubuntu.tag,
Entrypoint: `/bin/bash -c 'schedtool 0 | grep SCHED_BATCH | grep 19'`,
JobID: jobID,
Batch: true,
}
if !mock.RunJobExpectingSuccess(ji) {
t.Fail()
}
}

func testSchedNormal(t *testing.T, jobID string) {
ji := &mock.JobInput{
ImageName: ubuntu.name,
Version: ubuntu.tag,
Entrypoint: `/bin/bash -c 'schedtool 0 | grep SCHED_NORMAL'`,
JobID: jobID,
Batch: true,
}
if !mock.RunJobExpectingSuccess(ji) {
t.Fail()
}
}

0 comments on commit c2a70b0

Please sign in to comment.