|
@@ -4,6 +4,7 @@ import (
|
|
|
"fmt"
|
|
|
"net/http"
|
|
|
"strings"
|
|
|
+ "time"
|
|
|
|
|
|
"github.com/docker/docker/pkg/integration/checker"
|
|
|
"github.com/go-check/check"
|
|
@@ -15,6 +16,7 @@ func (s *DockerSuite) TestKillContainer(c *check.C) {
|
|
|
c.Assert(waitRun(cleanedContainerID), check.IsNil)
|
|
|
|
|
|
dockerCmd(c, "kill", cleanedContainerID)
|
|
|
+ c.Assert(waitExited(cleanedContainerID, 10*time.Second), check.IsNil)
|
|
|
|
|
|
out, _ = dockerCmd(c, "ps", "-q")
|
|
|
c.Assert(out, checker.Not(checker.Contains), cleanedContainerID, check.Commentf("killed container is still running"))
|
|
@@ -26,6 +28,7 @@ func (s *DockerSuite) TestKillOffStoppedContainer(c *check.C) {
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
|
|
|
|
|
dockerCmd(c, "stop", cleanedContainerID)
|
|
|
+ c.Assert(waitExited(cleanedContainerID, 10*time.Second), check.IsNil)
|
|
|
|
|
|
_, _, err := dockerCmdWithError("kill", "-s", "30", cleanedContainerID)
|
|
|
c.Assert(err, check.Not(check.IsNil), check.Commentf("Container %s is not running", cleanedContainerID))
|
|
@@ -39,6 +42,7 @@ func (s *DockerSuite) TestKillDifferentUserContainer(c *check.C) {
|
|
|
c.Assert(waitRun(cleanedContainerID), check.IsNil)
|
|
|
|
|
|
dockerCmd(c, "kill", cleanedContainerID)
|
|
|
+ c.Assert(waitExited(cleanedContainerID, 10*time.Second), check.IsNil)
|
|
|
|
|
|
out, _ = dockerCmd(c, "ps", "-q")
|
|
|
c.Assert(out, checker.Not(checker.Contains), cleanedContainerID, check.Commentf("killed container is still running"))
|
|
@@ -54,6 +58,7 @@ func (s *DockerSuite) TestKillWithSignal(c *check.C) {
|
|
|
c.Assert(waitRun(cid), check.IsNil)
|
|
|
|
|
|
dockerCmd(c, "kill", "-s", "SIGWINCH", cid)
|
|
|
+ time.Sleep(250 * time.Millisecond)
|
|
|
|
|
|
running := inspectField(c, cid, "State.Running")
|
|
|
|
|
@@ -67,8 +72,10 @@ func (s *DockerSuite) TestKillWithStopSignalWithSameSignalShouldDisableRestartPo
|
|
|
cid := strings.TrimSpace(out)
|
|
|
c.Assert(waitRun(cid), check.IsNil)
|
|
|
|
|
|
- // Let's docker send a CONT signal to the container
|
|
|
+ // Let docker send a TERM signal to the container
|
|
|
+ // It will kill the process and disable the restart policy
|
|
|
dockerCmd(c, "kill", "-s", "TERM", cid)
|
|
|
+ c.Assert(waitExited(cid, 10*time.Second), check.IsNil)
|
|
|
|
|
|
out, _ = dockerCmd(c, "ps", "-q")
|
|
|
c.Assert(out, checker.Not(checker.Contains), cid, check.Commentf("killed container is still running"))
|
|
@@ -81,9 +88,10 @@ func (s *DockerSuite) TestKillWithStopSignalWithDifferentSignalShouldKeepRestart
|
|
|
cid := strings.TrimSpace(out)
|
|
|
c.Assert(waitRun(cid), check.IsNil)
|
|
|
|
|
|
- // Let's docker send a TERM signal to the container
|
|
|
+ // Let docker send a TERM signal to the container
|
|
|
// It will kill the process, but not disable the restart policy
|
|
|
dockerCmd(c, "kill", "-s", "TERM", cid)
|
|
|
+ c.Assert(waitRestart(cid, 10*time.Second), check.IsNil)
|
|
|
|
|
|
// Restart policy should still be in place, so it should be still running
|
|
|
c.Assert(waitRun(cid), check.IsNil)
|