mirror of https://github.com/docker/docs.git
Merge pull request #17005 from mavenugo/restart
Adding a restart test to make sure #16887 doesnt happens again
This commit is contained in:
commit
ee03a05595
|
@ -1,6 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -124,3 +126,30 @@ func (s *DockerSuite) TestContainerRestartwithGoodContainer(c *check.C) {
|
||||||
c.Assert(MaximumRetryCount, checker.Equals, "3")
|
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)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue