2016-06-15 13:18:55 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/docker/docker/pkg/integration/checker"
|
|
|
|
"github.com/go-check/check"
|
2016-07-15 13:37:17 -04:00
|
|
|
|
2016-07-27 16:38:13 -04:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2016-07-15 13:37:17 -04:00
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2016-11-10 16:07:53 -05:00
|
|
|
pluginProcessName = "no-remove"
|
|
|
|
pName = "tiborvass/no-remove"
|
|
|
|
pTag = "latest"
|
|
|
|
pNameWithTag = pName + ":" + pTag
|
2016-06-15 13:18:55 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func (s *DockerSuite) TestPluginBasicOps(c *check.C) {
|
2016-11-09 20:49:09 -05:00
|
|
|
testRequires(c, DaemonIsLinux, Network)
|
2016-07-15 13:37:17 -04:00
|
|
|
_, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
|
2016-06-15 13:18:55 -04:00
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
out, _, err := dockerCmdWithError("plugin", "ls")
|
|
|
|
c.Assert(err, checker.IsNil)
|
2016-07-15 13:37:17 -04:00
|
|
|
c.Assert(out, checker.Contains, pName)
|
|
|
|
c.Assert(out, checker.Contains, pTag)
|
2016-06-15 13:18:55 -04:00
|
|
|
c.Assert(out, checker.Contains, "true")
|
|
|
|
|
2016-08-17 07:52:27 -04:00
|
|
|
id, _, err := dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pNameWithTag)
|
2016-11-04 20:37:41 -04:00
|
|
|
id = strings.TrimSpace(id)
|
2016-07-27 16:38:13 -04:00
|
|
|
c.Assert(err, checker.IsNil)
|
2016-06-15 13:18:55 -04:00
|
|
|
|
2016-07-15 13:37:17 -04:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
2016-08-04 19:19:46 -04:00
|
|
|
c.Assert(out, checker.Contains, "is enabled")
|
2016-06-15 13:18:55 -04:00
|
|
|
|
2016-07-15 13:37:17 -04:00
|
|
|
_, _, err = dockerCmdWithError("plugin", "disable", pNameWithTag)
|
2016-06-15 13:18:55 -04:00
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
2016-07-15 13:37:17 -04:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
2016-06-15 13:18:55 -04:00
|
|
|
c.Assert(err, checker.IsNil)
|
2016-07-15 13:37:17 -04:00
|
|
|
c.Assert(out, checker.Contains, pNameWithTag)
|
2016-07-27 16:38:13 -04:00
|
|
|
|
2016-08-17 07:52:27 -04:00
|
|
|
_, err = os.Stat(filepath.Join(dockerBasePath, "plugins", id))
|
2016-07-27 16:38:13 -04:00
|
|
|
if !os.IsNotExist(err) {
|
|
|
|
c.Fatal(err)
|
|
|
|
}
|
2016-06-15 13:18:55 -04:00
|
|
|
}
|
2016-06-17 10:44:57 -04:00
|
|
|
|
2016-07-22 11:24:54 -04:00
|
|
|
func (s *DockerSuite) TestPluginForceRemove(c *check.C) {
|
2016-11-09 20:49:09 -05:00
|
|
|
testRequires(c, DaemonIsLinux, Network)
|
2016-07-22 11:24:54 -04:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
2016-08-04 19:19:46 -04:00
|
|
|
c.Assert(out, checker.Contains, "is enabled")
|
2016-07-22 11:24:54 -04:00
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", "--force", pNameWithTag)
|
2016-09-07 09:59:15 -04:00
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, pNameWithTag)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerSuite) TestPluginActive(c *check.C) {
|
2016-11-11 12:50:43 -05:00
|
|
|
testRequires(c, DaemonIsLinux, Network, IsAmd64)
|
2016-09-07 09:59:15 -04:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("volume", "create", "-d", pNameWithTag)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
vID := strings.TrimSpace(out)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
|
|
|
c.Assert(out, checker.Contains, "is in use")
|
|
|
|
|
|
|
|
_, _, err = dockerCmdWithError("volume", "rm", vID)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
|
|
|
c.Assert(out, checker.Contains, "is enabled")
|
|
|
|
|
|
|
|
_, _, err = dockerCmdWithError("plugin", "disable", pNameWithTag)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
2016-07-22 11:24:54 -04:00
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, pNameWithTag)
|
|
|
|
}
|
|
|
|
|
2016-06-17 10:44:57 -04:00
|
|
|
func (s *DockerSuite) TestPluginInstallDisable(c *check.C) {
|
2016-11-09 20:49:09 -05:00
|
|
|
testRequires(c, DaemonIsLinux, Network)
|
2016-07-15 13:37:17 -04:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName)
|
2016-06-17 10:44:57 -04:00
|
|
|
c.Assert(err, checker.IsNil)
|
2016-07-15 13:37:17 -04:00
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
2016-06-17 10:44:57 -04:00
|
|
|
|
2016-07-15 13:37:17 -04:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "ls")
|
2016-06-17 10:44:57 -04:00
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(out, checker.Contains, "false")
|
|
|
|
|
2016-07-15 13:37:17 -04:00
|
|
|
out, _, err = dockerCmdWithError("plugin", "enable", pName)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "disable", pName)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "remove", pName)
|
2016-06-17 10:44:57 -04:00
|
|
|
c.Assert(err, checker.IsNil)
|
2016-07-15 13:37:17 -04:00
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
2016-06-17 10:44:57 -04:00
|
|
|
}
|
2016-07-06 15:16:14 -04:00
|
|
|
|
2016-11-01 18:03:14 -04:00
|
|
|
func (s *DockerSuite) TestPluginInstallDisableVolumeLs(c *check.C) {
|
2016-11-09 20:49:09 -05:00
|
|
|
testRequires(c, DaemonIsLinux, Network)
|
2016-11-01 18:03:14 -04:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
|
|
|
|
|
|
|
dockerCmd(c, "volume", "ls")
|
|
|
|
}
|
|
|
|
|
2016-10-31 20:07:05 -04:00
|
|
|
func (s *DockerSuite) TestPluginSet(c *check.C) {
|
2016-11-09 20:49:09 -05:00
|
|
|
testRequires(c, DaemonIsLinux, Network)
|
2016-10-31 20:07:05 -04:00
|
|
|
out, _ := dockerCmd(c, "plugin", "install", "--grant-all-permissions", "--disable", pName)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
|
|
|
|
2016-11-07 21:51:47 -05:00
|
|
|
env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", pName)
|
2016-10-31 20:07:05 -04:00
|
|
|
c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=0]")
|
|
|
|
|
|
|
|
dockerCmd(c, "plugin", "set", pName, "DEBUG=1")
|
|
|
|
|
2016-11-07 21:51:47 -05:00
|
|
|
env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", pName)
|
2016-10-31 20:07:05 -04:00
|
|
|
c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
|
|
|
|
}
|
|
|
|
|
2016-11-07 20:43:11 -05:00
|
|
|
func (s *DockerSuite) TestPluginInstallArgs(c *check.C) {
|
2016-11-09 20:49:09 -05:00
|
|
|
testRequires(c, DaemonIsLinux, Network)
|
2016-11-07 20:43:11 -05:00
|
|
|
out, _ := dockerCmd(c, "plugin", "install", "--grant-all-permissions", "--disable", pName, "DEBUG=1")
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
|
|
|
|
2016-11-07 21:51:47 -05:00
|
|
|
env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", pName)
|
2016-11-07 20:43:11 -05:00
|
|
|
c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
|
|
|
|
}
|
|
|
|
|
2016-07-06 15:16:14 -04:00
|
|
|
func (s *DockerSuite) TestPluginInstallImage(c *check.C) {
|
2016-11-23 08:03:53 -05:00
|
|
|
testRequires(c, DaemonIsLinux, Network)
|
2016-07-06 15:16:14 -04:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "install", "redis")
|
|
|
|
c.Assert(err, checker.NotNil)
|
|
|
|
c.Assert(out, checker.Contains, "content is not a plugin")
|
|
|
|
}
|
2016-07-25 17:06:27 -04:00
|
|
|
|
|
|
|
func (s *DockerSuite) TestPluginEnableDisableNegative(c *check.C) {
|
2016-11-09 20:49:09 -05:00
|
|
|
testRequires(c, DaemonIsLinux, Network)
|
2016-07-25 17:06:27 -04:00
|
|
|
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pName)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, pName)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "enable", pName)
|
|
|
|
c.Assert(err, checker.NotNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, "already enabled")
|
|
|
|
|
|
|
|
_, _, err = dockerCmdWithError("plugin", "disable", pName)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
out, _, err = dockerCmdWithError("plugin", "disable", pName)
|
|
|
|
c.Assert(err, checker.NotNil)
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Contains, "already disabled")
|
|
|
|
|
|
|
|
_, _, err = dockerCmdWithError("plugin", "remove", pName)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
}
|