docker_cli_daemon_not_experimental_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // +build daemon,!windows,!experimental
  2. package main
  3. import (
  4. "io/ioutil"
  5. "os"
  6. "strings"
  7. "github.com/go-check/check"
  8. )
  9. // os.Kill should kill daemon ungracefully, leaving behind container mounts.
  10. // A subsequent daemon restart shoud clean up said mounts.
  11. func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonKill(c *check.C) {
  12. c.Assert(s.d.StartWithBusybox(), check.IsNil)
  13. out, err := s.d.Cmd("run", "-d", "busybox", "top")
  14. c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
  15. id := strings.TrimSpace(out)
  16. c.Assert(s.d.cmd.Process.Signal(os.Kill), check.IsNil)
  17. mountOut, err := ioutil.ReadFile("/proc/self/mountinfo")
  18. c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
  19. // container mounts should exist even after daemon has crashed.
  20. comment := check.Commentf("%s should stay mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.folder, mountOut)
  21. c.Assert(strings.Contains(string(mountOut), id), check.Equals, true, comment)
  22. // restart daemon.
  23. if err := s.d.Restart(); err != nil {
  24. c.Fatal(err)
  25. }
  26. // Now, container mounts should be gone.
  27. mountOut, err = ioutil.ReadFile("/proc/self/mountinfo")
  28. c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
  29. comment = check.Commentf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.folder, mountOut)
  30. c.Assert(strings.Contains(string(mountOut), id), check.Equals, false, comment)
  31. }