1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix tests creating zombie processes

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure 2017-09-07 10:11:25 -07:00
parent ddae20c032
commit 617f89b9a3
No known key found for this signature in database
GPG key ID: 40CF16616B361216
7 changed files with 14 additions and 6 deletions

View file

@ -49,6 +49,7 @@ import (
func (s *DockerDaemonSuite) TestLegacyDaemonCommand(c *check.C) { func (s *DockerDaemonSuite) TestLegacyDaemonCommand(c *check.C) {
cmd := exec.Command(dockerBinary, "daemon", "--storage-driver=vfs", "--debug") cmd := exec.Command(dockerBinary, "daemon", "--storage-driver=vfs", "--debug")
err := cmd.Start() err := cmd.Start()
go cmd.Wait()
c.Assert(err, checker.IsNil, check.Commentf("could not start daemon using 'docker daemon'")) c.Assert(err, checker.IsNil, check.Commentf("could not start daemon using 'docker daemon'"))
c.Assert(cmd.Process.Kill(), checker.IsNil) c.Assert(cmd.Process.Kill(), checker.IsNil)

View file

@ -229,18 +229,18 @@ func (s *DockerSuite) TestExecStopNotHanging(c *check.C) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "top") dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "top")
err := exec.Command(dockerBinary, "exec", "testing", "top").Start() result := icmd.StartCmd(icmd.Command(dockerBinary, "exec", "testing", "top"))
c.Assert(err, checker.IsNil) result.Assert(c, icmd.Success)
go icmd.WaitOnCmd(0, result)
type dstop struct { type dstop struct {
out []byte out string
err error err error
} }
ch := make(chan dstop) ch := make(chan dstop)
go func() { go func() {
out, err := exec.Command(dockerBinary, "stop", "testing").CombinedOutput() result := icmd.RunCommand(dockerBinary, "stop", "testing")
ch <- dstop{out, err} ch <- dstop{result.Combined(), result.Error}
close(ch) close(ch)
}() }()
select { select {

View file

@ -280,6 +280,7 @@ func (s *DockerSuite) TestLogsFollowGoroutinesWithStdout(c *check.C) {
r, w := io.Pipe() r, w := io.Pipe()
cmd.Stdout = w cmd.Stdout = w
c.Assert(cmd.Start(), checker.IsNil) c.Assert(cmd.Start(), checker.IsNil)
go cmd.Wait()
// Make sure pipe is written to // Make sure pipe is written to
chErr := make(chan error) chErr := make(chan error)
@ -305,6 +306,7 @@ func (s *DockerSuite) TestLogsFollowGoroutinesNoOutput(c *check.C) {
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
cmd := exec.Command(dockerBinary, "logs", "-f", id) cmd := exec.Command(dockerBinary, "logs", "-f", id)
c.Assert(cmd.Start(), checker.IsNil) c.Assert(cmd.Start(), checker.IsNil)
go cmd.Wait()
time.Sleep(200 * time.Millisecond) time.Sleep(200 * time.Millisecond)
c.Assert(cmd.Process.Kill(), checker.IsNil) c.Assert(cmd.Process.Kill(), checker.IsNil)
cmd.Wait() cmd.Wait()

View file

@ -244,6 +244,7 @@ func (s *DockerHubPullSuite) TestPullClientDisconnect(c *check.C) {
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
err = pullCmd.Start() err = pullCmd.Start()
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
go pullCmd.Wait()
// Cancel as soon as we get some output. // Cancel as soon as we get some output.
buf := make([]byte, 10) buf := make([]byte, 10)

View file

@ -226,6 +226,7 @@ func (s *DockerSuite) TestRunAttachDetachFromInvalidFlag(c *check.C) {
if err := cmd.Start(); err != nil { if err := cmd.Start(); err != nil {
c.Fatal(err) c.Fatal(err)
} }
go cmd.Wait()
bufReader := bufio.NewReader(stdout) bufReader := bufio.NewReader(stdout)
out, err := bufReader.ReadString('\n') out, err := bufReader.ReadString('\n')
@ -424,6 +425,7 @@ func (s *DockerSuite) TestRunAttachInvalidDetachKeySequencePreserved(c *check.C)
if err := cmd.Start(); err != nil { if err := cmd.Start(); err != nil {
c.Fatal(err) c.Fatal(err)
} }
go cmd.Wait()
c.Assert(waitRun(name), check.IsNil) c.Assert(waitRun(name), check.IsNil)
// Invalid escape sequence aba, should print aba in output // Invalid escape sequence aba, should print aba in output

View file

@ -172,6 +172,7 @@ func (s *DockerSwarmSuite) TestServiceLogsFollow(c *check.C) {
cmd.Stdout = w cmd.Stdout = w
cmd.Stderr = w cmd.Stderr = w
c.Assert(cmd.Start(), checker.IsNil) c.Assert(cmd.Start(), checker.IsNil)
go cmd.Wait()
// Make sure pipe is written to // Make sure pipe is written to
ch := make(chan *logMessage) ch := make(chan *logMessage)

View file

@ -131,6 +131,7 @@ func (s *DockerSuite) TestStatsAllNewContainersAdded(c *check.C) {
stdout, err := statsCmd.StdoutPipe() stdout, err := statsCmd.StdoutPipe()
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
c.Assert(statsCmd.Start(), check.IsNil) c.Assert(statsCmd.Start(), check.IsNil)
go statsCmd.Wait()
defer statsCmd.Process.Kill() defer statsCmd.Process.Kill()
go func() { go func() {