2015-12-28 06:19:26 -05:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2016-12-30 12:23:00 -05:00
|
|
|
"github.com/docker/docker/integration-cli/checker"
|
2016-12-30 04:49:36 -05:00
|
|
|
"github.com/docker/docker/integration-cli/request"
|
2015-12-28 06:19:26 -05:00
|
|
|
"github.com/go-check/check"
|
|
|
|
)
|
|
|
|
|
[nit] integration-cli: obey Go's naming convention
No substantial code change.
- Api --> API
- Cli --> CLI
- Http, Https --> HTTP, HTTPS
- Id --> ID
- Uid,Gid,Pid --> UID,PID,PID
- Ipam --> IPAM
- Tls --> TLS (TestDaemonNoTlsCliTlsVerifyWithEnv --> TestDaemonTLSVerifyIssue13964)
Didn't touch in this commit:
- Git: because it is officially "Git": https://git-scm.com/
- Tar: because it is officially "Tar": https://www.gnu.org/software/tar/
- Cpu, Nat, Mac, Ipc, Shm: for keeping a consistency with existing production code (not changable, for compatibility)
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2016-09-27 21:50:12 -04:00
|
|
|
func (s *DockerSuite) TestAPIUpdateContainer(c *check.C) {
|
2015-12-28 06:19:26 -05:00
|
|
|
testRequires(c, DaemonIsLinux)
|
|
|
|
testRequires(c, memoryLimitSupport)
|
|
|
|
testRequires(c, swapMemorySupport)
|
|
|
|
|
|
|
|
name := "apiUpdateContainer"
|
|
|
|
hostConfig := map[string]interface{}{
|
|
|
|
"Memory": 314572800,
|
|
|
|
"MemorySwap": 524288000,
|
|
|
|
}
|
|
|
|
dockerCmd(c, "run", "-d", "--name", name, "-m", "200M", "busybox", "top")
|
2016-12-30 04:49:36 -05:00
|
|
|
_, _, err := request.SockRequest("POST", "/containers/"+name+"/update", hostConfig, daemonHost())
|
2015-12-28 06:19:26 -05:00
|
|
|
c.Assert(err, check.IsNil)
|
|
|
|
|
2016-02-02 20:26:46 -05:00
|
|
|
c.Assert(inspectField(c, name, "HostConfig.Memory"), checker.Equals, "314572800")
|
2015-12-28 06:19:26 -05:00
|
|
|
file := "/sys/fs/cgroup/memory/memory.limit_in_bytes"
|
|
|
|
out, _ := dockerCmd(c, "exec", name, "cat", file)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Equals, "314572800")
|
|
|
|
|
2016-02-02 20:26:46 -05:00
|
|
|
c.Assert(inspectField(c, name, "HostConfig.MemorySwap"), checker.Equals, "524288000")
|
2015-12-28 06:19:26 -05:00
|
|
|
file = "/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes"
|
|
|
|
out, _ = dockerCmd(c, "exec", name, "cat", file)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Equals, "524288000")
|
|
|
|
}
|