2018-03-01 22:51:11 +00:00
|
|
|
package container // import "github.com/docker/docker/integration/container"
|
2018-02-13 20:03:56 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"io/ioutil"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
"github.com/docker/docker/integration/internal/container"
|
2018-04-17 08:22:04 +00:00
|
|
|
"github.com/docker/docker/internal/test/request"
|
2018-02-13 20:03:56 +00:00
|
|
|
"github.com/docker/docker/pkg/stdcopy"
|
2018-03-13 19:28:34 +00:00
|
|
|
"github.com/gotestyourself/gotestyourself/assert"
|
2018-03-27 16:13:47 +00:00
|
|
|
"github.com/gotestyourself/gotestyourself/skip"
|
2018-02-13 20:03:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Regression test for #35370
|
|
|
|
// Makes sure that when following we don't get an EOF error when there are no logs
|
|
|
|
func TestLogsFollowTailEmpty(t *testing.T) {
|
2018-03-27 16:13:47 +00:00
|
|
|
// FIXME(vdemeester) fails on a e2e run on linux...
|
|
|
|
skip.IfCondition(t, testEnv.IsRemoteDaemon())
|
2018-02-13 20:03:56 +00:00
|
|
|
defer setupTest(t)()
|
|
|
|
client := request.NewAPIClient(t)
|
|
|
|
ctx := context.Background()
|
|
|
|
|
|
|
|
id := container.Run(t, ctx, client, container.WithCmd("sleep", "100000"))
|
|
|
|
|
|
|
|
logs, err := client.ContainerLogs(ctx, id, types.ContainerLogsOptions{ShowStdout: true, Tail: "2"})
|
|
|
|
if logs != nil {
|
|
|
|
defer logs.Close()
|
|
|
|
}
|
2018-03-13 19:28:34 +00:00
|
|
|
assert.Check(t, err)
|
2018-02-13 20:03:56 +00:00
|
|
|
|
|
|
|
_, err = stdcopy.StdCopy(ioutil.Discard, ioutil.Discard, logs)
|
2018-03-13 19:28:34 +00:00
|
|
|
assert.Check(t, err)
|
2018-02-13 20:03:56 +00:00
|
|
|
}
|