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

Commit

Permalink
Cleanup jobrunner, add negative tty test
Browse files Browse the repository at this point in the history
  • Loading branch information
rgulewich committed Oct 5, 2018
1 parent f093853 commit 66bcb4d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
10 changes: 4 additions & 6 deletions executor/mock/jobrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,13 @@ func (jobRunner *JobRunner) StopExecutorAsync() {
func (jobRunner *JobRunner) StartJob(jobInput *JobInput) *JobRunResponse { // nolint: gocyclo
// Define some stock job to run
var jobID string
attrs := make(map[string]string)

if jobInput.JobID == "" {
jobID = fmt.Sprintf("Titus-%v%v", r.Intn(1000), time.Now().Second())
} else {
jobID = jobInput.JobID
}

if jobInput.Tty {
attrs["titusParameter.agent.ttyEnabled"] = "true"
}

taskID := fmt.Sprintf("Titus-%v%v-Worker-0-2", r.Intn(1000), time.Now().Second())
env := map[string]string{
"TITUS_TASK_ID": taskID,
Expand All @@ -242,7 +237,7 @@ func (jobRunner *JobRunner) StartJob(jobInput *JobInput) *JobRunResponse { // no
Capabilities: jobInput.Capabilities,
TitusProvidedEnv: env,
IgnoreLaunchGuard: protobuf.Bool(jobInput.IgnoreLaunchGuard),
PassthroughAttributes: attrs,
PassthroughAttributes: make(map[string]string),
}
if p := jobInput.Process; p != nil {
ci.Process = &titus.ContainerInfo_Process{
Expand All @@ -258,6 +253,9 @@ func (jobRunner *JobRunner) StartJob(jobInput *JobInput) *JobRunResponse { // no
if jobInput.Batch == "idle" {
ci.PassthroughAttributes["titusParameter.agent.batchPriority"] = "idle"
}
if jobInput.Tty {
ci.PassthroughAttributes["titusParameter.agent.ttyEnabled"] = "true"
}

if jobInput.KillWaitSeconds > 0 {
ci.KillWaitSeconds = protobuf.Uint32(jobInput.KillWaitSeconds)
Expand Down
14 changes: 14 additions & 0 deletions executor/mock/standalone/standalone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func TestStandalone(t *testing.T) {
testCPUBursting,
testTwoCPUs,
testTty,
testTtyNegative,
}
for _, fun := range testFunctions {
fullName := runtime.FuncForPC(reflect.ValueOf(fun).Pointer()).Name()
Expand Down Expand Up @@ -861,3 +862,16 @@ func testTty(t *testing.T, jobID string) {
t.Fail()
}
}

func testTtyNegative(t *testing.T, jobID string) {
ji := &mock.JobInput{
ImageName: ubuntu.name,
Version: ubuntu.tag,
EntrypointOld: `/usr/bin/tty`,
JobID: jobID,
// Tty not specified
}
if !mock.RunJobExpectingFailure(ji) {
t.Fail()
}
}

0 comments on commit 66bcb4d

Please sign in to comment.