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/docker/docker/integration-cli/checker"
|
|
|
|
"github.com/go-check/check"
|
|
|
|
)
|
|
|
|
|
|
|
|
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")
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Equals, "hello")
|
|
|
|
|
|
|
|
dockerCmd(c, "start", "-a", "test")
|
|
|
|
out, _ = dockerCmd(c, "logs", "test")
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Equals, "hello\nhello")
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
cli, err := client.NewEnvClient()
|
2017-04-11 17:21:21 -04:00
|
|
|
c.Assert(err, checker.IsNil)
|
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())
|
2017-04-11 17:21:21 -04:00
|
|
|
c.Assert(err, checker.IsNil)
|
2017-05-23 23:56:26 -04:00
|
|
|
|
2017-04-11 17:21:21 -04:00
|
|
|
drivers := strings.Join(info.Plugins.Log, " ")
|
|
|
|
c.Assert(drivers, checker.Contains, "json-file")
|
|
|
|
c.Assert(drivers, checker.Not(checker.Contains), pluginName)
|
|
|
|
}
|