2015-12-05 00:01:31 -05: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 12:58:55 -04:00
|
|
|
testRequires(c, DaemonIsLinux, memoryLimitSupport, swapMemorySupport)
|
2015-12-05 00:01:31 -05:00
|
|
|
|
|
|
|
name := "testoomkilled"
|
2016-01-08 18:09:47 -05: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 00:01:31 -05:00
|
|
|
|
|
|
|
c.Assert(exitCode, checker.Equals, 137, check.Commentf("OOM exit should be 137"))
|
|
|
|
|
2016-01-28 09:19:25 -05:00
|
|
|
oomKilled := inspectField(c, name, "State.OOMKilled")
|
2015-12-05 00:01:31 -05:00
|
|
|
c.Assert(oomKilled, checker.Equals, "true")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerSuite) TestInspectOomKilledFalse(c *check.C) {
|
2016-05-10 12:58:55 -04:00
|
|
|
testRequires(c, DaemonIsLinux, memoryLimitSupport, swapMemorySupport)
|
2015-12-05 00:01:31 -05:00
|
|
|
|
|
|
|
name := "testoomkilled"
|
2016-01-08 18:09:47 -05:00
|
|
|
dockerCmd(c, "run", "--name", name, "--memory", "32MB", "busybox", "sh", "-c", "echo hello world")
|
2015-12-05 00:01:31 -05:00
|
|
|
|
2016-01-28 09:19:25 -05:00
|
|
|
oomKilled := inspectField(c, name, "State.OOMKilled")
|
2015-12-05 00:01:31 -05:00
|
|
|
c.Assert(oomKilled, checker.Equals, "false")
|
|
|
|
}
|