8799c4fc |
// +build !windows
package main
import (
"strings"
|
0fd5a654 |
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client" |
33968e6c |
"github.com/docker/docker/integration-cli/checker" |
8799c4fc |
"github.com/go-check/check" |
0fd5a654 |
"golang.org/x/net/context" |
8799c4fc |
)
|
7fb7a477 |
func (s *DockerSuite) TestAPIUpdateContainer(c *check.C) { |
8799c4fc |
testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport)
testRequires(c, swapMemorySupport)
name := "apiUpdateContainer" |
0fd5a654 |
updateConfig := container.UpdateConfig{
Resources: container.Resources{
Memory: 314572800,
MemorySwap: 524288000,
}, |
8799c4fc |
}
dockerCmd(c, "run", "-d", "--name", name, "-m", "200M", "busybox", "top") |
0fd5a654 |
cli, err := client.NewEnvClient()
c.Assert(err, check.IsNil)
defer cli.Close()
_, err = cli.ContainerUpdate(context.Background(), name, updateConfig)
|
8799c4fc |
c.Assert(err, check.IsNil)
|
7a20a270 |
c.Assert(inspectField(c, name, "HostConfig.Memory"), checker.Equals, "314572800") |
8799c4fc |
file := "/sys/fs/cgroup/memory/memory.limit_in_bytes"
out, _ := dockerCmd(c, "exec", name, "cat", file)
c.Assert(strings.TrimSpace(out), checker.Equals, "314572800")
|
7a20a270 |
c.Assert(inspectField(c, name, "HostConfig.MemorySwap"), checker.Equals, "524288000") |
8799c4fc |
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")
} |