|
@@ -113,57 +113,6 @@ func assertPipe(input, output string, r io.Reader, w io.Writer, count int) error
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
-func TestRunExit(t *testing.T) {
|
|
|
|
- stdin, stdinPipe := io.Pipe()
|
|
|
|
- stdout, stdoutPipe := io.Pipe()
|
|
|
|
-
|
|
|
|
- cli := client.NewDockerCli(stdin, stdoutPipe, ioutil.Discard, testDaemonProto, testDaemonAddr, nil)
|
|
|
|
- defer cleanup(globalEngine, t)
|
|
|
|
-
|
|
|
|
- c1 := make(chan struct{})
|
|
|
|
- go func() {
|
|
|
|
- cli.CmdRun("-i", unitTestImageID, "/bin/cat")
|
|
|
|
- close(c1)
|
|
|
|
- }()
|
|
|
|
-
|
|
|
|
- setTimeout(t, "Read/Write assertion timed out", 2*time.Second, func() {
|
|
|
|
- if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 150); err != nil {
|
|
|
|
- t.Fatal(err)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- container := globalDaemon.List()[0]
|
|
|
|
-
|
|
|
|
- // Closing /bin/cat stdin, expect it to exit
|
|
|
|
- if err := stdin.Close(); err != nil {
|
|
|
|
- t.Fatal(err)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // as the process exited, CmdRun must finish and unblock. Wait for it
|
|
|
|
- setTimeout(t, "Waiting for CmdRun timed out", 10*time.Second, func() {
|
|
|
|
- <-c1
|
|
|
|
-
|
|
|
|
- go func() {
|
|
|
|
- cli.CmdWait(container.ID)
|
|
|
|
- }()
|
|
|
|
-
|
|
|
|
- if _, err := bufio.NewReader(stdout).ReadString('\n'); err != nil {
|
|
|
|
- t.Fatal(err)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- // Make sure that the client has been disconnected
|
|
|
|
- setTimeout(t, "The client should have been disconnected once the remote process exited.", 2*time.Second, func() {
|
|
|
|
- // Expecting pipe i/o error, just check that read does not block
|
|
|
|
- stdin.Read([]byte{})
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- // Cleanup pipes
|
|
|
|
- if err := closeWrap(stdin, stdinPipe, stdout, stdoutPipe); err != nil {
|
|
|
|
- t.Fatal(err)
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// Expected behaviour: the process dies when the client disconnects
|
|
// Expected behaviour: the process dies when the client disconnects
|
|
func TestRunDisconnect(t *testing.T) {
|
|
func TestRunDisconnect(t *testing.T) {
|
|
|
|
|