2016-11-14 13:53:53 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2018-04-19 18:30:59 -04:00
|
|
|
"context"
|
2016-11-14 13:53:53 -05:00
|
|
|
"strings"
|
|
|
|
|
2017-05-23 23:56:26 -04:00
|
|
|
"github.com/docker/docker/client"
|
2016-11-14 13:53:53 -05:00
|
|
|
"github.com/go-check/check"
|
2019-04-04 09:23:19 -04:00
|
|
|
"gotest.tools/assert"
|
2016-11-14 13:53:53 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func (s *DockerSuite) TestPluginLogDriver(c *check.C) {
|
|
|
|
testRequires(c, IsAmd64, DaemonIsLinux)
|
|
|
|
|
|
|
|
pluginName := "cpuguy83/docker-logdriver-test:latest"
|
|
|
|
|
|
|
|
dockerCmd(c, "plugin", "install", pluginName)
|
|
|
|
dockerCmd(c, "run", "--log-driver", pluginName, "--name=test", "busybox", "echo", "hello")
|
|
|
|
out, _ := dockerCmd(c, "logs", "test")
|
2019-04-04 09:23:19 -04:00
|
|
|
assert.Equal(c, strings.TrimSpace(out), "hello")
|
2016-11-14 13:53:53 -05:00
|
|
|
|
|
|
|
dockerCmd(c, "start", "-a", "test")
|
|
|
|
out, _ = dockerCmd(c, "logs", "test")
|
2019-04-04 09:23:19 -04:00
|
|
|
assert.Equal(c, strings.TrimSpace(out), "hello\nhello")
|
2016-11-14 13:53:53 -05:00
|
|
|
|
|
|
|
dockerCmd(c, "rm", "test")
|
|
|
|
dockerCmd(c, "plugin", "disable", pluginName)
|
|
|
|
dockerCmd(c, "plugin", "rm", pluginName)
|
|
|
|
}
|
2017-04-11 17:21:21 -04:00
|
|
|
|
|
|
|
// Make sure log drivers are listed in info, and v2 plugins are not.
|
|
|
|
func (s *DockerSuite) TestPluginLogDriverInfoList(c *check.C) {
|
|
|
|
testRequires(c, IsAmd64, DaemonIsLinux)
|
|
|
|
pluginName := "cpuguy83/docker-logdriver-test"
|
|
|
|
|
|
|
|
dockerCmd(c, "plugin", "install", pluginName)
|
2017-05-23 23:56:26 -04:00
|
|
|
|
2019-01-03 16:49:00 -05:00
|
|
|
cli, err := client.NewClientWithOpts(client.FromEnv)
|
2019-04-04 09:23:19 -04:00
|
|
|
assert.NilError(c, err)
|
2017-05-23 23:56:26 -04:00
|
|
|
defer cli.Close()
|
2017-04-11 17:21:21 -04:00
|
|
|
|
2017-05-23 23:56:26 -04:00
|
|
|
info, err := cli.Info(context.Background())
|
2019-04-04 09:23:19 -04:00
|
|
|
assert.NilError(c, err)
|
2017-05-23 23:56:26 -04:00
|
|
|
|
2017-04-11 17:21:21 -04:00
|
|
|
drivers := strings.Join(info.Plugins.Log, " ")
|
2019-04-04 09:23:19 -04:00
|
|
|
assert.Assert(c, strings.Contains(drivers, "json-file"))
|
|
|
|
assert.Assert(c, !strings.Contains(drivers, pluginName))
|
2017-04-11 17:21:21 -04:00
|
|
|
}
|