浏览代码

test: daemon restart with containers running with restart always policy
manually stopped

If a container is running with a restart policy of always and it's
manually stopped, then on daemon restart it will be running.

Signed-off-by: Antonio Murdaca <runcom@linux.com>

Antonio Murdaca 10 年之前
父节点
当前提交
af59c80b4a
共有 1 个文件被更改,包括 23 次插入0 次删除
  1. 23 0
      integration-cli/docker_cli_daemon_test.go

+ 23 - 0
integration-cli/docker_cli_daemon_test.go

@@ -1527,3 +1527,26 @@ func teardownV6() error {
 	}
 	return nil
 }
+
+func (s *DockerDaemonSuite) TestDaemonRestartWithContainerWithRestartPolicyAlways(c *check.C) {
+	c.Assert(s.d.StartWithBusybox(), check.IsNil)
+
+	out, err := s.d.Cmd("run", "-d", "--restart", "always", "busybox", "top")
+	c.Assert(err, check.IsNil)
+	id := strings.TrimSpace(out)
+
+	_, err = s.d.Cmd("stop", id)
+	c.Assert(err, check.IsNil)
+	_, err = s.d.Cmd("wait", id)
+	c.Assert(err, check.IsNil)
+
+	out, err = s.d.Cmd("ps", "-q")
+	c.Assert(err, check.IsNil)
+	c.Assert(out, check.Equals, "")
+
+	c.Assert(s.d.Restart(), check.IsNil)
+
+	out, err = s.d.Cmd("ps", "-q")
+	c.Assert(err, check.IsNil)
+	c.Assert(strings.TrimSpace(out), check.Equals, id[:12])
+}