Browse code

un-containerize TestDaemonNoSpaceLeftOnDeviceError

Commit 59b83d8aae106cdc4042c29c900069fc804b2b68 containerized these steps,
as they didn't work well on Debian Jessie:

> 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.

Follow-up commits, such as 228d74842fd1ac97b5c8d11fd6a3c313eae5c051, and
1c5806cf57e008e6f3ef66e6c1c57c42bbd5d3aa updated the Debian distro, but
also updated this comment, losing the original context (the issue was
(originally) related to Debian Jessie).

This patch changes the test back to not use containers, which seems to
work fine (at least "it worked on my machine").

make TEST_IGNORE_CGROUP_CHECK=1 TEST_FILTER=TestDaemonNoSpaceLeftOnDeviceError DOCKER_GRAPHDRIVER=overlay2 test-integration

=== RUN TestDockerDaemonSuite/TestDaemonNoSpaceLeftOnDeviceError
check_test.go:589: [df36ad96a412b] daemon is not started
--- PASS: TestDockerDaemonSuite (5.12s)
--- PASS: TestDockerDaemonSuite/TestDaemonNoSpaceLeftOnDeviceError (5.12s)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2023/11/24 21:35:26
Showing 1 changed files
... ...
@@ -1646,16 +1646,15 @@ func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *testing.T) {
1646 1646
 	assert.Assert(c, mount.MakeRShared(testDir) == nil)
1647 1647
 	defer mount.Unmount(testDir)
1648 1648
 
1649
-	// create a 3MiB image (with a 2MiB ext4 fs) and mount it as graph root
1650
-	//
1651
-	// Why in a container? Because `mount` sometimes behaves weirdly and often
1652
-	// fails outright on this test in debian:jessie (which is what the test suite
1653
-	// runs under if run from the Makefile at the time this patch was added).
1654
-	cli.DockerCmd(c, "run", "--rm", "-v", testDir+":/test", "busybox", "sh", "-c", "dd of=/test/testfs.img bs=1M seek=3 count=0")
1655
-	icmd.RunCommand("mkfs.ext4", "-F", filepath.Join(testDir, "testfs.img")).Assert(c, icmd.Success)
1649
+	// create a 3MiB image (with a 2MiB ext4 fs) and mount it as storage root
1650
+	storageFS := filepath.Join(testDir, "testfs.img")
1651
+	icmd.RunCommand("dd", "of="+storageFS, "bs=1M", "seek=3", "count=0").Assert(c, icmd.Success)
1652
+	icmd.RunCommand("mkfs.ext4", "-F", storageFS).Assert(c, icmd.Success)
1656 1653
 
1657
-	cli.DockerCmd(c, "run", "--privileged", "--rm", "-v", testDir+":/test:shared", "busybox", "sh", "-c", "mkdir -p /test/test-mount && mount -n -t ext4 /test/testfs.img /test/test-mount")
1658
-	defer mount.Unmount(filepath.Join(testDir, "test-mount"))
1654
+	testMount, err := os.MkdirTemp(testDir, "test-mount")
1655
+	assert.NilError(c, err)
1656
+	icmd.RunCommand("mount", "-n", "-t", "ext4", storageFS, testMount).Assert(c, icmd.Success)
1657
+	defer mount.Unmount(testMount)
1659 1658
 
1660 1659
 	driver := "vfs"
1661 1660
 	if testEnv.UsingSnapshotter() {
... ...
@@ -1663,11 +1662,11 @@ func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *testing.T) {
1663 1663
 	}
1664 1664
 
1665 1665
 	s.d.Start(c,
1666
-		"--data-root", filepath.Join(testDir, "test-mount"),
1666
+		"--data-root", testMount,
1667 1667
 		"--storage-driver", driver,
1668 1668
 
1669 1669
 		// Pass empty containerd socket to force daemon to create a new
1670
-		// supervised containerd daemon. Otherwise the global containerd daemon
1670
+		// supervised containerd daemon, otherwise the global containerd daemon
1671 1671
 		// will be used and its data won't be stored in the specified data-root.
1672 1672
 		"--containerd", "",
1673 1673
 	)