From 7570a24c80bc9ad8708dcf21e1da78fefd3bfc5e Mon Sep 17 00:00:00 2001 From: root Date: Sun, 7 Jun 2015 05:13:38 +0000 Subject: [PATCH] RunOOM test should check to see if Oom Control is enabled closes #13766 Signed-off-by: Srini Brahmaroutu Upstream-commit: e7fb38410dfcbdd83df7c9e16806bbf8fc3af8b5 Component: engine --- .../integration-cli/docker_cli_run_test.go | 1 + .../engine/integration-cli/requirements.go | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/components/engine/integration-cli/docker_cli_run_test.go b/components/engine/integration-cli/docker_cli_run_test.go index 97b8658e21..1eeac67101 100644 --- a/components/engine/integration-cli/docker_cli_run_test.go +++ b/components/engine/integration-cli/docker_cli_run_test.go @@ -2883,6 +2883,7 @@ func (s *DockerSuite) TestRunAllowPortRangeThroughPublish(c *check.C) { } func (s *DockerSuite) TestRunOOMExitCode(c *check.C) { + testRequires(c, OomControl) errChan := make(chan error) go func() { defer close(errChan) diff --git a/components/engine/integration-cli/requirements.go b/components/engine/integration-cli/requirements.go index ff14360042..8848679d45 100644 --- a/components/engine/integration-cli/requirements.go +++ b/components/engine/integration-cli/requirements.go @@ -7,8 +7,10 @@ import ( "log" "net/http" "os/exec" + "path" "strings" + "github.com/docker/libcontainer/cgroups" "github.com/go-check/check" ) @@ -107,6 +109,24 @@ var ( }, "Test requires support for IPv6", } + OomControl = TestRequirement{ + func() bool { + cgroupMemoryMountpoint, err := cgroups.FindCgroupMountpoint("memory") + if err != nil { + return false + } + if _, err := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.memsw.limit_in_bytes")); err != nil { + return false + } + + if _, err = ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.oom_control")); err != nil { + return false + } + return true + + }, + "Test requires Oom control enabled.", + } ) // testRequires checks if the environment satisfies the requirements