Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 4a40eb1

Browse files
committed
Merge pull request #16 from Crazykev/integration-test
modify kill test and mv it to issue
2 parents 8eda1aa + 723e442 commit 4a40eb1

File tree

2 files changed

+46
-97
lines changed

2 files changed

+46
-97
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
*/

integration-cli/todo/docker_cli_kill_test.go

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)