For test that should be exclusively run only in regular daemon builds
and not in the experimental version, add a requirement.
Verified using TestCleanupMountsAfterDaemonKill.
- On regular daemon, the test ran.
- On experimental daemon, the test skipped.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,39 +0,0 @@ |
| 1 |
-// +build daemon,!windows,!experimental |
|
| 2 |
- |
|
| 3 |
-package main |
|
| 4 |
- |
|
| 5 |
-import ( |
|
| 6 |
- "io/ioutil" |
|
| 7 |
- "os" |
|
| 8 |
- "strings" |
|
| 9 |
- |
|
| 10 |
- "github.com/go-check/check" |
|
| 11 |
-) |
|
| 12 |
- |
|
| 13 |
-// os.Kill should kill daemon ungracefully, leaving behind container mounts. |
|
| 14 |
-// A subsequent daemon restart shoud clean up said mounts. |
|
| 15 |
-func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonKill(c *check.C) {
|
|
| 16 |
- c.Assert(s.d.StartWithBusybox(), check.IsNil) |
|
| 17 |
- |
|
| 18 |
- out, err := s.d.Cmd("run", "-d", "busybox", "top")
|
|
| 19 |
- c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
|
| 20 |
- id := strings.TrimSpace(out) |
|
| 21 |
- c.Assert(s.d.cmd.Process.Signal(os.Kill), check.IsNil) |
|
| 22 |
- mountOut, err := ioutil.ReadFile("/proc/self/mountinfo")
|
|
| 23 |
- c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
|
|
| 24 |
- |
|
| 25 |
- // container mounts should exist even after daemon has crashed. |
|
| 26 |
- comment := check.Commentf("%s should stay mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.folder, mountOut)
|
|
| 27 |
- c.Assert(strings.Contains(string(mountOut), id), check.Equals, true, comment) |
|
| 28 |
- |
|
| 29 |
- // restart daemon. |
|
| 30 |
- if err := s.d.Restart(); err != nil {
|
|
| 31 |
- c.Fatal(err) |
|
| 32 |
- } |
|
| 33 |
- |
|
| 34 |
- // Now, container mounts should be gone. |
|
| 35 |
- mountOut, err = ioutil.ReadFile("/proc/self/mountinfo")
|
|
| 36 |
- c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
|
|
| 37 |
- comment = check.Commentf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.folder, mountOut)
|
|
| 38 |
- c.Assert(strings.Contains(string(mountOut), id), check.Equals, false, comment) |
|
| 39 |
-} |
| ... | ... |
@@ -1584,6 +1584,35 @@ func (s *DockerDaemonSuite) TestRunContainerWithBridgeNone(c *check.C) {
|
| 1584 | 1584 |
check.Commentf("The network interfaces in container should be the same with host when --net=host when bridge network is disabled: %s", out))
|
| 1585 | 1585 |
} |
| 1586 | 1586 |
|
| 1587 |
+// os.Kill should kill daemon ungracefully, leaving behind container mounts. |
|
| 1588 |
+// A subsequent daemon restart shoud clean up said mounts. |
|
| 1589 |
+func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonKill(c *check.C) {
|
|
| 1590 |
+ testRequires(c, NotExperimentalDaemon) |
|
| 1591 |
+ c.Assert(s.d.StartWithBusybox(), check.IsNil) |
|
| 1592 |
+ |
|
| 1593 |
+ out, err := s.d.Cmd("run", "-d", "busybox", "top")
|
|
| 1594 |
+ c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
|
| 1595 |
+ id := strings.TrimSpace(out) |
|
| 1596 |
+ c.Assert(s.d.cmd.Process.Signal(os.Kill), check.IsNil) |
|
| 1597 |
+ mountOut, err := ioutil.ReadFile("/proc/self/mountinfo")
|
|
| 1598 |
+ c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
|
|
| 1599 |
+ |
|
| 1600 |
+ // container mounts should exist even after daemon has crashed. |
|
| 1601 |
+ comment := check.Commentf("%s should stay mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.folder, mountOut)
|
|
| 1602 |
+ c.Assert(strings.Contains(string(mountOut), id), check.Equals, true, comment) |
|
| 1603 |
+ |
|
| 1604 |
+ // restart daemon. |
|
| 1605 |
+ if err := s.d.Restart(); err != nil {
|
|
| 1606 |
+ c.Fatal(err) |
|
| 1607 |
+ } |
|
| 1608 |
+ |
|
| 1609 |
+ // Now, container mounts should be gone. |
|
| 1610 |
+ mountOut, err = ioutil.ReadFile("/proc/self/mountinfo")
|
|
| 1611 |
+ c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
|
|
| 1612 |
+ comment = check.Commentf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.folder, mountOut)
|
|
| 1613 |
+ c.Assert(strings.Contains(string(mountOut), id), check.Equals, false, comment) |
|
| 1614 |
+} |
|
| 1615 |
+ |
|
| 1587 | 1616 |
func (s *DockerDaemonSuite) TestDaemonRestartWithContainerRunning(t *check.C) {
|
| 1588 | 1617 |
if err := s.d.StartWithBusybox(); err != nil {
|
| 1589 | 1618 |
t.Fatal(err) |
| ... | ... |
@@ -9,6 +9,7 @@ import ( |
| 9 | 9 |
"strings" |
| 10 | 10 |
"time" |
| 11 | 11 |
|
| 12 |
+ "github.com/docker/docker/utils" |
|
| 12 | 13 |
"github.com/go-check/check" |
| 13 | 14 |
) |
| 14 | 15 |
|
| ... | ... |
@@ -29,6 +30,10 @@ var ( |
| 29 | 29 |
func() bool { return daemonPlatform == "linux" },
|
| 30 | 30 |
"Test requires a Linux daemon", |
| 31 | 31 |
} |
| 32 |
+ NotExperimentalDaemon = testRequirement{
|
|
| 33 |
+ func() bool { return !utils.ExperimentalBuild() },
|
|
| 34 |
+ "Test requires a non experimental daemon", |
|
| 35 |
+ } |
|
| 32 | 36 |
NotArm = testRequirement{
|
| 33 | 37 |
func() bool { return os.Getenv("DOCKER_ENGINE_GOARCH") != "arm" },
|
| 34 | 38 |
"Test requires a daemon not running on ARM", |