From 47c353eb4694a727e4fe4d6c1c2eedf1dc3c3aa8 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Fri, 6 May 2016 14:19:27 -0700 Subject: [PATCH] Clean loopbacks in TestDaemonNoSpaceLeftOnDeviceError Signed-off-by: Tonis Tiigi --- integration-cli/docker_cli_daemon_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/integration-cli/docker_cli_daemon_test.go b/integration-cli/docker_cli_daemon_test.go index 13327d5265..55945ad1ec 100644 --- a/integration-cli/docker_cli_daemon_test.go +++ b/integration-cli/docker_cli_daemon_test.go @@ -1922,16 +1922,24 @@ func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *check.C) { defer os.RemoveAll(testDir) c.Assert(mount.MakeRShared(testDir), checker.IsNil) defer mount.Unmount(testDir) - defer mount.Unmount(filepath.Join(testDir, "test-mount")) // create a 2MiB image 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=2 count=0") out, _, err := runCommandWithOutput(exec.Command("mkfs.ext4", "-F", filepath.Join(testDir, "testfs.img"))) // `mkfs.ext4` is not in busybox c.Assert(err, checker.IsNil, check.Commentf(out)) - dockerCmd(c, "run", "--privileged", "--rm", "-v", testDir+":/test:shared", "busybox", "sh", "-c", "mkdir -p /test/test-mount && mount -t ext4 -no loop,rw /test/testfs.img /test/test-mount") + + cmd := exec.Command("losetup", "-f", "--show", filepath.Join(testDir, "testfs.img")) + loout, err := cmd.CombinedOutput() + c.Assert(err, checker.IsNil) + loopname := strings.TrimSpace(string(loout)) + 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")) err = s.d.Start("--graph", filepath.Join(testDir, "test-mount")) + defer s.d.Stop() c.Assert(err, check.IsNil) // pull a repository large enough to fill the mount point