1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #36744 from kolyshkin/t-enospc

TestDaemonNoSpaceLeftOnDeviceError: simplify
This commit is contained in:
Vincent Demeester 2018-04-20 15:40:39 +02:00 committed by GitHub
commit 7d9cbfa96f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1807,23 +1807,18 @@ func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *check.C) {
c.Assert(mount.MakeRShared(testDir), checker.IsNil) c.Assert(mount.MakeRShared(testDir), checker.IsNil)
defer mount.Unmount(testDir) 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) // 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") 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) 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")) 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")
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))
defer mount.Unmount(filepath.Join(testDir, "test-mount")) defer mount.Unmount(filepath.Join(testDir, "test-mount"))
s.d.Start(c, "--data-root", filepath.Join(testDir, "test-mount")) s.d.Start(c, "--data-root", filepath.Join(testDir, "test-mount"))
defer s.d.Stop(c) 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") pullOut, err := s.d.Cmd("pull", "debian:stretch")
c.Assert(err, checker.NotNil, check.Commentf(pullOut)) c.Assert(err, checker.NotNil, check.Commentf(pullOut))
c.Assert(pullOut, checker.Contains, "no space left on device") c.Assert(pullOut, checker.Contains, "no space left on device")