浏览代码

IT for ungraceful daemon restart with multiple host-mode containers

Signed-off-by: Madhu Venugopal <madhu@docker.com>
Madhu Venugopal 9 年之前
父节点
当前提交
b323e3df8b
共有 1 个文件被更改,包括 26 次插入0 次删除
  1. 26 0
      integration-cli/docker_cli_network_unix_test.go

+ 26 - 0
integration-cli/docker_cli_network_unix_test.go

@@ -738,3 +738,29 @@ func (s *DockerNetworkSuite) TestDockerNetworkRunNetByID(c *check.C) {
 	out, _ := dockerCmd(c, "network", "create", "one")
 	dockerCmd(c, "run", "-d", "--net", strings.TrimSpace(out), "busybox", "top")
 }
+
+func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c *check.C) {
+	testRequires(c, DaemonIsLinux, NotUserNamespace)
+	s.d.Start()
+
+	// Run a few containers on host network
+	for i := 0; i < 10; i++ {
+		cName := fmt.Sprintf("hostc-%d", i)
+		out, err := s.d.Cmd("run", "-d", "--name", cName, "--net=host", "--restart=always", "busybox", "top")
+		c.Assert(err, checker.IsNil, check.Commentf(out))
+	}
+
+	// Kill daemon ungracefully and restart
+	if err := s.d.cmd.Process.Kill(); err != nil {
+		c.Fatal(err)
+	}
+	s.d.Restart()
+
+	// make sure all the containers are up and running
+	for i := 0; i < 10; i++ {
+		cName := fmt.Sprintf("hostc-%d", i)
+		runningOut, err := s.d.Cmd("inspect", "--format='{{.State.Running}}'", cName)
+		c.Assert(err, checker.IsNil)
+		c.Assert(strings.TrimSpace(runningOut), checker.Equals, "true")
+	}
+}