Browse code

Adding test for the fix #17168.

The test case creates a mount point, starts the daemon with the
graph dir pointing to the mount and initates a pull request. We should
be able to check for the error message when the mount point gets filled
during pull.

Signed-off-by: Anil Belur <askb23@gmail.com>

Anil Belur authored on 2015/11/13 14:53:35
Showing 1 changed files
... ...
@@ -1880,3 +1880,30 @@ func (s *DockerDaemonSuite) TestBridgeIPIsExcludedFromAllocatorPool(c *check.C)
1880 1880
 		cont++
1881 1881
 	}
1882 1882
 }
1883
+
1884
+// Test daemon for no space left on device error
1885
+func (s *DockerDaemonSuite) TestDaemonNoSpaceleftOnDeviceError(c *check.C) {
1886
+	// create a 2MiB image and mount it as graph root
1887
+	cmd := exec.Command("dd", "of=/tmp/testfs.img", "bs=1M", "seek=2", "count=0")
1888
+	if err := cmd.Run(); err != nil {
1889
+		c.Fatalf("dd failed: %v", err)
1890
+	}
1891
+	cmd = exec.Command("mkfs.ext4", "-F", "/tmp/testfs.img")
1892
+	if err := cmd.Run(); err != nil {
1893
+		c.Fatalf("mkfs.ext4 failed: %v", err)
1894
+	}
1895
+	cmd = exec.Command("mkdir", "-p", "/tmp/testfs-mount")
1896
+	if err := cmd.Run(); err != nil {
1897
+		c.Fatalf("mkdir failed: %v", err)
1898
+	}
1899
+	cmd = exec.Command("mount", "-t", "ext4", "-no", "loop,rw", "/tmp/testfs.img", "/tmp/testfs-mount")
1900
+	if err := cmd.Run(); err != nil {
1901
+		c.Fatalf("mount failed: %v", err)
1902
+	}
1903
+	err := s.d.Start("--graph", "/tmp/testfs-mount")
1904
+	c.Assert(err, check.IsNil)
1905
+
1906
+	// pull a repository large enough to fill the mount point
1907
+	out, err := s.d.Cmd("pull", "registry:2")
1908
+	c.Assert(out, check.Not(check.Equals), 1, check.Commentf("no space left on device"))
1909
+}