From c7076d26709f3fa277bd11e1dffdc8fc7833d38e Mon Sep 17 00:00:00 2001 From: Anusha Ragunathan Date: Thu, 7 Apr 2016 14:41:40 -0700 Subject: [PATCH] Add non-experimental daemon as a test requirement. 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 --- ...docker_cli_daemon_not_experimental_test.go | 39 ------------------- integration-cli/docker_cli_daemon_test.go | 29 ++++++++++++++ integration-cli/requirements.go | 5 +++ 3 files changed, 34 insertions(+), 39 deletions(-) delete mode 100644 integration-cli/docker_cli_daemon_not_experimental_test.go diff --git a/integration-cli/docker_cli_daemon_not_experimental_test.go b/integration-cli/docker_cli_daemon_not_experimental_test.go deleted file mode 100644 index 3c987741fb..0000000000 --- a/integration-cli/docker_cli_daemon_not_experimental_test.go +++ /dev/null @@ -1,39 +0,0 @@ -// +build daemon,!windows,!experimental - -package main - -import ( - "io/ioutil" - "os" - "strings" - - "github.com/go-check/check" -) - -// os.Kill should kill daemon ungracefully, leaving behind container mounts. -// A subsequent daemon restart shoud clean up said mounts. -func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonKill(c *check.C) { - c.Assert(s.d.StartWithBusybox(), check.IsNil) - - out, err := s.d.Cmd("run", "-d", "busybox", "top") - c.Assert(err, check.IsNil, check.Commentf("Output: %s", out)) - id := strings.TrimSpace(out) - c.Assert(s.d.cmd.Process.Signal(os.Kill), check.IsNil) - mountOut, err := ioutil.ReadFile("/proc/self/mountinfo") - c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut)) - - // container mounts should exist even after daemon has crashed. - comment := check.Commentf("%s should stay mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.folder, mountOut) - c.Assert(strings.Contains(string(mountOut), id), check.Equals, true, comment) - - // restart daemon. - if err := s.d.Restart(); err != nil { - c.Fatal(err) - } - - // Now, container mounts should be gone. - mountOut, err = ioutil.ReadFile("/proc/self/mountinfo") - c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut)) - comment = check.Commentf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.folder, mountOut) - c.Assert(strings.Contains(string(mountOut), id), check.Equals, false, comment) -} diff --git a/integration-cli/docker_cli_daemon_test.go b/integration-cli/docker_cli_daemon_test.go index b3617fca95..3249cf1570 100644 --- a/integration-cli/docker_cli_daemon_test.go +++ b/integration-cli/docker_cli_daemon_test.go @@ -1584,6 +1584,35 @@ func (s *DockerDaemonSuite) TestRunContainerWithBridgeNone(c *check.C) { check.Commentf("The network interfaces in container should be the same with host when --net=host when bridge network is disabled: %s", out)) } +// os.Kill should kill daemon ungracefully, leaving behind container mounts. +// A subsequent daemon restart shoud clean up said mounts. +func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonKill(c *check.C) { + testRequires(c, NotExperimentalDaemon) + c.Assert(s.d.StartWithBusybox(), check.IsNil) + + out, err := s.d.Cmd("run", "-d", "busybox", "top") + c.Assert(err, check.IsNil, check.Commentf("Output: %s", out)) + id := strings.TrimSpace(out) + c.Assert(s.d.cmd.Process.Signal(os.Kill), check.IsNil) + mountOut, err := ioutil.ReadFile("/proc/self/mountinfo") + c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut)) + + // container mounts should exist even after daemon has crashed. + comment := check.Commentf("%s should stay mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.folder, mountOut) + c.Assert(strings.Contains(string(mountOut), id), check.Equals, true, comment) + + // restart daemon. + if err := s.d.Restart(); err != nil { + c.Fatal(err) + } + + // Now, container mounts should be gone. + mountOut, err = ioutil.ReadFile("/proc/self/mountinfo") + c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut)) + comment = check.Commentf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.folder, mountOut) + c.Assert(strings.Contains(string(mountOut), id), check.Equals, false, comment) +} + func (s *DockerDaemonSuite) TestDaemonRestartWithContainerRunning(t *check.C) { if err := s.d.StartWithBusybox(); err != nil { t.Fatal(err) diff --git a/integration-cli/requirements.go b/integration-cli/requirements.go index e948c0aae0..74c2679476 100644 --- a/integration-cli/requirements.go +++ b/integration-cli/requirements.go @@ -9,6 +9,7 @@ import ( "strings" "time" + "github.com/docker/docker/utils" "github.com/go-check/check" ) @@ -29,6 +30,10 @@ var ( func() bool { return daemonPlatform == "linux" }, "Test requires a Linux daemon", } + NotExperimentalDaemon = testRequirement{ + func() bool { return !utils.ExperimentalBuild() }, + "Test requires a non experimental daemon", + } NotArm = testRequirement{ func() bool { return os.Getenv("DOCKER_ENGINE_GOARCH") != "arm" }, "Test requires a daemon not running on ARM",