IT for ungraceful daemon restart with multiple host-mode containers

Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
Madhu Venugopal 2015-11-02 10:38:10 -08:00
parent beeec6d103
commit b323e3df8b
1 changed files with 26 additions and 0 deletions

View File

@ -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")
}
}