Browse Source

Fix TestAttachAfterDetach to work with latest client

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Daniel Nephin 7 years ago
parent
commit
847b610620
1 changed files with 5 additions and 13 deletions
  1. 5 13
      integration-cli/docker_cli_attach_unix_test.go

+ 5 - 13
integration-cli/docker_cli_attach_unix_test.go

@@ -69,10 +69,10 @@ func (s *DockerSuite) TestAttachAfterDetach(c *check.C) {
 	cmd.Stdout = tty
 	cmd.Stdout = tty
 	cmd.Stderr = tty
 	cmd.Stderr = tty
 
 
-	errChan := make(chan error)
+	cmdExit := make(chan error)
 	go func() {
 	go func() {
-		errChan <- cmd.Run()
-		close(errChan)
+		cmdExit <- cmd.Run()
+		close(cmdExit)
 	}()
 	}()
 
 
 	c.Assert(waitRun(name), check.IsNil)
 	c.Assert(waitRun(name), check.IsNil)
@@ -82,12 +82,7 @@ func (s *DockerSuite) TestAttachAfterDetach(c *check.C) {
 	cpty.Write([]byte{17})
 	cpty.Write([]byte{17})
 
 
 	select {
 	select {
-	case err := <-errChan:
-		if err != nil {
-			buff := make([]byte, 200)
-			tty.Read(buff)
-			c.Fatalf("%s: %s", err, buff)
-		}
+	case <-cmdExit:
 	case <-time.After(5 * time.Second):
 	case <-time.After(5 * time.Second):
 		c.Fatal("timeout while detaching")
 		c.Fatal("timeout while detaching")
 	}
 	}
@@ -102,6 +97,7 @@ func (s *DockerSuite) TestAttachAfterDetach(c *check.C) {
 
 
 	err = cmd.Start()
 	err = cmd.Start()
 	c.Assert(err, checker.IsNil)
 	c.Assert(err, checker.IsNil)
+	defer cmd.Process.Kill()
 
 
 	bytes := make([]byte, 10)
 	bytes := make([]byte, 10)
 	var nBytes int
 	var nBytes int
@@ -124,11 +120,7 @@ func (s *DockerSuite) TestAttachAfterDetach(c *check.C) {
 		c.Fatal("timeout waiting for attach read")
 		c.Fatal("timeout waiting for attach read")
 	}
 	}
 
 
-	err = cmd.Wait()
-	c.Assert(err, checker.IsNil)
-
 	c.Assert(string(bytes[:nBytes]), checker.Contains, "/ #")
 	c.Assert(string(bytes[:nBytes]), checker.Contains, "/ #")
-
 }
 }
 
 
 // TestAttachDetach checks that attach in tty mode can be detached using the long container ID
 // TestAttachDetach checks that attach in tty mode can be detached using the long container ID