|
@@ -17,6 +17,7 @@ import (
|
|
|
"github.com/docker/docker/pkg/mount"
|
|
|
"github.com/docker/docker/pkg/parsers"
|
|
|
"github.com/docker/docker/pkg/sysinfo"
|
|
|
+ "github.com/docker/docker/pkg/units"
|
|
|
"github.com/go-check/check"
|
|
|
"github.com/kr/pty"
|
|
|
)
|
|
@@ -435,3 +436,22 @@ func (s *DockerSuite) TestRunInvalidCPUShares(c *check.C) {
|
|
|
expected = "The maximum allowed cpu-shares is"
|
|
|
c.Assert(out, checker.Contains, expected)
|
|
|
}
|
|
|
+
|
|
|
+func (s *DockerSuite) TestRunWithCorrectMemorySwapOnLXC(c *check.C) {
|
|
|
+ testRequires(c, memoryLimitSupport)
|
|
|
+ testRequires(c, swapMemorySupport)
|
|
|
+ testRequires(c, SameHostDaemon)
|
|
|
+
|
|
|
+ out, _ := dockerCmd(c, "run", "-d", "-m", "16m", "--memory-swap", "64m", "busybox", "top")
|
|
|
+ if _, err := os.Stat("/sys/fs/cgroup/memory/lxc"); err != nil {
|
|
|
+ c.Skip("Excecution driver must be LXC for this test")
|
|
|
+ }
|
|
|
+ id := strings.TrimSpace(out)
|
|
|
+ memorySwap, err := ioutil.ReadFile(fmt.Sprintf("/sys/fs/cgroup/memory/lxc/%s/memory.memsw.limit_in_bytes", id))
|
|
|
+ c.Assert(err, check.IsNil)
|
|
|
+ cgSwap, err := strconv.ParseInt(strings.TrimSpace(string(memorySwap)), 10, 64)
|
|
|
+ c.Assert(err, check.IsNil)
|
|
|
+ swap, err := units.RAMInBytes("64m")
|
|
|
+ c.Assert(err, check.IsNil)
|
|
|
+ c.Assert(cgSwap, check.Equals, swap)
|
|
|
+}
|