github.com/endophage/docker@v1.4.2-0.20161027011718-242853499895/integration-cli/docker_cli_plugins_test.go (about) 1 package main 2 3 import ( 4 "github.com/docker/docker/pkg/integration/checker" 5 "github.com/go-check/check" 6 7 "os" 8 "path/filepath" 9 "strings" 10 ) 11 12 var ( 13 pName = "tiborvass/no-remove" 14 pTag = "latest" 15 pNameWithTag = pName + ":" + pTag 16 ) 17 18 func (s *DockerSuite) TestPluginBasicOps(c *check.C) { 19 testRequires(c, DaemonIsLinux, ExperimentalDaemon, Network) 20 _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag) 21 c.Assert(err, checker.IsNil) 22 23 out, _, err := dockerCmdWithError("plugin", "ls") 24 c.Assert(err, checker.IsNil) 25 c.Assert(out, checker.Contains, pName) 26 c.Assert(out, checker.Contains, pTag) 27 c.Assert(out, checker.Contains, "true") 28 29 id, _, err := dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pNameWithTag) 30 c.Assert(err, checker.IsNil) 31 32 out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag) 33 c.Assert(out, checker.Contains, "is enabled") 34 35 _, _, err = dockerCmdWithError("plugin", "disable", pNameWithTag) 36 c.Assert(err, checker.IsNil) 37 38 out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag) 39 c.Assert(err, checker.IsNil) 40 c.Assert(out, checker.Contains, pNameWithTag) 41 42 _, err = os.Stat(filepath.Join(dockerBasePath, "plugins", id)) 43 if !os.IsNotExist(err) { 44 c.Fatal(err) 45 } 46 } 47 48 func (s *DockerSuite) TestPluginForceRemove(c *check.C) { 49 testRequires(c, DaemonIsLinux, ExperimentalDaemon, Network) 50 out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag) 51 c.Assert(err, checker.IsNil) 52 53 out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag) 54 c.Assert(out, checker.Contains, "is enabled") 55 56 out, _, err = dockerCmdWithError("plugin", "remove", "--force", pNameWithTag) 57 c.Assert(err, checker.IsNil) 58 c.Assert(out, checker.Contains, pNameWithTag) 59 } 60 61 func (s *DockerSuite) TestPluginActive(c *check.C) { 62 testRequires(c, DaemonIsLinux, ExperimentalDaemon, Network) 63 out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag) 64 c.Assert(err, checker.IsNil) 65 66 out, _, err = dockerCmdWithError("volume", "create", "-d", pNameWithTag) 67 c.Assert(err, checker.IsNil) 68 69 vID := strings.TrimSpace(out) 70 71 out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag) 72 c.Assert(out, checker.Contains, "is in use") 73 74 _, _, err = dockerCmdWithError("volume", "rm", vID) 75 c.Assert(err, checker.IsNil) 76 77 out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag) 78 c.Assert(out, checker.Contains, "is enabled") 79 80 _, _, err = dockerCmdWithError("plugin", "disable", pNameWithTag) 81 c.Assert(err, checker.IsNil) 82 83 out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag) 84 c.Assert(err, checker.IsNil) 85 c.Assert(out, checker.Contains, pNameWithTag) 86 } 87 88 func (s *DockerSuite) TestPluginInstallDisable(c *check.C) { 89 testRequires(c, DaemonIsLinux, ExperimentalDaemon, Network) 90 out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName) 91 c.Assert(err, checker.IsNil) 92 c.Assert(strings.TrimSpace(out), checker.Contains, pName) 93 94 out, _, err = dockerCmdWithError("plugin", "ls") 95 c.Assert(err, checker.IsNil) 96 c.Assert(out, checker.Contains, "false") 97 98 out, _, err = dockerCmdWithError("plugin", "enable", pName) 99 c.Assert(err, checker.IsNil) 100 c.Assert(strings.TrimSpace(out), checker.Contains, pName) 101 102 out, _, err = dockerCmdWithError("plugin", "disable", pName) 103 c.Assert(err, checker.IsNil) 104 c.Assert(strings.TrimSpace(out), checker.Contains, pName) 105 106 out, _, err = dockerCmdWithError("plugin", "remove", pName) 107 c.Assert(err, checker.IsNil) 108 c.Assert(strings.TrimSpace(out), checker.Contains, pName) 109 } 110 111 func (s *DockerSuite) TestPluginInstallImage(c *check.C) { 112 testRequires(c, DaemonIsLinux, ExperimentalDaemon) 113 out, _, err := dockerCmdWithError("plugin", "install", "redis") 114 c.Assert(err, checker.NotNil) 115 c.Assert(out, checker.Contains, "content is not a plugin") 116 } 117 118 func (s *DockerSuite) TestPluginEnableDisableNegative(c *check.C) { 119 testRequires(c, DaemonIsLinux, ExperimentalDaemon, Network) 120 out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pName) 121 c.Assert(err, checker.IsNil) 122 c.Assert(strings.TrimSpace(out), checker.Contains, pName) 123 124 out, _, err = dockerCmdWithError("plugin", "enable", pName) 125 c.Assert(err, checker.NotNil) 126 c.Assert(strings.TrimSpace(out), checker.Contains, "already enabled") 127 128 _, _, err = dockerCmdWithError("plugin", "disable", pName) 129 c.Assert(err, checker.IsNil) 130 131 out, _, err = dockerCmdWithError("plugin", "disable", pName) 132 c.Assert(err, checker.NotNil) 133 c.Assert(strings.TrimSpace(out), checker.Contains, "already disabled") 134 135 _, _, err = dockerCmdWithError("plugin", "remove", pName) 136 c.Assert(err, checker.IsNil) 137 }