浏览代码

Improve TestAttachClosedOnContainerStop

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Tonis Tiigi 8 年之前
父节点
当前提交
9d8f01b4f5
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      integration-cli/docker_cli_attach_unix_test.go

+ 6 - 2
integration-cli/docker_cli_attach_unix_test.go

@@ -4,6 +4,7 @@ package main
 
 
 import (
 import (
 	"bufio"
 	"bufio"
+	"io/ioutil"
 	"os/exec"
 	"os/exec"
 	"strings"
 	"strings"
 	"time"
 	"time"
@@ -23,7 +24,7 @@ func (s *DockerSuite) TestAttachClosedOnContainerStop(c *check.C) {
 	id := strings.TrimSpace(out)
 	id := strings.TrimSpace(out)
 	c.Assert(waitRun(id), check.IsNil)
 	c.Assert(waitRun(id), check.IsNil)
 
 
-	_, tty, err := pty.Open()
+	pty, tty, err := pty.Open()
 	c.Assert(err, check.IsNil)
 	c.Assert(err, check.IsNil)
 
 
 	attachCmd := exec.Command(dockerBinary, "attach", id)
 	attachCmd := exec.Command(dockerBinary, "attach", id)
@@ -35,6 +36,7 @@ func (s *DockerSuite) TestAttachClosedOnContainerStop(c *check.C) {
 
 
 	errChan := make(chan error)
 	errChan := make(chan error)
 	go func() {
 	go func() {
+		time.Sleep(300 * time.Millisecond)
 		defer close(errChan)
 		defer close(errChan)
 		// Container is waiting for us to signal it to stop
 		// Container is waiting for us to signal it to stop
 		dockerCmd(c, "stop", id)
 		dockerCmd(c, "stop", id)
@@ -48,7 +50,9 @@ func (s *DockerSuite) TestAttachClosedOnContainerStop(c *check.C) {
 
 
 	select {
 	select {
 	case err := <-errChan:
 	case err := <-errChan:
-		c.Assert(err, check.IsNil)
+		tty.Close()
+		out, _ := ioutil.ReadAll(pty)
+		c.Assert(err, check.IsNil, check.Commentf("out: %v", string(out)))
 	case <-time.After(attachWait):
 	case <-time.After(attachWait):
 		c.Fatal("timed out without attach returning")
 		c.Fatal("timed out without attach returning")
 	}
 	}