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"
|
2019-09-09 17:06:12 -04:00
|
|
|
"testing"
|
2016-11-14 13:53:53 -05:00
|
|
|
|
2017-05-23 23:56:26 -04:00
|
|
|
"github.com/docker/docker/client"
|
2020-02-07 08:39:24 -05:00
|
|
|
"gotest.tools/v3/assert"
|
2016-11-14 13:53:53 -05:00
|
|
|
)
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerSuite) TestPluginLogDriver(c *testing.T) {
|
2016-11-14 13:53:53 -05: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 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.
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerSuite) TestPluginLogDriverInfoList(c *testing.T) {
|
2017-04-11 17:21:21 -04:00
|
|
|
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
|
|
|
}
|