Browse code

Merge pull request #36744 from kolyshkin/t-enospc

TestDaemonNoSpaceLeftOnDeviceError: simplify

Vincent Demeester authored on 2018/04/20 22:40:39
Showing 1 changed files
... ...
@@ -1807,23 +1807,18 @@ func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *check.C) {
1807 1807
 	c.Assert(mount.MakeRShared(testDir), checker.IsNil)
1808 1808
 	defer mount.Unmount(testDir)
1809 1809
 
1810
-	// create a 2MiB image and mount it as graph root
1810
+	// create a 3MiB image (with a 2MiB ext4 fs) and mount it as graph root
1811 1811
 	// 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)
1812 1812
 	dockerCmd(c, "run", "--rm", "-v", testDir+":/test", "busybox", "sh", "-c", "dd of=/test/testfs.img bs=1M seek=3 count=0")
1813 1813
 	icmd.RunCommand("mkfs.ext4", "-F", filepath.Join(testDir, "testfs.img")).Assert(c, icmd.Success)
1814 1814
 
1815
-	result := icmd.RunCommand("losetup", "-f", "--show", filepath.Join(testDir, "testfs.img"))
1816
-	result.Assert(c, icmd.Success)
1817
-	loopname := strings.TrimSpace(string(result.Combined()))
1818
-	defer exec.Command("losetup", "-d", loopname).Run()
1819
-
1820
-	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))
1815
+	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")
1821 1816
 	defer mount.Unmount(filepath.Join(testDir, "test-mount"))
1822 1817
 
1823 1818
 	s.d.Start(c, "--data-root", filepath.Join(testDir, "test-mount"))
1824 1819
 	defer s.d.Stop(c)
1825 1820
 
1826
-	// pull a repository large enough to fill the mount point
1821
+	// pull a repository large enough to overfill the mounted filesystem
1827 1822
 	pullOut, err := s.d.Cmd("pull", "debian:stretch")
1828 1823
 	c.Assert(err, checker.NotNil, check.Commentf(pullOut))
1829 1824
 	c.Assert(pullOut, checker.Contains, "no space left on device")