1package main
2
3import (
4	"strings"
5
6	"github.com/docker/docker/client"
7	"github.com/docker/docker/integration-cli/checker"
8	"github.com/go-check/check"
9	"golang.org/x/net/context"
10)
11
12func (s *DockerSuite) TestPluginLogDriver(c *check.C) {
13	testRequires(c, IsAmd64, DaemonIsLinux)
14
15	pluginName := "cpuguy83/docker-logdriver-test:latest"
16
17	dockerCmd(c, "plugin", "install", pluginName)
18	dockerCmd(c, "run", "--log-driver", pluginName, "--name=test", "busybox", "echo", "hello")
19	out, _ := dockerCmd(c, "logs", "test")
20	c.Assert(strings.TrimSpace(out), checker.Equals, "hello")
21
22	dockerCmd(c, "start", "-a", "test")
23	out, _ = dockerCmd(c, "logs", "test")
24	c.Assert(strings.TrimSpace(out), checker.Equals, "hello\nhello")
25
26	dockerCmd(c, "rm", "test")
27	dockerCmd(c, "plugin", "disable", pluginName)
28	dockerCmd(c, "plugin", "rm", pluginName)
29}
30
31// Make sure log drivers are listed in info, and v2 plugins are not.
32func (s *DockerSuite) TestPluginLogDriverInfoList(c *check.C) {
33	testRequires(c, IsAmd64, DaemonIsLinux)
34	pluginName := "cpuguy83/docker-logdriver-test"
35
36	dockerCmd(c, "plugin", "install", pluginName)
37
38	cli, err := client.NewEnvClient()
39	c.Assert(err, checker.IsNil)
40	defer cli.Close()
41
42	info, err := cli.Info(context.Background())
43	c.Assert(err, checker.IsNil)
44
45	drivers := strings.Join(info.Plugins.Log, " ")
46	c.Assert(drivers, checker.Contains, "json-file")
47	c.Assert(drivers, checker.Not(checker.Contains), pluginName)
48}
49