2018-03-01 17:51:11 -05:00
|
|
|
package container // import "github.com/docker/docker/integration/container"
|
2018-02-13 15:03:56 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"io/ioutil"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
"github.com/docker/docker/integration/internal/container"
|
|
|
|
"github.com/docker/docker/pkg/stdcopy"
|
2020-02-07 08:39:24 -05:00
|
|
|
"gotest.tools/v3/assert"
|
|
|
|
"gotest.tools/v3/skip"
|
2018-02-13 15:03:56 -05: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 12:13:47 -04:00
|
|
|
// FIXME(vdemeester) fails on a e2e run on linux...
|
2019-01-03 06:19:15 -05:00
|
|
|
skip.If(t, testEnv.IsRemoteDaemon)
|
2018-02-13 15:03:56 -05:00
|
|
|
defer setupTest(t)()
|
2019-01-02 08:16:25 -05:00
|
|
|
client := testEnv.APIClient()
|
2018-02-13 15:03:56 -05:00
|
|
|
ctx := context.Background()
|
|
|
|
|
2019-06-06 07:15:31 -04:00
|
|
|
id := container.Run(ctx, t, client, container.WithCmd("sleep", "100000"))
|
2018-02-13 15:03:56 -05:00
|
|
|
|
|
|
|
logs, err := client.ContainerLogs(ctx, id, types.ContainerLogsOptions{ShowStdout: true, Tail: "2"})
|
|
|
|
if logs != nil {
|
|
|
|
defer logs.Close()
|
|
|
|
}
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Check(t, err)
|
2018-02-13 15:03:56 -05:00
|
|
|
|
|
|
|
_, err = stdcopy.StdCopy(ioutil.Discard, ioutil.Discard, logs)
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Check(t, err)
|
2018-02-13 15:03:56 -05:00
|
|
|
}
|