Browse code

Improve TestAttachClosedOnContainerStop

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>

Tonis Tiigi authored on 2016/10/06 07:48:04
Showing 1 changed files
... ...
@@ -4,6 +4,7 @@ package main
4 4
 
5 5
 import (
6 6
 	"bufio"
7
+	"io/ioutil"
7 8
 	"os/exec"
8 9
 	"strings"
9 10
 	"time"
... ...
@@ -23,7 +24,7 @@ func (s *DockerSuite) TestAttachClosedOnContainerStop(c *check.C) {
23 23
 	id := strings.TrimSpace(out)
24 24
 	c.Assert(waitRun(id), check.IsNil)
25 25
 
26
-	_, tty, err := pty.Open()
26
+	pty, tty, err := pty.Open()
27 27
 	c.Assert(err, check.IsNil)
28 28
 
29 29
 	attachCmd := exec.Command(dockerBinary, "attach", id)
... ...
@@ -35,6 +36,7 @@ func (s *DockerSuite) TestAttachClosedOnContainerStop(c *check.C) {
35 35
 
36 36
 	errChan := make(chan error)
37 37
 	go func() {
38
+		time.Sleep(300 * time.Millisecond)
38 39
 		defer close(errChan)
39 40
 		// Container is waiting for us to signal it to stop
40 41
 		dockerCmd(c, "stop", id)
... ...
@@ -48,7 +50,9 @@ func (s *DockerSuite) TestAttachClosedOnContainerStop(c *check.C) {
48 48
 
49 49
 	select {
50 50
 	case err := <-errChan:
51
-		c.Assert(err, check.IsNil)
51
+		tty.Close()
52
+		out, _ := ioutil.ReadAll(pty)
53
+		c.Assert(err, check.IsNil, check.Commentf("out: %v", string(out)))
52 54
 	case <-time.After(attachWait):
53 55
 		c.Fatal("timed out without attach returning")
54 56
 	}