From a978fd22daefcc68d37c46177a545f7e1dfc6d9e Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 29 Mar 2018 18:31:14 -0700 Subject: [PATCH] TestDaemonNoSpaceLeftOnDeviceError: simplify There is no need to perform a separate losetup step; mount (even the one in busybox!) is smart enough to set up a loopback device all by itself (even without -o loop present!). More to say, while doing this, it sets LO_FLAGS_AUTOCLEAR flag for the kernel to delete the loopback device as soon as its fs is unmounted (this is supposed to work since kernel 2.6.25). Also, remove mount options (-t ext4, -o loop,rw) as they are either defaults (rw) or mount is smart enough to figure out. Leave -n so it won't do unnecessary write to container's /etc/mtab. While at it, touch up some comments. Signed-off-by: Kir Kolyshkin --- integration-cli/docker_cli_daemon_test.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/integration-cli/docker_cli_daemon_test.go b/integration-cli/docker_cli_daemon_test.go index 2646de3fb7..da95623b42 100644 --- a/integration-cli/docker_cli_daemon_test.go +++ b/integration-cli/docker_cli_daemon_test.go @@ -1816,23 +1816,18 @@ func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *check.C) { c.Assert(mount.MakeRShared(testDir), checker.IsNil) defer mount.Unmount(testDir) - // create a 2MiB image and mount it as graph root + // create a 3MiB image (with a 2MiB ext4 fs) and mount it as graph root // Why in a container? Because `mount` sometimes behaves weirdly and often fails outright on this test in debian:jessie (which is what the test suite runs under if run from the Makefile) dockerCmd(c, "run", "--rm", "-v", testDir+":/test", "busybox", "sh", "-c", "dd of=/test/testfs.img bs=1M seek=3 count=0") icmd.RunCommand("mkfs.ext4", "-F", filepath.Join(testDir, "testfs.img")).Assert(c, icmd.Success) - result := icmd.RunCommand("losetup", "-f", "--show", filepath.Join(testDir, "testfs.img")) - result.Assert(c, icmd.Success) - loopname := strings.TrimSpace(string(result.Combined())) - defer exec.Command("losetup", "-d", loopname).Run() - - dockerCmd(c, "run", "--privileged", "--rm", "-v", testDir+":/test:shared", "busybox", "sh", "-c", fmt.Sprintf("mkdir -p /test/test-mount && mount -t ext4 -no loop,rw %v /test/test-mount", loopname)) + dockerCmd(c, "run", "--privileged", "--rm", "-v", testDir+":/test:shared", "busybox", "sh", "-c", "mkdir -p /test/test-mount && mount -n /test/testfs.img /test/test-mount") defer mount.Unmount(filepath.Join(testDir, "test-mount")) s.d.Start(c, "--data-root", filepath.Join(testDir, "test-mount")) defer s.d.Stop(c) - // pull a repository large enough to fill the mount point + // pull a repository large enough to overfill the mounted filesystem pullOut, err := s.d.Cmd("pull", "debian:stretch") c.Assert(err, checker.NotNil, check.Commentf(pullOut)) c.Assert(pullOut, checker.Contains, "no space left on device")