1
0
mirror of https://github.com/moby/moby.git synced 2025-07-29 07:21:35 +03:00

Merge pull request #16277 from runcom/add-oom-score-adj

Add OomScoreAdj
This commit is contained in:
Arnaud Porterie
2015-12-02 11:49:51 -08:00
16 changed files with 94 additions and 7 deletions

View File

@ -1524,3 +1524,34 @@ func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(
c.Assert(*containerJSON.HostConfig.MemorySwappiness, check.Equals, int64(-1))
}
// check validation is done daemon side and not only in cli
func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *check.C) {
testRequires(c, DaemonIsLinux)
config := struct {
Image string
OomScoreAdj int
}{"busybox", 1001}
name := "oomscoreadj-over"
status, b, err := sockRequest("POST", "/containers/create?name="+name, config)
c.Assert(err, check.IsNil)
c.Assert(status, check.Equals, http.StatusInternalServerError)
expected := "Invalid value 1001, range for oom score adj is [-1000, 1000]."
if !strings.Contains(string(b), expected) {
c.Fatalf("Expected output to contain %q, got %q", expected, string(b))
}
config = struct {
Image string
OomScoreAdj int
}{"busybox", -1001}
name = "oomscoreadj-low"
status, b, err = sockRequest("POST", "/containers/create?name="+name, config)
c.Assert(err, check.IsNil)
c.Assert(status, check.Equals, http.StatusInternalServerError)
expected = "Invalid value -1001, range for oom score adj is [-1000, 1000]."
if !strings.Contains(string(b), expected) {
c.Fatalf("Expected output to contain %q, got %q", expected, string(b))
}
}