Skip to content

Commit

Permalink
TestSigProxyWithTTY: fix
Browse files Browse the repository at this point in the history
exec.CombinedOutput should not be used here because:
 - it redirects cmd Stdout and Stderr and we want it to be the tty
 - it calls cmd.Run which we already did

Also, make sure we don't leave a zombie running, by calling Wait()

Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed Jul 24, 2019
1 parent c429225 commit 13eb231
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions e2e/container/proxy_signal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ import (
func TestSigProxyWithTTY(t *testing.T) {
_, tty, err := pty.Open()
assert.NilError(t, err, "could not open pty")
defer func() { _ = tty.Close() }()

containerName := "repro-28872"
cmd := exec.Command("docker", "run", "-i", "-t", "--init", "--name", containerName, fixtures.BusyboxImage, "sleep", "30")
cmd.Stdin = tty
cmd.Stdout = tty
cmd.Stderr = tty
defer func() {
_ = cmd.Wait()
_ = tty.Close()
}()

err = cmd.Start()
out, _ := cmd.CombinedOutput()
assert.NilError(t, err, "failed to start container: %s", out)
assert.NilError(t, err, "failed to start container")
defer icmd.RunCommand("docker", "container", "rm", "-f", containerName)

poll.WaitOn(t, containerExistsWithStatus(t, containerName, "running"), poll.WithDelay(100*time.Millisecond), poll.WithTimeout(5*time.Second))
Expand Down

0 comments on commit 13eb231

Please sign in to comment.