docker_cli_oom_killed_test.go 980 B

123456789101112131415161718192021222324252627282930
  1. // +build !windows
  2. package main
  3. import (
  4. "github.com/docker/docker/pkg/integration/checker"
  5. "github.com/go-check/check"
  6. )
  7. func (s *DockerSuite) TestInspectOomKilledTrue(c *check.C) {
  8. testRequires(c, DaemonIsLinux, memoryLimitSupport, swapMemorySupport)
  9. name := "testoomkilled"
  10. _, exitCode, _ := dockerCmdWithError("run", "--name", name, "--memory", "32MB", "busybox", "sh", "-c", "x=a; while true; do x=$x$x$x$x; done")
  11. c.Assert(exitCode, checker.Equals, 137, check.Commentf("OOM exit should be 137"))
  12. oomKilled := inspectField(c, name, "State.OOMKilled")
  13. c.Assert(oomKilled, checker.Equals, "true")
  14. }
  15. func (s *DockerSuite) TestInspectOomKilledFalse(c *check.C) {
  16. testRequires(c, DaemonIsLinux, memoryLimitSupport, swapMemorySupport)
  17. name := "testoomkilled"
  18. dockerCmd(c, "run", "--name", name, "--memory", "32MB", "busybox", "sh", "-c", "echo hello world")
  19. oomKilled := inspectField(c, name, "State.OOMKilled")
  20. c.Assert(oomKilled, checker.Equals, "false")
  21. }