mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
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 <kolyshkin@gmail.com>
This commit is contained in:
parent
deed26f7f0
commit
a978fd22da
1 changed files with 3 additions and 8 deletions
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue