"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "integration-cli/docker_cli_update_unix_test.go" between
moby-20.10.6.tar.gz and moby-20.10.7.tar.gz

About: Moby is a framework to assemble specialized container systems (formerly project name Docker; see here to clarify the relationship between the projects).

docker_cli_update_unix_test.go  (moby-20.10.6):docker_cli_update_unix_test.go  (moby-20.10.7)
skipping to change at line 17 skipping to change at line 17
"encoding/json" "encoding/json"
"fmt" "fmt"
"os/exec" "os/exec"
"strings" "strings"
"testing" "testing"
"time" "time"
"github.com/creack/pty" "github.com/creack/pty"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/docker/docker/pkg/parsers/kernel"
"github.com/docker/docker/testutil/request" "github.com/docker/docker/testutil/request"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
) )
func (s *DockerSuite) TestUpdateRunningContainer(c *testing.T) { func (s *DockerSuite) TestUpdateRunningContainer(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
name := "test-update-container" name := "test-update-container"
dockerCmd(c, "run", "-d", "--name", name, "-m", "300M", "busybox", "top") dockerCmd(c, "run", "-d", "--name", name, "-m", "300M", "busybox", "top")
skipping to change at line 125 skipping to change at line 124
func (s *DockerSuite) TestUpdateContainerWithoutFlags(c *testing.T) { func (s *DockerSuite) TestUpdateContainerWithoutFlags(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
name := "test-update-container" name := "test-update-container"
dockerCmd(c, "run", "-d", "--name", name, "-m", "300M", "busybox", "true" ) dockerCmd(c, "run", "-d", "--name", name, "-m", "300M", "busybox", "true" )
_, _, err := dockerCmdWithError("update", name) _, _, err := dockerCmdWithError("update", name)
assert.ErrorContains(c, err, "") assert.ErrorContains(c, err, "")
} }
func (s *DockerSuite) TestUpdateKernelMemory(c *testing.T) {
testRequires(c, DaemonIsLinux, kernelMemorySupport)
name := "test-update-container"
dockerCmd(c, "run", "-d", "--name", name, "--kernel-memory", "50M", "busy
box", "top")
dockerCmd(c, "update", "--kernel-memory", "100M", name)
assert.Equal(c, inspectField(c, name, "HostConfig.KernelMemory"), "104857
600")
file := "/sys/fs/cgroup/memory/memory.kmem.limit_in_bytes"
out, _ := dockerCmd(c, "exec", name, "cat", file)
assert.Equal(c, strings.TrimSpace(out), "104857600")
}
func (s *DockerSuite) TestUpdateKernelMemoryUninitialized(c *testing.T) {
testRequires(c, DaemonIsLinux, kernelMemorySupport)
isNewKernel := CheckKernelVersion(4, 6, 0)
name := "test-update-container"
dockerCmd(c, "run", "-d", "--name", name, "busybox", "top")
_, _, err := dockerCmdWithError("update", "--kernel-memory", "100M", name
)
// Update kernel memory to a running container without kernel memory init
ialized
// is not allowed before kernel version 4.6.
if !isNewKernel {
assert.ErrorContains(c, err, "")
} else {
assert.NilError(c, err)
}
dockerCmd(c, "pause", name)
_, _, err = dockerCmdWithError("update", "--kernel-memory", "200M", name)
if !isNewKernel {
assert.ErrorContains(c, err, "")
} else {
assert.NilError(c, err)
}
dockerCmd(c, "unpause", name)
dockerCmd(c, "stop", name)
dockerCmd(c, "update", "--kernel-memory", "300M", name)
dockerCmd(c, "start", name)
assert.Equal(c, inspectField(c, name, "HostConfig.KernelMemory"), "314572
800")
file := "/sys/fs/cgroup/memory/memory.kmem.limit_in_bytes"
out, _ := dockerCmd(c, "exec", name, "cat", file)
assert.Equal(c, strings.TrimSpace(out), "314572800")
}
// GetKernelVersion gets the current kernel version.
func GetKernelVersion() *kernel.VersionInfo {
v, _ := kernel.ParseRelease(testEnv.DaemonInfo.KernelVersion)
return v
}
// CheckKernelVersion checks if current kernel is newer than (or equal to)
// the given version.
func CheckKernelVersion(k, major, minor int) bool {
return kernel.CompareKernelVersion(*GetKernelVersion(), kernel.VersionInf
o{Kernel: k, Major: major, Minor: minor}) >= 0
}
func (s *DockerSuite) TestUpdateSwapMemoryOnly(c *testing.T) { func (s *DockerSuite) TestUpdateSwapMemoryOnly(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
testRequires(c, memoryLimitSupport) testRequires(c, memoryLimitSupport)
testRequires(c, swapMemorySupport) testRequires(c, swapMemorySupport)
name := "test-update-container" name := "test-update-container"
dockerCmd(c, "run", "-d", "--name", name, "--memory", "300M", "--memory-s wap", "500M", "busybox", "top") dockerCmd(c, "run", "-d", "--name", name, "--memory", "300M", "--memory-s wap", "500M", "busybox", "top")
dockerCmd(c, "update", "--memory-swap", "600M", name) dockerCmd(c, "update", "--memory-swap", "600M", name)
assert.Equal(c, inspectField(c, name, "HostConfig.MemorySwap"), "62914560 0") assert.Equal(c, inspectField(c, name, "HostConfig.MemorySwap"), "62914560 0")
 End of changes. 2 change blocks. 
68 lines changed or deleted 0 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)