mirror of https://github.com/docker/docs.git
Fix race within TestRunDisconnectTty
This commit is contained in:
parent
2ced94b414
commit
acb546cd1b
|
@ -979,8 +979,13 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout rcli.DockerConn, args ...s
|
||||||
}
|
}
|
||||||
Debugf("Waiting for attach to return\n")
|
Debugf("Waiting for attach to return\n")
|
||||||
<-attachErr
|
<-attachErr
|
||||||
container.Wait()
|
|
||||||
// Expecting I/O pipe error, discarding
|
// Expecting I/O pipe error, discarding
|
||||||
|
|
||||||
|
// If we are in stdinonce mode, wait for the process to end
|
||||||
|
// otherwise, simply return
|
||||||
|
if config.StdinOnce && !config.Tty {
|
||||||
|
container.Wait()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -228,6 +228,21 @@ func TestRunDisconnectTty(t *testing.T) {
|
||||||
close(c1)
|
close(c1)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
setTimeout(t, "Waiting for the container to be started timed out", 2*time.Second, func() {
|
||||||
|
for {
|
||||||
|
// Client disconnect after run -i should keep stdin out in TTY mode
|
||||||
|
l := runtime.List()
|
||||||
|
if len(l) == 1 && l[0].State.Running {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(10 * time.Millisecond)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Client disconnect after run -i should keep stdin out in TTY mode
|
||||||
|
container := runtime.List()[0]
|
||||||
|
|
||||||
setTimeout(t, "Read/Write assertion timed out", 2*time.Second, func() {
|
setTimeout(t, "Read/Write assertion timed out", 2*time.Second, func() {
|
||||||
if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 15); err != nil {
|
if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 15); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -242,8 +257,6 @@ func TestRunDisconnectTty(t *testing.T) {
|
||||||
// In tty mode, we expect the process to stay alive even after client's stdin closes.
|
// In tty mode, we expect the process to stay alive even after client's stdin closes.
|
||||||
// Do not wait for run to finish
|
// Do not wait for run to finish
|
||||||
|
|
||||||
// Client disconnect after run -i should keep stdin out in TTY mode
|
|
||||||
container := runtime.List()[0]
|
|
||||||
// Give some time to monitor to do his thing
|
// Give some time to monitor to do his thing
|
||||||
container.WaitTimeout(500 * time.Millisecond)
|
container.WaitTimeout(500 * time.Millisecond)
|
||||||
if !container.State.Running {
|
if !container.State.Running {
|
||||||
|
|
Loading…
Reference in New Issue