"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "components/engine/integration-cli/docker_cli_attach_test.go" between
docker-ce-19.03.2.tar.gz and docker-ce-19.03.3.tar.gz

About: Docker CE is a project to pack, ship and run any application as a lightweight container. Docker containers can run anywhere, on a laptop or at scale, in production, on VMs, bare metal, OpenStack clusters, public clouds and more. Community edition.

docker_cli_attach_test.go  (docker-ce-19.03.2):docker_cli_attach_test.go  (docker-ce-19.03.3)
package main package main
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"io" "io"
"os/exec" "os/exec"
"runtime" "runtime"
"strings" "strings"
"sync" "sync"
"testing"
"time" "time"
"github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli"
"github.com/go-check/check"
"gotest.tools/assert" "gotest.tools/assert"
"gotest.tools/icmd" "gotest.tools/icmd"
) )
const attachWait = 5 * time.Second const attachWait = 5 * time.Second
func (s *DockerSuite) TestAttachMultipleAndRestart(c *check.C) { func (s *DockerSuite) TestAttachMultipleAndRestart(c *testing.T) {
endGroup := &sync.WaitGroup{} endGroup := &sync.WaitGroup{}
startGroup := &sync.WaitGroup{} startGroup := &sync.WaitGroup{}
endGroup.Add(3) endGroup.Add(3)
startGroup.Add(3) startGroup.Add(3)
cli.DockerCmd(c, "run", "--name", "attacher", "-d", "busybox", "/bin/sh", "-c", "while true; do sleep 1; echo hello; done") cli.DockerCmd(c, "run", "--name", "attacher", "-d", "busybox", "/bin/sh", "-c", "while true; do sleep 1; echo hello; done")
cli.WaitRun(c, "attacher") cli.WaitRun(c, "attacher")
startDone := make(chan struct{}) startDone := make(chan struct{})
endDone := make(chan struct{}) endDone := make(chan struct{})
skipping to change at line 91 skipping to change at line 91
cli.DockerCmd(c, "kill", "attacher") cli.DockerCmd(c, "kill", "attacher")
select { select {
case <-endDone: case <-endDone:
case <-time.After(attachWait): case <-time.After(attachWait):
c.Fatalf("Attaches did not finish properly") c.Fatalf("Attaches did not finish properly")
} }
} }
func (s *DockerSuite) TestAttachTTYWithoutStdin(c *check.C) { func (s *DockerSuite) TestAttachTTYWithoutStdin(c *testing.T) {
// TODO @jhowardmsft. Figure out how to get this running again reliable o n Windows. // TODO @jhowardmsft. Figure out how to get this running again reliable o n Windows.
// It works by accident at the moment. Sometimes. I've gone back to v1.13 .0 and see the same. // It works by accident at the moment. Sometimes. I've gone back to v1.13 .0 and see the same.
// On Windows, docker run -d -ti busybox causes the container to exit imm ediately. // On Windows, docker run -d -ti busybox causes the container to exit imm ediately.
// Obviously a year back when I updated the test, that was not the case. However, // Obviously a year back when I updated the test, that was not the case. However,
// with this, and the test racing with the tear-down which panic's, somet imes CI // with this, and the test racing with the tear-down which panic's, somet imes CI
// will just fail and `MISS` all the other tests. For now, disabling it. Will // will just fail and `MISS` all the other tests. For now, disabling it. Will
// open an issue to track re-enabling this and root-causing the problem. // open an issue to track re-enabling this and root-causing the problem.
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-d", "-ti", "busybox") out, _ := dockerCmd(c, "run", "-d", "-ti", "busybox")
skipping to change at line 136 skipping to change at line 136
}() }()
select { select {
case err := <-done: case err := <-done:
assert.NilError(c, err) assert.NilError(c, err)
case <-time.After(attachWait): case <-time.After(attachWait):
c.Fatal("attach is running but should have failed") c.Fatal("attach is running but should have failed")
} }
} }
func (s *DockerSuite) TestAttachDisconnect(c *check.C) { func (s *DockerSuite) TestAttachDisconnect(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-di", "busybox", "/bin/cat") out, _ := dockerCmd(c, "run", "-di", "busybox", "/bin/cat")
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
cmd := exec.Command(dockerBinary, "attach", id) cmd := exec.Command(dockerBinary, "attach", id)
stdin, err := cmd.StdinPipe() stdin, err := cmd.StdinPipe()
if err != nil { if err != nil {
c.Fatal(err) c.Fatal(err)
} }
defer stdin.Close() defer stdin.Close()
stdout, err := cmd.StdoutPipe() stdout, err := cmd.StdoutPipe()
assert.NilError(c, err) assert.NilError(c, err)
defer stdout.Close() defer stdout.Close()
c.Assert(cmd.Start(), check.IsNil) assert.Assert(c, cmd.Start() == nil)
defer func() { defer func() {
cmd.Process.Kill() cmd.Process.Kill()
cmd.Wait() cmd.Wait()
}() }()
_, err = stdin.Write([]byte("hello\n")) _, err = stdin.Write([]byte("hello\n"))
assert.NilError(c, err) assert.NilError(c, err)
out, err = bufio.NewReader(stdout).ReadString('\n') out, err = bufio.NewReader(stdout).ReadString('\n')
assert.NilError(c, err) assert.NilError(c, err)
c.Assert(strings.TrimSpace(out), check.Equals, "hello") assert.Equal(c, strings.TrimSpace(out), "hello")
c.Assert(stdin.Close(), check.IsNil) assert.Assert(c, stdin.Close() == nil)
// Expect container to still be running after stdin is closed // Expect container to still be running after stdin is closed
running := inspectField(c, id, "State.Running") running := inspectField(c, id, "State.Running")
c.Assert(running, check.Equals, "true") assert.Equal(c, running, "true")
} }
func (s *DockerSuite) TestAttachPausedContainer(c *check.C) { func (s *DockerSuite) TestAttachPausedContainer(c *testing.T) {
testRequires(c, IsPausable) testRequires(c, IsPausable)
runSleepingContainer(c, "-d", "--name=test") runSleepingContainer(c, "-d", "--name=test")
dockerCmd(c, "pause", "test") dockerCmd(c, "pause", "test")
result := dockerCmdWithResult("attach", "test") result := dockerCmdWithResult("attach", "test")
result.Assert(c, icmd.Expected{ result.Assert(c, icmd.Expected{
Error: "exit status 1", Error: "exit status 1",
ExitCode: 1, ExitCode: 1,
Err: "You cannot attach to a paused container, unpause it fi rst", Err: "You cannot attach to a paused container, unpause it fi rst",
}) })
 End of changes. 10 change blocks. 
9 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)