ソースを参照

Merge pull request #17005 from mavenugo/restart

Adding a restart test to make sure #16887 doesnt happens again
Michael Crosby 9 年 前
コミット
ee03a05595
1 ファイル変更29 行追加0 行削除
  1. 29 0
      integration-cli/docker_cli_restart_test.go

+ 29 - 0
integration-cli/docker_cli_restart_test.go

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