ソースを参照

Merge pull request #4357 from creack/fix_TestCmdKill

Fix TestCmdKill by closing the pipe before waiting on the container
Victor Vieux 11 年 前
コミット
5908aa350d
1 ファイル変更7 行追加5 行削除
  1. 7 5
      integration/commands_test.go

+ 7 - 5
integration/commands_test.go

@@ -1046,11 +1046,12 @@ func TestContainerOrphaning(t *testing.T) {
 }
 }
 
 
 func TestCmdKill(t *testing.T) {
 func TestCmdKill(t *testing.T) {
-	stdin, stdinPipe := io.Pipe()
-	stdout, stdoutPipe := io.Pipe()
-
-	cli := api.NewDockerCli(stdin, stdoutPipe, ioutil.Discard, testDaemonProto, testDaemonAddr)
-	cli2 := api.NewDockerCli(nil, ioutil.Discard, ioutil.Discard, testDaemonProto, testDaemonAddr)
+	var (
+		stdin, stdinPipe   = io.Pipe()
+		stdout, stdoutPipe = io.Pipe()
+		cli                = api.NewDockerCli(stdin, stdoutPipe, ioutil.Discard, testDaemonProto, testDaemonAddr)
+		cli2               = api.NewDockerCli(nil, ioutil.Discard, ioutil.Discard, testDaemonProto, testDaemonAddr)
+	)
 	defer cleanup(globalEngine, t)
 	defer cleanup(globalEngine, t)
 
 
 	ch := make(chan struct{})
 	ch := make(chan struct{})
@@ -1089,6 +1090,7 @@ func TestCmdKill(t *testing.T) {
 		}
 		}
 	})
 	})
 
 
+	stdout.Close()
 	time.Sleep(500 * time.Millisecond)
 	time.Sleep(500 * time.Millisecond)
 	if !container.State.IsRunning() {
 	if !container.State.IsRunning() {
 		t.Fatal("The container should be still running")
 		t.Fatal("The container should be still running")