|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "net/http" |
| 6 | + "strings" |
| 7 | + |
| 8 | + "github.com/docker/docker/pkg/integration/checker" |
| 9 | + "github.com/go-check/check" |
| 10 | +) |
| 11 | + |
| 12 | +func (s *DockerSuite) TestKillContainer(c *check.C) { |
| 13 | + testRequires(c, DaemonIsLinux) |
| 14 | + out, _ := dockerCmd(c, "run", "-d", "busybox", "top") |
| 15 | + cleanedContainerID := strings.TrimSpace(out) |
| 16 | + c.Assert(waitRun(cleanedContainerID), check.IsNil) |
| 17 | + |
| 18 | + dockerCmd(c, "kill", cleanedContainerID) |
| 19 | + |
| 20 | + out, _ = dockerCmd(c, "ps", "-q") |
| 21 | + c.Assert(out, checker.Not(checker.Contains), cleanedContainerID, check.Commentf("killed container is still running")) |
| 22 | + |
| 23 | +} |
| 24 | + |
| 25 | +func (s *DockerSuite) TestKillofStoppedContainer(c *check.C) { |
| 26 | + testRequires(c, DaemonIsLinux) |
| 27 | + out, _ := dockerCmd(c, "run", "-d", "busybox", "top") |
| 28 | + cleanedContainerID := strings.TrimSpace(out) |
| 29 | + |
| 30 | + dockerCmd(c, "stop", cleanedContainerID) |
| 31 | + |
| 32 | + _, _, err := dockerCmdWithError("kill", "-s", "30", cleanedContainerID) |
| 33 | + c.Assert(err, check.Not(check.IsNil), check.Commentf("Container %s is not running", cleanedContainerID)) |
| 34 | +} |
| 35 | + |
| 36 | +/* |
| 37 | +func (s *DockerSuite) TestKillStoppedContainerAPIPre120(c *check.C) { |
| 38 | + testRequires(c, DaemonIsLinux) |
| 39 | + dockerCmd(c, "run", "--name", "docker-kill-test-api", "-d", "busybox", "top") |
| 40 | + dockerCmd(c, "stop", "docker-kill-test-api") |
| 41 | +
|
| 42 | + status, _, err := sockRequest("POST", fmt.Sprintf("/v1.19/containers/%s/kill", "docker-kill-test-api"), nil) |
| 43 | + c.Assert(err, check.IsNil) |
| 44 | + c.Assert(status, check.Equals, http.StatusNoContent) |
| 45 | +} |
| 46 | +*/ |
0 commit comments