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

Improve TestAttachClosedOnContainerStop

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2016-10-05 15:48:04 -07:00
parent 921a0bf686
commit 9d8f01b4f5

View file

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