From b323e3df8bcb52607e57d5f49dcb7a93edafa84a Mon Sep 17 00:00:00 2001 From: Madhu Venugopal Date: Mon, 2 Nov 2015 10:38:10 -0800 Subject: [PATCH] IT for ungraceful daemon restart with multiple host-mode containers Signed-off-by: Madhu Venugopal --- .../docker_cli_network_unix_test.go | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/integration-cli/docker_cli_network_unix_test.go b/integration-cli/docker_cli_network_unix_test.go index 221b8dcd7f..3534b145c3 100644 --- a/integration-cli/docker_cli_network_unix_test.go +++ b/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") + } +}