docker_api_update_unix_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // +build !windows
  2. package main
  3. import (
  4. "strings"
  5. "github.com/docker/docker/pkg/integration/checker"
  6. "github.com/go-check/check"
  7. )
  8. func (s *DockerSuite) TestApiUpdateContainer(c *check.C) {
  9. testRequires(c, DaemonIsLinux)
  10. testRequires(c, memoryLimitSupport)
  11. testRequires(c, swapMemorySupport)
  12. name := "apiUpdateContainer"
  13. hostConfig := map[string]interface{}{
  14. "Memory": 314572800,
  15. "MemorySwap": 524288000,
  16. }
  17. dockerCmd(c, "run", "-d", "--name", name, "-m", "200M", "busybox", "top")
  18. _, _, err := sockRequest("POST", "/containers/"+name+"/update", hostConfig)
  19. c.Assert(err, check.IsNil)
  20. c.Assert(inspectField(c, name, "HostConfig.Memory"), checker.Equals, "314572800")
  21. file := "/sys/fs/cgroup/memory/memory.limit_in_bytes"
  22. out, _ := dockerCmd(c, "exec", name, "cat", file)
  23. c.Assert(strings.TrimSpace(out), checker.Equals, "314572800")
  24. c.Assert(inspectField(c, name, "HostConfig.MemorySwap"), checker.Equals, "524288000")
  25. file = "/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes"
  26. out, _ = dockerCmd(c, "exec", name, "cat", file)
  27. c.Assert(strings.TrimSpace(out), checker.Equals, "524288000")
  28. }