github.com/LazyboyChen7/engine@v17.12.1-ce-rc2+incompatible/integration-cli/docker_api_update_unix_test.go (about) 1 // +build !windows 2 3 package main 4 5 import ( 6 "strings" 7 8 "github.com/docker/docker/api/types/container" 9 "github.com/docker/docker/client" 10 "github.com/docker/docker/integration-cli/checker" 11 "github.com/go-check/check" 12 "golang.org/x/net/context" 13 ) 14 15 func (s *DockerSuite) TestAPIUpdateContainer(c *check.C) { 16 testRequires(c, DaemonIsLinux) 17 testRequires(c, memoryLimitSupport) 18 testRequires(c, swapMemorySupport) 19 20 name := "apiUpdateContainer" 21 updateConfig := container.UpdateConfig{ 22 Resources: container.Resources{ 23 Memory: 314572800, 24 MemorySwap: 524288000, 25 }, 26 } 27 dockerCmd(c, "run", "-d", "--name", name, "-m", "200M", "busybox", "top") 28 cli, err := client.NewEnvClient() 29 c.Assert(err, check.IsNil) 30 defer cli.Close() 31 32 _, err = cli.ContainerUpdate(context.Background(), name, updateConfig) 33 34 c.Assert(err, check.IsNil) 35 36 c.Assert(inspectField(c, name, "HostConfig.Memory"), checker.Equals, "314572800") 37 file := "/sys/fs/cgroup/memory/memory.limit_in_bytes" 38 out, _ := dockerCmd(c, "exec", name, "cat", file) 39 c.Assert(strings.TrimSpace(out), checker.Equals, "314572800") 40 41 c.Assert(inspectField(c, name, "HostConfig.MemorySwap"), checker.Equals, "524288000") 42 file = "/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes" 43 out, _ = dockerCmd(c, "exec", name, "cat", file) 44 c.Assert(strings.TrimSpace(out), checker.Equals, "524288000") 45 }