mirror of https://github.com/docker/docs.git
Adding a restart test to make sure #16887 doesnt happens again
Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
parent
877fe61f75
commit
be9b7a2459
|
|
@ -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