mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
adabb51311
Add the swapMemorySupport requirement to all tests related to the OOM killer. The --memory option has the subtle side effect of defaulting --memory-swap to double the value of --memory. The OOM killer doesn't kick in until the container exhausts memory+swap, and so without the memory swap cgroup the tests will timeout due to swap being effectively unlimited. Document the default behavior of --memory-swap in the docker run man page. Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
30 lines
980 B
Go
30 lines
980 B
Go
// +build !windows
|
|
|
|
package main
|
|
|
|
import (
|
|
"github.com/docker/docker/pkg/integration/checker"
|
|
"github.com/go-check/check"
|
|
)
|
|
|
|
func (s *DockerSuite) TestInspectOomKilledTrue(c *check.C) {
|
|
testRequires(c, DaemonIsLinux, memoryLimitSupport, swapMemorySupport)
|
|
|
|
name := "testoomkilled"
|
|
_, exitCode, _ := dockerCmdWithError("run", "--name", name, "--memory", "32MB", "busybox", "sh", "-c", "x=a; while true; do x=$x$x$x$x; done")
|
|
|
|
c.Assert(exitCode, checker.Equals, 137, check.Commentf("OOM exit should be 137"))
|
|
|
|
oomKilled := inspectField(c, name, "State.OOMKilled")
|
|
c.Assert(oomKilled, checker.Equals, "true")
|
|
}
|
|
|
|
func (s *DockerSuite) TestInspectOomKilledFalse(c *check.C) {
|
|
testRequires(c, DaemonIsLinux, memoryLimitSupport, swapMemorySupport)
|
|
|
|
name := "testoomkilled"
|
|
dockerCmd(c, "run", "--name", name, "--memory", "32MB", "busybox", "sh", "-c", "echo hello world")
|
|
|
|
oomKilled := inspectField(c, name, "State.OOMKilled")
|
|
c.Assert(oomKilled, checker.Equals, "false")
|
|
}
|