2015-12-05 05:01:31 +00:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/docker/docker/pkg/integration/checker"
|
|
|
|
"github.com/go-check/check"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s *DockerSuite) TestInspectOomKilledTrue(c *check.C) {
|
2016-05-10 16:58:55 +00:00
|
|
|
testRequires(c, DaemonIsLinux, memoryLimitSupport, swapMemorySupport)
|
2015-12-05 05:01:31 +00:00
|
|
|
|
|
|
|
name := "testoomkilled"
|
2016-01-08 23:09:47 +00:00
|
|
|
_, exitCode, _ := dockerCmdWithError("run", "--name", name, "--memory", "32MB", "busybox", "sh", "-c", "x=a; while true; do x=$x$x$x$x; done")
|
2015-12-05 05:01:31 +00:00
|
|
|
|
|
|
|
c.Assert(exitCode, checker.Equals, 137, check.Commentf("OOM exit should be 137"))
|
|
|
|
|
2016-01-28 14:19:25 +00:00
|
|
|
oomKilled := inspectField(c, name, "State.OOMKilled")
|
2015-12-05 05:01:31 +00:00
|
|
|
c.Assert(oomKilled, checker.Equals, "true")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerSuite) TestInspectOomKilledFalse(c *check.C) {
|
2016-05-10 16:58:55 +00:00
|
|
|
testRequires(c, DaemonIsLinux, memoryLimitSupport, swapMemorySupport)
|
2015-12-05 05:01:31 +00:00
|
|
|
|
|
|
|
name := "testoomkilled"
|
2016-01-08 23:09:47 +00:00
|
|
|
dockerCmd(c, "run", "--name", name, "--memory", "32MB", "busybox", "sh", "-c", "echo hello world")
|
2015-12-05 05:01:31 +00:00
|
|
|
|
2016-01-28 14:19:25 +00:00
|
|
|
oomKilled := inspectField(c, name, "State.OOMKilled")
|
2015-12-05 05:01:31 +00:00
|
|
|
c.Assert(oomKilled, checker.Equals, "false")
|
|
|
|
}
|