logs_test.go 967 B

12345678910111213141516171819202122232425262728293031323334
  1. package container // import "github.com/docker/docker/integration/container"
  2. import (
  3. "context"
  4. "io/ioutil"
  5. "testing"
  6. "github.com/docker/docker/api/types"
  7. "github.com/docker/docker/integration/internal/container"
  8. "github.com/docker/docker/pkg/stdcopy"
  9. "gotest.tools/assert"
  10. "gotest.tools/skip"
  11. )
  12. // Regression test for #35370
  13. // Makes sure that when following we don't get an EOF error when there are no logs
  14. func TestLogsFollowTailEmpty(t *testing.T) {
  15. // FIXME(vdemeester) fails on a e2e run on linux...
  16. skip.If(t, testEnv.IsRemoteDaemon)
  17. defer setupTest(t)()
  18. client := testEnv.APIClient()
  19. ctx := context.Background()
  20. id := container.Run(t, ctx, client, container.WithCmd("sleep", "100000"))
  21. logs, err := client.ContainerLogs(ctx, id, types.ContainerLogsOptions{ShowStdout: true, Tail: "2"})
  22. if logs != nil {
  23. defer logs.Close()
  24. }
  25. assert.Check(t, err)
  26. _, err = stdcopy.StdCopy(ioutil.Discard, ioutil.Discard, logs)
  27. assert.Check(t, err)
  28. }