|
@@ -5,6 +5,7 @@ import (
|
|
"net/http"
|
|
"net/http"
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
|
|
+ "github.com/docker/docker/pkg/integration/checker"
|
|
"github.com/go-check/check"
|
|
"github.com/go-check/check"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -17,9 +18,8 @@ func (s *DockerSuite) TestKillContainer(c *check.C) {
|
|
dockerCmd(c, "kill", cleanedContainerID)
|
|
dockerCmd(c, "kill", cleanedContainerID)
|
|
|
|
|
|
out, _ = dockerCmd(c, "ps", "-q")
|
|
out, _ = dockerCmd(c, "ps", "-q")
|
|
- if strings.Contains(out, cleanedContainerID) {
|
|
|
|
- c.Fatal("killed container is still running")
|
|
|
|
- }
|
|
|
|
|
|
+ c.Assert(out, checker.Not(checker.Contains), cleanedContainerID, check.Commentf("killed container is still running"))
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
func (s *DockerSuite) TestKillofStoppedContainer(c *check.C) {
|
|
func (s *DockerSuite) TestKillofStoppedContainer(c *check.C) {
|
|
@@ -42,9 +42,8 @@ func (s *DockerSuite) TestKillDifferentUserContainer(c *check.C) {
|
|
dockerCmd(c, "kill", cleanedContainerID)
|
|
dockerCmd(c, "kill", cleanedContainerID)
|
|
|
|
|
|
out, _ = dockerCmd(c, "ps", "-q")
|
|
out, _ = dockerCmd(c, "ps", "-q")
|
|
- if strings.Contains(out, cleanedContainerID) {
|
|
|
|
- c.Fatal("killed container is still running")
|
|
|
|
- }
|
|
|
|
|
|
+ c.Assert(out, checker.Not(checker.Contains), cleanedContainerID, check.Commentf("killed container is still running"))
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
// regression test about correct signal parsing see #13665
|
|
// regression test about correct signal parsing see #13665
|
|
@@ -57,9 +56,8 @@ func (s *DockerSuite) TestKillWithSignal(c *check.C) {
|
|
dockerCmd(c, "kill", "-s", "SIGWINCH", cid)
|
|
dockerCmd(c, "kill", "-s", "SIGWINCH", cid)
|
|
|
|
|
|
running, _ := inspectField(cid, "State.Running")
|
|
running, _ := inspectField(cid, "State.Running")
|
|
- if running != "true" {
|
|
|
|
- c.Fatal("Container should be in running state after SIGWINCH")
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ c.Assert(running, checker.Equals, "true", check.Commentf("Container should be in running state after SIGWINCH"))
|
|
}
|
|
}
|
|
|
|
|
|
func (s *DockerSuite) TestKillWithInvalidSignal(c *check.C) {
|
|
func (s *DockerSuite) TestKillWithInvalidSignal(c *check.C) {
|
|
@@ -70,14 +68,10 @@ func (s *DockerSuite) TestKillWithInvalidSignal(c *check.C) {
|
|
|
|
|
|
out, _, err := dockerCmdWithError("kill", "-s", "0", cid)
|
|
out, _, err := dockerCmdWithError("kill", "-s", "0", cid)
|
|
c.Assert(err, check.NotNil)
|
|
c.Assert(err, check.NotNil)
|
|
- if !strings.ContainsAny(out, "Invalid signal: 0") {
|
|
|
|
- c.Fatal("Kill with an invalid signal didn't error out correctly")
|
|
|
|
- }
|
|
|
|
|
|
+ c.Assert(out, checker.Contains, "Invalid signal: 0", check.Commentf("Kill with an invalid signal didn't error out correctly"))
|
|
|
|
|
|
running, _ := inspectField(cid, "State.Running")
|
|
running, _ := inspectField(cid, "State.Running")
|
|
- if running != "true" {
|
|
|
|
- c.Fatal("Container should be in running state after an invalid signal")
|
|
|
|
- }
|
|
|
|
|
|
+ c.Assert(running, checker.Equals, "true", check.Commentf("Container should be in running state after an invalid signal"))
|
|
|
|
|
|
out, _ = dockerCmd(c, "run", "-d", "busybox", "top")
|
|
out, _ = dockerCmd(c, "run", "-d", "busybox", "top")
|
|
cid = strings.TrimSpace(out)
|
|
cid = strings.TrimSpace(out)
|
|
@@ -85,14 +79,11 @@ func (s *DockerSuite) TestKillWithInvalidSignal(c *check.C) {
|
|
|
|
|
|
out, _, err = dockerCmdWithError("kill", "-s", "SIG42", cid)
|
|
out, _, err = dockerCmdWithError("kill", "-s", "SIG42", cid)
|
|
c.Assert(err, check.NotNil)
|
|
c.Assert(err, check.NotNil)
|
|
- if !strings.ContainsAny(out, "Invalid signal: SIG42") {
|
|
|
|
- c.Fatal("Kill with an invalid signal error out correctly")
|
|
|
|
- }
|
|
|
|
|
|
+ c.Assert(out, checker.Contains, "Invalid signal: SIG42", check.Commentf("Kill with an invalid signal error out correctly"))
|
|
|
|
|
|
running, _ = inspectField(cid, "State.Running")
|
|
running, _ = inspectField(cid, "State.Running")
|
|
- if running != "true" {
|
|
|
|
- c.Fatal("Container should be in running state after an invalid signal")
|
|
|
|
- }
|
|
|
|
|
|
+ c.Assert(running, checker.Equals, "true", check.Commentf("Container should be in running state after an invalid signal"))
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
func (s *DockerSuite) TestKillStoppedContainerAPIPre120(c *check.C) {
|
|
func (s *DockerSuite) TestKillStoppedContainerAPIPre120(c *check.C) {
|