Browse code

Merge pull request #13866 from brahmaroutu/runOOM_13766

RunOOM test should check to see if Oom Control is enabled

Michael Crosby authored on 2015/07/08 08:21:46
Showing 2 changed files
... ...
@@ -2883,6 +2883,7 @@ func (s *DockerSuite) TestRunAllowPortRangeThroughPublish(c *check.C) {
2883 2883
 }
2884 2884
 
2885 2885
 func (s *DockerSuite) TestRunOOMExitCode(c *check.C) {
2886
+	testRequires(c, OomControl)
2886 2887
 	errChan := make(chan error)
2887 2888
 	go func() {
2888 2889
 		defer close(errChan)
... ...
@@ -7,9 +7,11 @@ import (
7 7
 	"log"
8 8
 	"net/http"
9 9
 	"os/exec"
10
+	"path"
10 11
 	"strings"
11 12
 	"time"
12 13
 
14
+	"github.com/docker/libcontainer/cgroups"
13 15
 	"github.com/go-check/check"
14 16
 )
15 17
 
... ...
@@ -119,6 +121,24 @@ var (
119 119
 		},
120 120
 		"Test requires support for IPv6",
121 121
 	}
122
+	OomControl = TestRequirement{
123
+		func() bool {
124
+			cgroupMemoryMountpoint, err := cgroups.FindCgroupMountpoint("memory")
125
+			if err != nil {
126
+				return false
127
+			}
128
+			if _, err := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.memsw.limit_in_bytes")); err != nil {
129
+				return false
130
+			}
131
+
132
+			if _, err = ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.oom_control")); err != nil {
133
+				return false
134
+			}
135
+			return true
136
+
137
+		},
138
+		"Test requires Oom control enabled.",
139
+	}
122 140
 )
123 141
 
124 142
 // testRequires checks if the environment satisfies the requirements