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

Commit

Permalink
Add OOM Kill Test
Browse files Browse the repository at this point in the history
  • Loading branch information
sargun committed May 21, 2018
1 parent 9d7eb44 commit f6116f6
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion executor/mock/standalone/standalone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var (
}
ubuntu = testImage{
name: "titusoss/ubuntu",
tag: "20180501-1525157359",
tag: "20180518-1526605880",
}
// TODO: Determine how this got built, and add it to the auto image builders?
byDigest = testImage{
Expand Down Expand Up @@ -95,6 +95,7 @@ func TestStandalone(t *testing.T) {
testMakesPTY,
testTerminateTimeoutNotTooSlow,
testOOMAdj,
testOOMKill,
}
for _, fun := range testFunctions {
fullName := runtime.FuncForPC(reflect.ValueOf(fun).Pointer()).Name()
Expand Down Expand Up @@ -544,3 +545,33 @@ func testOOMAdj(t *testing.T, jobID string) {
t.Fail()
}
}

func testOOMKill(t *testing.T, jobID string) {
// Start the executor
jobRunner := mock.NewJobRunner()
defer jobRunner.StopExecutorAsync()

ji := &mock.JobInput{
ImageName: ubuntu.name,
Version: ubuntu.tag,
Entrypoint: `stress --vm 100 --vm-keep --vm-hang 100`,
JobID: jobID,
}
jobResponse := jobRunner.StartJob(ji)

// Wait until the task is running

for status := range jobResponse.UpdateChan {

if mock.IsTerminalState(status.State) {
if status.State.String() != "TASK_FAILED" {
t.Fail()
}
if !strings.Contains(status.Mesg, "OOMKilled") {
t.Fatal("Task killed due to: ", status.Mesg)
}
return
}
}
t.Fail()
}

0 comments on commit f6116f6

Please sign in to comment.