Signed-off-by: Madhu Venugopal <madhu@docker.com>
| ... | ... |
@@ -1,6 +1,8 @@ |
| 1 | 1 |
package main |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
+ "os" |
|
| 5 |
+ "strconv" |
|
| 4 | 6 |
"strings" |
| 5 | 7 |
"time" |
| 6 | 8 |
|
| ... | ... |
@@ -124,3 +126,30 @@ func (s *DockerSuite) TestContainerRestartwithGoodContainer(c *check.C) {
|
| 124 | 124 |
c.Assert(MaximumRetryCount, checker.Equals, "3") |
| 125 | 125 |
|
| 126 | 126 |
} |
| 127 |
+ |
|
| 128 |
+func (s *DockerSuite) TestContainerRestartSuccess(c *check.C) {
|
|
| 129 |
+ testRequires(c, DaemonIsLinux) |
|
| 130 |
+ |
|
| 131 |
+ out, _ := dockerCmd(c, "run", "-d", "--restart=always", "busybox", "top") |
|
| 132 |
+ id := strings.TrimSpace(out) |
|
| 133 |
+ c.Assert(waitRun(id), check.IsNil) |
|
| 134 |
+ |
|
| 135 |
+ pidStr, err := inspectField(id, "State.Pid") |
|
| 136 |
+ c.Assert(err, check.IsNil) |
|
| 137 |
+ |
|
| 138 |
+ pid, err := strconv.Atoi(pidStr) |
|
| 139 |
+ c.Assert(err, check.IsNil) |
|
| 140 |
+ |
|
| 141 |
+ p, err := os.FindProcess(pid) |
|
| 142 |
+ c.Assert(err, check.IsNil) |
|
| 143 |
+ c.Assert(p, check.NotNil) |
|
| 144 |
+ |
|
| 145 |
+ err = p.Kill() |
|
| 146 |
+ c.Assert(err, check.IsNil) |
|
| 147 |
+ |
|
| 148 |
+ err = waitInspect(id, "{{.RestartCount}}", "1", 5*time.Second)
|
|
| 149 |
+ c.Assert(err, check.IsNil) |
|
| 150 |
+ |
|
| 151 |
+ err = waitInspect(id, "{{.State.Status}}", "running", 5*time.Second)
|
|
| 152 |
+ c.Assert(err, check.IsNil) |
|
| 153 |
+} |