github.com/morganxf/moby@v1.13.1/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/pkg/integration/checker"
     9  	"github.com/go-check/check"
    10  )
    11  
    12  func (s *DockerSuite) TestAPIUpdateContainer(c *check.C) {
    13  	testRequires(c, DaemonIsLinux)
    14  	testRequires(c, memoryLimitSupport)
    15  	testRequires(c, swapMemorySupport)
    16  
    17  	name := "apiUpdateContainer"
    18  	hostConfig := map[string]interface{}{
    19  		"Memory":     314572800,
    20  		"MemorySwap": 524288000,
    21  	}
    22  	dockerCmd(c, "run", "-d", "--name", name, "-m", "200M", "busybox", "top")
    23  	_, _, err := sockRequest("POST", "/containers/"+name+"/update", hostConfig)
    24  	c.Assert(err, check.IsNil)
    25  
    26  	c.Assert(inspectField(c, name, "HostConfig.Memory"), checker.Equals, "314572800")
    27  	file := "/sys/fs/cgroup/memory/memory.limit_in_bytes"
    28  	out, _ := dockerCmd(c, "exec", name, "cat", file)
    29  	c.Assert(strings.TrimSpace(out), checker.Equals, "314572800")
    30  
    31  	c.Assert(inspectField(c, name, "HostConfig.MemorySwap"), checker.Equals, "524288000")
    32  	file = "/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes"
    33  	out, _ = dockerCmd(c, "exec", name, "cat", file)
    34  	c.Assert(strings.TrimSpace(out), checker.Equals, "524288000")
    35  }