2016-11-14 18:53:53 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2018-04-19 22:30:59 +00:00
|
|
|
"context"
|
2016-11-14 18:53:53 +00:00
|
|
|
"strings"
|
2019-09-09 21:06:12 +00:00
|
|
|
"testing"
|
2016-11-14 18:53:53 +00:00
|
|
|
|
2017-05-24 03:56:26 +00:00
|
|
|
"github.com/docker/docker/client"
|
2020-02-07 13:39:24 +00:00
|
|
|
"gotest.tools/v3/assert"
|
2016-11-14 18:53:53 +00:00
|
|
|
)
|
|
|
|
|
2019-09-09 21:05:55 +00:00
|
|
|
func (s *DockerSuite) TestPluginLogDriver(c *testing.T) {
|
2016-11-14 18:53:53 +00:00
|
|
|
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 13:23:19 +00:00
|
|
|
assert.Equal(c, strings.TrimSpace(out), "hello")
|
2016-11-14 18:53:53 +00:00
|
|
|
|
|
|
|
dockerCmd(c, "start", "-a", "test")
|
|
|
|
out, _ = dockerCmd(c, "logs", "test")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.Equal(c, strings.TrimSpace(out), "hello\nhello")
|
2016-11-14 18:53:53 +00:00
|
|
|
|
|
|
|
dockerCmd(c, "rm", "test")
|
|
|
|
dockerCmd(c, "plugin", "disable", pluginName)
|
|
|
|
dockerCmd(c, "plugin", "rm", pluginName)
|
|
|
|
}
|
2017-04-11 21:21:21 +00:00
|
|
|
|
|
|
|
// Make sure log drivers are listed in info, and v2 plugins are not.
|
2019-09-09 21:05:55 +00:00
|
|
|
func (s *DockerSuite) TestPluginLogDriverInfoList(c *testing.T) {
|
2017-04-11 21:21:21 +00:00
|
|
|
testRequires(c, IsAmd64, DaemonIsLinux)
|
|
|
|
pluginName := "cpuguy83/docker-logdriver-test"
|
|
|
|
|
|
|
|
dockerCmd(c, "plugin", "install", pluginName)
|
2017-05-24 03:56:26 +00:00
|
|
|
|
2019-01-03 21:49:00 +00:00
|
|
|
cli, err := client.NewClientWithOpts(client.FromEnv)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2017-05-24 03:56:26 +00:00
|
|
|
defer cli.Close()
|
2017-04-11 21:21:21 +00:00
|
|
|
|
2017-05-24 03:56:26 +00:00
|
|
|
info, err := cli.Info(context.Background())
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2017-05-24 03:56:26 +00:00
|
|
|
|
2017-04-11 21:21:21 +00:00
|
|
|
drivers := strings.Join(info.Plugins.Log, " ")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.Assert(c, strings.Contains(drivers, "json-file"))
|
|
|
|
assert.Assert(c, !strings.Contains(drivers, pluginName))
|
2017-04-11 21:21:21 +00:00
|
|
|
}
|