Why? Because the `mount` here will sometimes fail when run in
`debian:jessie`, which is what the environrment hosting the test suite
is running if run from the `Makefile`.
Also, why the heck not containerize it, all the things.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
| ... | ... |
@@ -21,6 +21,7 @@ import ( |
| 21 | 21 |
"time" |
| 22 | 22 |
|
| 23 | 23 |
"github.com/docker/docker/pkg/integration/checker" |
| 24 |
+ "github.com/docker/docker/pkg/mount" |
|
| 24 | 25 |
"github.com/docker/go-units" |
| 25 | 26 |
"github.com/docker/libnetwork/iptables" |
| 26 | 27 |
"github.com/docker/libtrust" |
| ... | ... |
@@ -1909,27 +1910,24 @@ func (s *DockerDaemonSuite) TestBridgeIPIsExcludedFromAllocatorPool(c *check.C) |
| 1909 | 1909 |
} |
| 1910 | 1910 |
|
| 1911 | 1911 |
// Test daemon for no space left on device error |
| 1912 |
-func (s *DockerDaemonSuite) TestDaemonNoSpaceleftOnDeviceError(c *check.C) {
|
|
| 1912 |
+func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *check.C) {
|
|
| 1913 | 1913 |
testRequires(c, SameHostDaemon, DaemonIsLinux, Network) |
| 1914 | 1914 |
|
| 1915 |
- // create a 2MiB image and mount it as graph root |
|
| 1916 |
- cmd := exec.Command("dd", "of=/tmp/testfs.img", "bs=1M", "seek=2", "count=0")
|
|
| 1917 |
- out, err := cmd.CombinedOutput() |
|
| 1918 |
- c.Assert(err, checker.IsNil, check.Commentf(string(out))) |
|
| 1919 |
- |
|
| 1920 |
- cmd = exec.Command("mkfs.ext4", "-F", "/tmp/testfs.img")
|
|
| 1921 |
- out, err = cmd.CombinedOutput() |
|
| 1922 |
- c.Assert(err, checker.IsNil, check.Commentf(string(out))) |
|
| 1923 |
- |
|
| 1924 |
- cmd = exec.Command("mkdir", "-p", "/tmp/testfs-mount")
|
|
| 1925 |
- out, err = cmd.CombinedOutput() |
|
| 1926 |
- c.Assert(err, checker.IsNil, check.Commentf(string(out))) |
|
| 1915 |
+ testDir, err := ioutil.TempDir("", "no-space-left-on-device-test")
|
|
| 1916 |
+ c.Assert(err, checker.IsNil) |
|
| 1917 |
+ defer os.RemoveAll(testDir) |
|
| 1918 |
+ c.Assert(mount.MakeRShared(testDir), checker.IsNil) |
|
| 1919 |
+ defer mount.Unmount(testDir) |
|
| 1920 |
+ defer mount.Unmount(filepath.Join(testDir, "test-mount")) |
|
| 1927 | 1921 |
|
| 1928 |
- cmd = exec.Command("mount", "-t", "ext4", "-no", "loop,rw", "/tmp/testfs.img", "/tmp/testfs-mount")
|
|
| 1929 |
- out, err = cmd.CombinedOutput() |
|
| 1930 |
- c.Assert(err, checker.IsNil, check.Commentf(string(out))) |
|
| 1922 |
+ // create a 2MiB image and mount it as graph root |
|
| 1923 |
+ // 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) |
|
| 1924 |
+ dockerCmd(c, "run", "--rm", "-v", testDir+":/test", "busybox", "sh", "-c", "dd of=/test/testfs.img bs=1M seek=2 count=0") |
|
| 1925 |
+ out, _, err := runCommandWithOutput(exec.Command("mkfs.ext4", "-F", filepath.Join(testDir, "testfs.img"))) // `mkfs.ext4` is not in busybox
|
|
| 1926 |
+ c.Assert(err, checker.IsNil, check.Commentf(out)) |
|
| 1927 |
+ 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") |
|
| 1931 | 1928 |
|
| 1932 |
- err = s.d.Start("--graph", "/tmp/testfs-mount")
|
|
| 1929 |
+ err = s.d.Start("--graph", filepath.Join(testDir, "test-mount"))
|
|
| 1933 | 1930 |
c.Assert(err, check.IsNil) |
| 1934 | 1931 |
|
| 1935 | 1932 |
// pull a repository large enough to fill the mount point |