2016-06-15 17:18:55 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2018-04-19 22:30:59 +00:00
|
|
|
"context"
|
2016-12-12 23:05:53 +00:00
|
|
|
"fmt"
|
2021-08-24 10:10:50 +00:00
|
|
|
"io"
|
2017-04-14 01:56:50 +00:00
|
|
|
"net/http"
|
2016-07-27 20:38:13 +00:00
|
|
|
"os"
|
2017-07-12 20:31:13 +00:00
|
|
|
"path"
|
2016-07-27 20:38:13 +00:00
|
|
|
"path/filepath"
|
2016-07-15 17:37:17 +00:00
|
|
|
"strings"
|
2019-09-09 21:06:12 +00:00
|
|
|
"testing"
|
2017-07-12 20:31:13 +00:00
|
|
|
"time"
|
2017-01-05 18:08:24 +00:00
|
|
|
|
2017-07-12 20:31:13 +00:00
|
|
|
"github.com/docker/docker/api/types"
|
2017-04-19 12:04:39 +00:00
|
|
|
"github.com/docker/docker/integration-cli/cli"
|
2017-04-14 01:56:50 +00:00
|
|
|
"github.com/docker/docker/integration-cli/daemon"
|
2023-07-14 18:02:38 +00:00
|
|
|
"github.com/docker/docker/testutil"
|
2019-08-29 20:52:40 +00:00
|
|
|
"github.com/docker/docker/testutil/fixtures/plugin"
|
2020-02-07 13:39:24 +00:00
|
|
|
"gotest.tools/v3/assert"
|
2020-10-26 15:05:19 +00:00
|
|
|
is "gotest.tools/v3/assert/cmp"
|
2022-08-25 13:19:15 +00:00
|
|
|
"gotest.tools/v3/skip"
|
2016-07-15 17:37:17 +00:00
|
|
|
)
|
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
const (
|
2016-11-22 19:21:34 +00:00
|
|
|
pluginProcessName = "sample-volume-plugin"
|
2017-01-05 21:55:43 +00:00
|
|
|
pName = "tiborvass/sample-volume-plugin"
|
|
|
|
npName = "tiborvass/test-docker-netplugin"
|
2016-11-10 21:07:53 +00:00
|
|
|
pTag = "latest"
|
|
|
|
pNameWithTag = pName + ":" + pTag
|
2016-12-16 20:53:22 +00:00
|
|
|
npNameWithTag = npName + ":" + pTag
|
2016-06-15 17:18:55 +00:00
|
|
|
)
|
|
|
|
|
2022-06-16 21:32:10 +00:00
|
|
|
type DockerCLIPluginsSuite struct {
|
|
|
|
ds *DockerSuite
|
|
|
|
}
|
|
|
|
|
2023-07-14 18:02:38 +00:00
|
|
|
func (s *DockerCLIPluginsSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
|
|
s.ds.TearDownTest(ctx, c)
|
2022-06-16 21:32:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerCLIPluginsSuite) OnTimeout(c *testing.T) {
|
|
|
|
s.ds.OnTimeout(c)
|
|
|
|
}
|
|
|
|
|
2019-09-09 21:05:55 +00:00
|
|
|
func (ps *DockerPluginSuite) TestPluginBasicOps(c *testing.T) {
|
2023-07-28 08:49:01 +00:00
|
|
|
pluginName := ps.getPluginRepoWithTag()
|
|
|
|
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-06-15 17:18:55 +00:00
|
|
|
|
|
|
|
out, _, err := dockerCmdWithError("plugin", "ls")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2023-07-28 08:49:01 +00:00
|
|
|
assert.Check(c, is.Contains(out, pluginName))
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, "true"))
|
2023-07-28 08:49:01 +00:00
|
|
|
id, _, err := dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pluginName)
|
2016-11-05 00:37:41 +00:00
|
|
|
id = strings.TrimSpace(id)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-06-15 17:18:55 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "")
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, "is enabled"))
|
2023-07-28 08:49:01 +00:00
|
|
|
_, _, err = dockerCmdWithError("plugin", "disable", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-06-15 17:18:55 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2023-07-28 08:49:01 +00:00
|
|
|
assert.Check(c, is.Contains(out, pluginName))
|
2018-01-15 14:28:10 +00:00
|
|
|
_, err = os.Stat(filepath.Join(testEnv.DaemonInfo.DockerRootDir, "plugins", id))
|
2016-07-27 20:38:13 +00:00
|
|
|
if !os.IsNotExist(err) {
|
|
|
|
c.Fatal(err)
|
|
|
|
}
|
2016-06-15 17:18:55 +00:00
|
|
|
}
|
2016-06-17 14:44:57 +00:00
|
|
|
|
2019-09-09 21:05:55 +00:00
|
|
|
func (ps *DockerPluginSuite) TestPluginForceRemove(c *testing.T) {
|
2023-07-28 08:49:01 +00:00
|
|
|
pluginName := ps.getPluginRepoWithTag()
|
2017-07-12 20:31:13 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-07-22 15:24:54 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
out, _, _ := dockerCmdWithError("plugin", "remove", pluginName)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, "is enabled"))
|
2023-07-28 08:49:01 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", "--force", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2023-07-28 08:49:01 +00:00
|
|
|
assert.Check(c, is.Contains(out, pluginName))
|
2016-09-07 13:59:15 +00:00
|
|
|
}
|
|
|
|
|
2022-06-16 21:32:10 +00:00
|
|
|
func (s *DockerCLIPluginsSuite) TestPluginActive(c *testing.T) {
|
2016-12-12 20:46:36 +00:00
|
|
|
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
2017-07-12 20:31:13 +00:00
|
|
|
|
2016-12-20 16:26:58 +00:00
|
|
|
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-09-07 13:59:15 +00:00
|
|
|
|
2016-12-20 16:26:58 +00:00
|
|
|
_, _, err = dockerCmdWithError("volume", "create", "-d", pNameWithTag, "--name", "testvol1")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-09-07 13:59:15 +00:00
|
|
|
|
2018-07-09 17:40:34 +00:00
|
|
|
out, _, _ := dockerCmdWithError("plugin", "disable", pNameWithTag)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, "in use"))
|
2016-12-20 16:26:58 +00:00
|
|
|
_, _, err = dockerCmdWithError("volume", "rm", "testvol1")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-09-07 13:59:15 +00:00
|
|
|
|
|
|
|
_, _, err = dockerCmdWithError("plugin", "disable", pNameWithTag)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-09-07 13:59:15 +00:00
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, pNameWithTag))
|
2016-07-22 15:24:54 +00:00
|
|
|
}
|
|
|
|
|
2022-06-16 21:32:10 +00:00
|
|
|
func (s *DockerCLIPluginsSuite) TestPluginActiveNetwork(c *testing.T) {
|
2016-12-16 20:53:22 +00:00
|
|
|
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
2018-07-09 17:40:34 +00:00
|
|
|
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", npNameWithTag)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-12-16 20:53:22 +00:00
|
|
|
|
2018-07-09 17:40:34 +00:00
|
|
|
out, _, err := dockerCmdWithError("network", "create", "-d", npNameWithTag, "test")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-12-16 20:53:22 +00:00
|
|
|
|
|
|
|
nID := strings.TrimSpace(out)
|
|
|
|
|
2018-07-09 17:40:34 +00:00
|
|
|
out, _, _ = dockerCmdWithError("plugin", "remove", npNameWithTag)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, "is in use"))
|
2016-12-16 20:53:22 +00:00
|
|
|
_, _, err = dockerCmdWithError("network", "rm", nID)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-12-16 20:53:22 +00:00
|
|
|
|
2018-07-09 17:40:34 +00:00
|
|
|
out, _, _ = dockerCmdWithError("plugin", "remove", npNameWithTag)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, "is enabled"))
|
2016-12-16 20:53:22 +00:00
|
|
|
_, _, err = dockerCmdWithError("plugin", "disable", npNameWithTag)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-12-16 20:53:22 +00:00
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", npNameWithTag)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, npNameWithTag))
|
2016-12-16 20:53:22 +00:00
|
|
|
}
|
|
|
|
|
2019-09-09 21:05:55 +00:00
|
|
|
func (ps *DockerPluginSuite) TestPluginInstallDisable(c *testing.T) {
|
2023-07-28 08:49:01 +00:00
|
|
|
pluginName := ps.getPluginRepoWithTag()
|
2017-07-12 20:31:13 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2023-07-28 08:49:01 +00:00
|
|
|
assert.Check(c, is.Contains(out, pluginName))
|
2016-07-15 17:37:17 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "ls")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, "false"))
|
2023-07-28 08:49:01 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "enable", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2023-07-28 08:49:01 +00:00
|
|
|
assert.Check(c, is.Contains(out, pluginName))
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "disable", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2023-07-28 08:49:01 +00:00
|
|
|
assert.Check(c, is.Contains(out, pluginName))
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2023-07-28 08:49:01 +00:00
|
|
|
assert.Check(c, is.Contains(out, pluginName))
|
2016-06-17 14:44:57 +00:00
|
|
|
}
|
2016-07-06 19:16:14 +00:00
|
|
|
|
2022-06-16 21:32:10 +00:00
|
|
|
func (s *DockerCLIPluginsSuite) TestPluginInstallDisableVolumeLs(c *testing.T) {
|
2016-12-12 20:46:36 +00:00
|
|
|
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
2016-11-01 22:03:14 +00:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, pName))
|
2023-07-28 08:49:01 +00:00
|
|
|
cli.DockerCmd(c, "volume", "ls")
|
2016-11-01 22:03:14 +00:00
|
|
|
}
|
|
|
|
|
2019-09-09 21:05:55 +00:00
|
|
|
func (ps *DockerPluginSuite) TestPluginSet(c *testing.T) {
|
2017-09-19 20:12:29 +00:00
|
|
|
client := testEnv.APIClient()
|
2016-11-01 00:07:05 +00:00
|
|
|
|
2017-07-12 20:31:13 +00:00
|
|
|
name := "test"
|
2023-07-14 18:02:38 +00:00
|
|
|
ctx, cancel := context.WithTimeout(testutil.GetContext(c), 60*time.Second)
|
2017-07-12 20:31:13 +00:00
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
initialValue := "0"
|
2017-11-28 21:04:13 +00:00
|
|
|
mntSrc := "foo"
|
|
|
|
devPath := "/dev/bar"
|
|
|
|
|
2017-09-19 20:12:29 +00:00
|
|
|
// Create a new plugin with extra settings
|
|
|
|
err := plugin.Create(ctx, client, name, func(cfg *plugin.Config) {
|
2017-07-12 20:31:13 +00:00
|
|
|
cfg.Env = []types.PluginEnv{{Name: "DEBUG", Value: &initialValue, Settable: []string{"value"}}}
|
2017-11-28 21:04:13 +00:00
|
|
|
cfg.Mounts = []types.PluginMount{
|
|
|
|
{Name: "pmount1", Settable: []string{"source"}, Type: "none", Source: &mntSrc},
|
|
|
|
{Name: "pmount2", Settable: []string{"source"}, Type: "none"}, // Mount without source is invalid.
|
|
|
|
}
|
|
|
|
cfg.Linux.Devices = []types.PluginDevice{
|
|
|
|
{Name: "pdev1", Path: &devPath, Settable: []string{"path"}},
|
|
|
|
{Name: "pdev2", Settable: []string{"path"}}, // Device without Path is invalid.
|
|
|
|
}
|
2017-07-12 20:31:13 +00:00
|
|
|
})
|
2019-09-09 21:08:22 +00:00
|
|
|
assert.Assert(c, err == nil, "failed to create test plugin")
|
2017-07-12 20:31:13 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
env := cli.DockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", name).Stdout()
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Equal(strings.TrimSpace(env), "[DEBUG=0]"))
|
2016-11-01 00:07:05 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
cli.DockerCmd(c, "plugin", "set", name, "DEBUG=1")
|
2016-11-01 00:07:05 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
env = cli.DockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", name).Stdout()
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Equal(strings.TrimSpace(env), "[DEBUG=1]"))
|
2017-11-28 21:04:13 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
mounts := cli.DockerCmd(c, "plugin", "inspect", "-f", "{{with $mount := index .Settings.Mounts 0}}{{$mount.Source}}{{end}}", name).Stdout()
|
|
|
|
assert.Check(c, is.Contains(mounts, mntSrc))
|
|
|
|
cli.DockerCmd(c, "plugin", "set", name, "pmount1.source=bar")
|
2017-11-28 21:04:13 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
mounts = cli.DockerCmd(c, "plugin", "inspect", "-f", "{{with $mount := index .Settings.Mounts 0}}{{$mount.Source}}{{end}}", name).Stdout()
|
|
|
|
assert.Check(c, is.Contains(mounts, "bar"))
|
2017-11-28 21:04:13 +00:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "set", name, "pmount2.source=bar2")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "")
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, "Plugin config has no mount source"))
|
2017-11-28 21:04:13 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "set", name, "pdev2.path=/dev/bar2")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "")
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, "Plugin config has no device path"))
|
2016-11-01 00:07:05 +00:00
|
|
|
}
|
|
|
|
|
2019-09-09 21:05:55 +00:00
|
|
|
func (ps *DockerPluginSuite) TestPluginInstallArgs(c *testing.T) {
|
2023-07-28 08:49:01 +00:00
|
|
|
pluginName := path.Join(ps.registryHost(), "plugin", "testplugininstallwithargs")
|
2023-07-14 18:02:38 +00:00
|
|
|
ctx, cancel := context.WithTimeout(testutil.GetContext(c), 60*time.Second)
|
2017-07-12 20:31:13 +00:00
|
|
|
defer cancel()
|
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
plugin.CreateInRegistry(ctx, pluginName, nil, func(cfg *plugin.Config) {
|
2017-07-12 20:31:13 +00:00
|
|
|
cfg.Env = []types.PluginEnv{{Name: "DEBUG", Settable: []string{"value"}}}
|
|
|
|
})
|
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
out := cli.DockerCmd(c, "plugin", "install", "--grant-all-permissions", "--disable", pluginName, "DEBUG=1").Stdout()
|
|
|
|
assert.Check(c, is.Contains(out, pluginName))
|
|
|
|
env := cli.DockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", pluginName).Stdout()
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Equal(strings.TrimSpace(env), "[DEBUG=1]"))
|
2016-11-08 01:43:11 +00:00
|
|
|
}
|
|
|
|
|
2019-09-09 21:05:55 +00:00
|
|
|
func (ps *DockerPluginSuite) TestPluginInstallImage(c *testing.T) {
|
2017-07-12 20:31:13 +00:00
|
|
|
testRequires(c, IsAmd64)
|
2022-08-25 13:19:15 +00:00
|
|
|
skip.If(c, GitHubActions, "FIXME: https://github.com/moby/moby/issues/43996")
|
2016-12-12 23:05:53 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
const imgRepo = privateRegistryURL + "/dockercli/busybox"
|
2016-12-12 23:05:53 +00:00
|
|
|
// tag the image to upload it to the private registry
|
2023-07-28 08:49:01 +00:00
|
|
|
cli.DockerCmd(c, "tag", "busybox", imgRepo)
|
2016-12-12 23:05:53 +00:00
|
|
|
// push the image to the registry
|
2023-07-28 08:49:01 +00:00
|
|
|
cli.DockerCmd(c, "push", imgRepo)
|
2016-12-12 23:05:53 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "install", imgRepo)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "")
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, `Encountered remote "application/vnd.docker.container.image.v1+json"(image) when fetching`))
|
2016-07-06 19:16:14 +00:00
|
|
|
}
|
2016-07-25 21:06:27 +00:00
|
|
|
|
2019-09-09 21:05:55 +00:00
|
|
|
func (ps *DockerPluginSuite) TestPluginEnableDisableNegative(c *testing.T) {
|
2023-07-28 08:49:01 +00:00
|
|
|
pluginName := ps.getPluginRepoWithTag()
|
2017-07-12 20:31:13 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2023-07-28 08:49:01 +00:00
|
|
|
assert.Check(c, is.Contains(out, pluginName))
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "enable", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "")
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, "already enabled"))
|
2023-07-28 08:49:01 +00:00
|
|
|
_, _, err = dockerCmdWithError("plugin", "disable", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-07-25 21:06:27 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "disable", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "")
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, "already disabled"))
|
2023-07-28 08:49:01 +00:00
|
|
|
_, _, err = dockerCmdWithError("plugin", "remove", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-07-25 21:06:27 +00:00
|
|
|
}
|
2016-11-22 17:42:58 +00:00
|
|
|
|
2019-09-09 21:05:55 +00:00
|
|
|
func (ps *DockerPluginSuite) TestPluginCreate(c *testing.T) {
|
2016-11-22 17:42:58 +00:00
|
|
|
name := "foo/bar-driver"
|
2021-08-24 10:10:50 +00:00
|
|
|
temp, err := os.MkdirTemp("", "foo")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-11-22 17:42:58 +00:00
|
|
|
defer os.RemoveAll(temp)
|
|
|
|
|
|
|
|
data := `{"description": "foo plugin"}`
|
2022-01-20 12:43:42 +00:00
|
|
|
err = os.WriteFile(filepath.Join(temp, "config.json"), []byte(data), 0o644)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-11-22 17:42:58 +00:00
|
|
|
|
2022-01-20 12:43:42 +00:00
|
|
|
err = os.MkdirAll(filepath.Join(temp, "rootfs"), 0o700)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-12-12 23:05:53 +00:00
|
|
|
|
2016-11-22 17:42:58 +00:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "create", name, temp)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, name))
|
2016-11-22 17:42:58 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "ls")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, name))
|
2016-11-22 17:42:58 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "create", name, temp)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "")
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, "already exist"))
|
2016-11-22 17:42:58 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "ls")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, name))
|
2016-11-22 17:42:58 +00:00
|
|
|
// The output will consists of one HEADER line and one line of foo/bar-driver
|
2019-09-09 21:05:56 +00:00
|
|
|
assert.Equal(c, len(strings.Split(strings.TrimSpace(out), "\n")), 2)
|
2016-11-22 17:42:58 +00:00
|
|
|
}
|
2016-11-24 04:04:44 +00:00
|
|
|
|
2019-09-09 21:05:55 +00:00
|
|
|
func (ps *DockerPluginSuite) TestPluginInspect(c *testing.T) {
|
2023-07-28 08:49:01 +00:00
|
|
|
pluginName := ps.getPluginRepoWithTag()
|
2017-07-12 20:31:13 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-11-24 04:04:44 +00:00
|
|
|
|
|
|
|
out, _, err := dockerCmdWithError("plugin", "ls")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2023-07-28 08:49:01 +00:00
|
|
|
assert.Check(c, is.Contains(out, pluginName))
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, "true"))
|
2016-11-24 04:04:44 +00:00
|
|
|
// Find the ID first
|
2023-07-28 08:49:01 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-11-24 04:04:44 +00:00
|
|
|
id := strings.TrimSpace(out)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.Assert(c, id != "")
|
2016-11-24 04:04:44 +00:00
|
|
|
|
|
|
|
// Long form
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", id)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Equal(strings.TrimSpace(out), id))
|
2016-11-24 04:04:44 +00:00
|
|
|
|
|
|
|
// Short form
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", id[:5])
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Equal(strings.TrimSpace(out), id))
|
2016-11-24 04:04:44 +00:00
|
|
|
|
|
|
|
// Name with tag form
|
2023-07-28 08:49:01 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Equal(strings.TrimSpace(out), id))
|
2016-11-24 04:04:44 +00:00
|
|
|
|
|
|
|
// Name without tag form
|
2017-07-12 20:31:13 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", ps.getPluginRepo())
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Equal(strings.TrimSpace(out), id))
|
2016-11-24 04:04:44 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
_, _, err = dockerCmdWithError("plugin", "disable", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-11-24 04:04:44 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pluginName)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2023-07-28 08:49:01 +00:00
|
|
|
assert.Check(c, is.Contains(out, pluginName))
|
2016-11-24 04:04:44 +00:00
|
|
|
// After remove nothing should be found
|
|
|
|
_, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", id[:5])
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "")
|
2016-11-24 04:04:44 +00:00
|
|
|
}
|
2016-12-07 15:38:18 +00:00
|
|
|
|
|
|
|
// Test case for https://github.com/docker/docker/pull/29186#discussion_r91277345
|
2022-06-16 21:32:10 +00:00
|
|
|
func (s *DockerCLIPluginsSuite) TestPluginInspectOnWindows(c *testing.T) {
|
2016-12-07 15:38:18 +00:00
|
|
|
// This test should work on Windows only
|
|
|
|
testRequires(c, DaemonIsWindows)
|
|
|
|
|
|
|
|
out, _, err := dockerCmdWithError("plugin", "inspect", "foobar")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "")
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, "plugins are not supported on this platform"))
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "plugins are not supported on this platform")
|
2016-12-07 15:38:18 +00:00
|
|
|
}
|
2016-12-27 20:51:00 +00:00
|
|
|
|
2019-09-09 21:05:55 +00:00
|
|
|
func (ps *DockerPluginSuite) TestPluginIDPrefix(c *testing.T) {
|
2017-07-12 20:31:13 +00:00
|
|
|
name := "test"
|
2017-09-19 20:12:29 +00:00
|
|
|
client := testEnv.APIClient()
|
2017-07-12 20:31:13 +00:00
|
|
|
|
2023-07-14 18:02:38 +00:00
|
|
|
ctx, cancel := context.WithTimeout(testutil.GetContext(c), 60*time.Second)
|
2017-07-12 20:31:13 +00:00
|
|
|
initialValue := "0"
|
2017-09-19 20:12:29 +00:00
|
|
|
err := plugin.Create(ctx, client, name, func(cfg *plugin.Config) {
|
2017-07-12 20:31:13 +00:00
|
|
|
cfg.Env = []types.PluginEnv{{Name: "DEBUG", Value: &initialValue, Settable: []string{"value"}}}
|
|
|
|
})
|
|
|
|
cancel()
|
|
|
|
|
2019-09-09 21:08:22 +00:00
|
|
|
assert.Assert(c, err == nil, "failed to create test plugin")
|
2016-12-22 23:41:53 +00:00
|
|
|
|
|
|
|
// Find ID first
|
2017-07-12 20:31:13 +00:00
|
|
|
id, _, err := dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", name)
|
2016-12-22 23:41:53 +00:00
|
|
|
id = strings.TrimSpace(id)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-12-22 23:41:53 +00:00
|
|
|
|
|
|
|
// List current state
|
|
|
|
out, _, err := dockerCmdWithError("plugin", "ls")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, name))
|
|
|
|
assert.Check(c, is.Contains(out, "false"))
|
2023-07-28 08:49:01 +00:00
|
|
|
env := cli.DockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", id[:5]).Stdout()
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Equal(strings.TrimSpace(env), "[DEBUG=0]"))
|
2016-12-22 23:41:53 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
cli.DockerCmd(c, "plugin", "set", id[:5], "DEBUG=1")
|
2016-12-22 23:41:53 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
env = cli.DockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", id[:5]).Stdout()
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Equal(strings.TrimSpace(env), "[DEBUG=1]"))
|
2016-12-22 23:41:53 +00:00
|
|
|
|
|
|
|
// Enable
|
|
|
|
_, _, err = dockerCmdWithError("plugin", "enable", id[:5])
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-12-22 23:41:53 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "ls")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, name))
|
|
|
|
assert.Check(c, is.Contains(out, "true"))
|
2016-12-22 23:41:53 +00:00
|
|
|
// Disable
|
|
|
|
_, _, err = dockerCmdWithError("plugin", "disable", id[:5])
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-12-22 23:41:53 +00:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "ls")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, name))
|
|
|
|
assert.Check(c, is.Contains(out, "false"))
|
2016-12-22 23:41:53 +00:00
|
|
|
// Remove
|
2018-07-09 17:40:34 +00:00
|
|
|
_, _, err = dockerCmdWithError("plugin", "remove", id[:5])
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-12-22 23:41:53 +00:00
|
|
|
// List returns none
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "ls")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2019-09-09 21:07:46 +00:00
|
|
|
assert.Assert(c, !strings.Contains(out, name))
|
2016-12-22 23:41:53 +00:00
|
|
|
}
|
2016-11-23 00:23:21 +00:00
|
|
|
|
2019-09-09 21:05:55 +00:00
|
|
|
func (ps *DockerPluginSuite) TestPluginListDefaultFormat(c *testing.T) {
|
2021-08-24 10:10:50 +00:00
|
|
|
config, err := os.MkdirTemp("", "config-file-")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-11-23 00:23:21 +00:00
|
|
|
defer os.RemoveAll(config)
|
|
|
|
|
2022-01-20 12:43:42 +00:00
|
|
|
err = os.WriteFile(filepath.Join(config, "config.json"), []byte(`{"pluginsFormat": "raw"}`), 0o644)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2016-11-23 00:23:21 +00:00
|
|
|
|
2017-07-12 20:31:13 +00:00
|
|
|
name := "test:latest"
|
2017-09-19 20:12:29 +00:00
|
|
|
client := testEnv.APIClient()
|
2017-07-12 20:31:13 +00:00
|
|
|
|
2023-07-14 18:02:38 +00:00
|
|
|
ctx, cancel := context.WithTimeout(testutil.GetContext(c), 60*time.Second)
|
2017-07-12 20:31:13 +00:00
|
|
|
defer cancel()
|
|
|
|
err = plugin.Create(ctx, client, name, func(cfg *plugin.Config) {
|
|
|
|
cfg.Description = "test plugin"
|
|
|
|
})
|
2019-09-09 21:08:22 +00:00
|
|
|
assert.Assert(c, err == nil, "failed to create test plugin")
|
2016-11-23 00:23:21 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
id := cli.DockerCmd(c, "plugin", "inspect", "--format", "{{.ID}}", name).Stdout()
|
|
|
|
id = strings.TrimSpace(id)
|
2016-11-23 00:23:21 +00:00
|
|
|
|
|
|
|
// We expect the format to be in `raw + --no-trunc`
|
|
|
|
expectedOutput := fmt.Sprintf(`plugin_id: %s
|
|
|
|
name: %s
|
2017-07-12 20:31:13 +00:00
|
|
|
description: test plugin
|
|
|
|
enabled: false`, id, name)
|
2016-11-23 00:23:21 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
out := cli.DockerCmd(c, "--config", config, "plugin", "ls", "--no-trunc").Combined()
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, expectedOutput))
|
2016-11-23 00:23:21 +00:00
|
|
|
}
|
2017-01-29 00:54:32 +00:00
|
|
|
|
2022-06-16 21:32:10 +00:00
|
|
|
func (s *DockerCLIPluginsSuite) TestPluginUpgrade(c *testing.T) {
|
2018-12-24 12:25:53 +00:00
|
|
|
testRequires(c, DaemonIsLinux, Network, testEnv.IsLocalDaemon, IsAmd64, NotUserNamespace)
|
2023-07-28 08:49:01 +00:00
|
|
|
const pluginName = "cpuguy83/docker-volume-driver-plugin-local:latest"
|
|
|
|
const pluginV2 = "cpuguy83/docker-volume-driver-plugin-local:v2"
|
2017-01-29 00:54:32 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
cli.DockerCmd(c, "plugin", "install", "--grant-all-permissions", pluginName)
|
|
|
|
cli.DockerCmd(c, "volume", "create", "--driver", pluginName, "bananas")
|
|
|
|
cli.DockerCmd(c, "run", "--rm", "-v", "bananas:/apple", "busybox", "sh", "-c", "touch /apple/core")
|
2017-02-03 04:08:35 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "upgrade", "--grant-all-permissions", pluginName, pluginV2)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.ErrorContains(c, err, "", out)
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(out, "disabled before upgrading"))
|
2023-07-28 08:49:01 +00:00
|
|
|
id := cli.DockerCmd(c, "plugin", "inspect", "--format={{.ID}}", pluginName).Stdout()
|
|
|
|
id = strings.TrimSpace(id)
|
2017-01-29 00:54:32 +00:00
|
|
|
|
|
|
|
// make sure "v2" does not exists
|
2018-01-15 14:28:10 +00:00
|
|
|
_, err = os.Stat(filepath.Join(testEnv.DaemonInfo.DockerRootDir, "plugins", id, "rootfs", "v2"))
|
integration-cli: S1025: the argument is already a string (gosimple)
```
integration-cli/docker_cli_daemon_test.go:1753:32: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_daemon_test.go:1783:31: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_daemon_test.go:1893:92: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_external_volume_driver_test.go:444:34: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_external_volume_driver_test.go:600:36: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_external_volume_driver_test.go:602:36: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_external_volume_driver_test.go:610:34: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_external_volume_driver_test.go:613:34: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_external_volume_driver_test.go:614:36: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_external_volume_driver_test.go:617:36: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_plugins_test.go:431:39: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_swarm_test.go:174:31: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_swarm_test.go:1046:31: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_swarm_test.go:1071:31: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_swarm_test.go:1074:31: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_swarm_test.go:1079:31: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_swarm_test.go:1087:31: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_swarm_test.go:1102:31: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_swarm_test.go:1108:31: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_swarm_test.go:1128:31: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_swarm_test.go:1323:31: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_swarm_test.go:1329:32: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_swarm_test.go:1388:34: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
integration-cli/docker_cli_swarm_test.go:1985:31: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
```
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-11 10:36:00 +00:00
|
|
|
assert.Assert(c, os.IsNotExist(err), out)
|
2017-01-29 00:54:32 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
cli.DockerCmd(c, "plugin", "disable", "-f", pluginName)
|
|
|
|
cli.DockerCmd(c, "plugin", "upgrade", "--grant-all-permissions", "--skip-remote-check", pluginName, pluginV2)
|
2017-01-29 00:54:32 +00:00
|
|
|
|
|
|
|
// make sure "v2" file exists
|
2018-01-15 14:28:10 +00:00
|
|
|
_, err = os.Stat(filepath.Join(testEnv.DaemonInfo.DockerRootDir, "plugins", id, "rootfs", "v2"))
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2017-01-29 00:54:32 +00:00
|
|
|
|
2023-07-28 08:49:01 +00:00
|
|
|
cli.DockerCmd(c, "plugin", "enable", pluginName)
|
|
|
|
cli.DockerCmd(c, "volume", "inspect", "bananas")
|
|
|
|
cli.DockerCmd(c, "run", "--rm", "-v", "bananas:/apple", "busybox", "sh", "-c", "ls -lh /apple/core")
|
2017-01-29 00:54:32 +00:00
|
|
|
}
|
2017-04-14 01:56:50 +00:00
|
|
|
|
2022-06-16 21:32:10 +00:00
|
|
|
func (s *DockerCLIPluginsSuite) TestPluginMetricsCollector(c *testing.T) {
|
2018-12-24 12:25:53 +00:00
|
|
|
testRequires(c, DaemonIsLinux, Network, testEnv.IsLocalDaemon, IsAmd64)
|
2018-04-13 15:02:56 +00:00
|
|
|
d := daemon.New(c, dockerBinary, dockerdBinary)
|
2017-04-14 01:56:50 +00:00
|
|
|
d.Start(c)
|
|
|
|
defer d.Stop(c)
|
|
|
|
|
|
|
|
name := "cpuguy83/docker-metrics-plugin-test:latest"
|
|
|
|
r := cli.Docker(cli.Args("plugin", "install", "--grant-all-permissions", name), cli.Daemon(d))
|
2019-09-09 21:08:22 +00:00
|
|
|
assert.Assert(c, r.Error == nil, r.Combined())
|
2017-04-14 01:56:50 +00:00
|
|
|
|
|
|
|
// plugin lisens on localhost:19393 and proxies the metrics
|
|
|
|
resp, err := http.Get("http://localhost:19393/metrics")
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2017-04-14 01:56:50 +00:00
|
|
|
defer resp.Body.Close()
|
|
|
|
|
2021-08-24 10:10:50 +00:00
|
|
|
b, err := io.ReadAll(resp.Body)
|
2019-04-04 13:23:19 +00:00
|
|
|
assert.NilError(c, err)
|
2017-05-21 23:24:07 +00:00
|
|
|
// check that a known metric is there... don't expect this metric to change over time.. probably safe
|
2020-10-26 15:05:19 +00:00
|
|
|
assert.Check(c, is.Contains(string(b), "container_actions"))
|
2017-04-14 01:56:50 +00:00
|
|
|
}
|