Adding a restart test to make sure #16887 doesnt happens again

Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
Madhu Venugopal 2015-10-13 21:08:47 -07:00
parent 877fe61f75
commit be9b7a2459
1 changed files with 29 additions and 0 deletions

View File

@ -1,6 +1,8 @@
package main
import (
"os"
"strconv"
"strings"
"time"
@ -124,3 +126,30 @@ func (s *DockerSuite) TestContainerRestartwithGoodContainer(c *check.C) {
c.Assert(MaximumRetryCount, checker.Equals, "3")
}
func (s *DockerSuite) TestContainerRestartSuccess(c *check.C) {
testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "--restart=always", "busybox", "top")
id := strings.TrimSpace(out)
c.Assert(waitRun(id), check.IsNil)
pidStr, err := inspectField(id, "State.Pid")
c.Assert(err, check.IsNil)
pid, err := strconv.Atoi(pidStr)
c.Assert(err, check.IsNil)
p, err := os.FindProcess(pid)
c.Assert(err, check.IsNil)
c.Assert(p, check.NotNil)
err = p.Kill()
c.Assert(err, check.IsNil)
err = waitInspect(id, "{{.RestartCount}}", "1", 5*time.Second)
c.Assert(err, check.IsNil)
err = waitInspect(id, "{{.State.Status}}", "running", 5*time.Second)
c.Assert(err, check.IsNil)
}