docker_cli_plugins_test.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. package main
  2. import (
  3. "fmt"
  4. "io/ioutil"
  5. "net/http"
  6. "os"
  7. "path/filepath"
  8. "strings"
  9. "github.com/docker/docker/integration-cli/checker"
  10. "github.com/docker/docker/integration-cli/cli"
  11. "github.com/docker/docker/integration-cli/daemon"
  12. icmd "github.com/docker/docker/pkg/testutil/cmd"
  13. "github.com/go-check/check"
  14. )
  15. var (
  16. pluginProcessName = "sample-volume-plugin"
  17. pName = "tiborvass/sample-volume-plugin"
  18. npName = "tiborvass/test-docker-netplugin"
  19. pTag = "latest"
  20. pNameWithTag = pName + ":" + pTag
  21. npNameWithTag = npName + ":" + pTag
  22. )
  23. func (s *DockerSuite) TestPluginBasicOps(c *check.C) {
  24. testRequires(c, DaemonIsLinux, IsAmd64, Network)
  25. _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
  26. c.Assert(err, checker.IsNil)
  27. out, _, err := dockerCmdWithError("plugin", "ls")
  28. c.Assert(err, checker.IsNil)
  29. c.Assert(out, checker.Contains, pName)
  30. c.Assert(out, checker.Contains, pTag)
  31. c.Assert(out, checker.Contains, "true")
  32. id, _, err := dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pNameWithTag)
  33. id = strings.TrimSpace(id)
  34. c.Assert(err, checker.IsNil)
  35. out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
  36. c.Assert(err, checker.NotNil)
  37. c.Assert(out, checker.Contains, "is enabled")
  38. _, _, err = dockerCmdWithError("plugin", "disable", pNameWithTag)
  39. c.Assert(err, checker.IsNil)
  40. out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
  41. c.Assert(err, checker.IsNil)
  42. c.Assert(out, checker.Contains, pNameWithTag)
  43. _, err = os.Stat(filepath.Join(testEnv.DockerBasePath(), "plugins", id))
  44. if !os.IsNotExist(err) {
  45. c.Fatal(err)
  46. }
  47. }
  48. func (s *DockerSuite) TestPluginForceRemove(c *check.C) {
  49. testRequires(c, DaemonIsLinux, IsAmd64, Network)
  50. out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
  51. c.Assert(err, checker.IsNil)
  52. out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
  53. c.Assert(out, checker.Contains, "is enabled")
  54. out, _, err = dockerCmdWithError("plugin", "remove", "--force", pNameWithTag)
  55. c.Assert(err, checker.IsNil)
  56. c.Assert(out, checker.Contains, pNameWithTag)
  57. }
  58. func (s *DockerSuite) TestPluginActive(c *check.C) {
  59. testRequires(c, DaemonIsLinux, IsAmd64, Network)
  60. _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
  61. c.Assert(err, checker.IsNil)
  62. _, _, err = dockerCmdWithError("volume", "create", "-d", pNameWithTag, "--name", "testvol1")
  63. c.Assert(err, checker.IsNil)
  64. out, _, err := dockerCmdWithError("plugin", "disable", pNameWithTag)
  65. c.Assert(out, checker.Contains, "in use")
  66. _, _, err = dockerCmdWithError("volume", "rm", "testvol1")
  67. c.Assert(err, checker.IsNil)
  68. _, _, err = dockerCmdWithError("plugin", "disable", pNameWithTag)
  69. c.Assert(err, checker.IsNil)
  70. out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
  71. c.Assert(err, checker.IsNil)
  72. c.Assert(out, checker.Contains, pNameWithTag)
  73. }
  74. func (s *DockerSuite) TestPluginActiveNetwork(c *check.C) {
  75. testRequires(c, DaemonIsLinux, IsAmd64, Network)
  76. out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", npNameWithTag)
  77. c.Assert(err, checker.IsNil)
  78. out, _, err = dockerCmdWithError("network", "create", "-d", npNameWithTag, "test")
  79. c.Assert(err, checker.IsNil)
  80. nID := strings.TrimSpace(out)
  81. out, _, err = dockerCmdWithError("plugin", "remove", npNameWithTag)
  82. c.Assert(out, checker.Contains, "is in use")
  83. _, _, err = dockerCmdWithError("network", "rm", nID)
  84. c.Assert(err, checker.IsNil)
  85. out, _, err = dockerCmdWithError("plugin", "remove", npNameWithTag)
  86. c.Assert(out, checker.Contains, "is enabled")
  87. _, _, err = dockerCmdWithError("plugin", "disable", npNameWithTag)
  88. c.Assert(err, checker.IsNil)
  89. out, _, err = dockerCmdWithError("plugin", "remove", npNameWithTag)
  90. c.Assert(err, checker.IsNil)
  91. c.Assert(out, checker.Contains, npNameWithTag)
  92. }
  93. func (s *DockerSuite) TestPluginInstallDisable(c *check.C) {
  94. testRequires(c, DaemonIsLinux, IsAmd64, Network)
  95. out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName)
  96. c.Assert(err, checker.IsNil)
  97. c.Assert(strings.TrimSpace(out), checker.Contains, pName)
  98. out, _, err = dockerCmdWithError("plugin", "ls")
  99. c.Assert(err, checker.IsNil)
  100. c.Assert(out, checker.Contains, "false")
  101. out, _, err = dockerCmdWithError("plugin", "enable", pName)
  102. c.Assert(err, checker.IsNil)
  103. c.Assert(strings.TrimSpace(out), checker.Contains, pName)
  104. out, _, err = dockerCmdWithError("plugin", "disable", pName)
  105. c.Assert(err, checker.IsNil)
  106. c.Assert(strings.TrimSpace(out), checker.Contains, pName)
  107. out, _, err = dockerCmdWithError("plugin", "remove", pName)
  108. c.Assert(err, checker.IsNil)
  109. c.Assert(strings.TrimSpace(out), checker.Contains, pName)
  110. }
  111. func (s *DockerSuite) TestPluginInstallDisableVolumeLs(c *check.C) {
  112. testRequires(c, DaemonIsLinux, IsAmd64, Network)
  113. out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName)
  114. c.Assert(err, checker.IsNil)
  115. c.Assert(strings.TrimSpace(out), checker.Contains, pName)
  116. dockerCmd(c, "volume", "ls")
  117. }
  118. func (s *DockerSuite) TestPluginSet(c *check.C) {
  119. testRequires(c, DaemonIsLinux, IsAmd64, Network)
  120. out, _ := dockerCmd(c, "plugin", "install", "--grant-all-permissions", "--disable", pName)
  121. c.Assert(strings.TrimSpace(out), checker.Contains, pName)
  122. env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", pName)
  123. c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=0]")
  124. dockerCmd(c, "plugin", "set", pName, "DEBUG=1")
  125. env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", pName)
  126. c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
  127. }
  128. func (s *DockerSuite) TestPluginInstallArgs(c *check.C) {
  129. testRequires(c, DaemonIsLinux, IsAmd64, Network)
  130. out, _ := dockerCmd(c, "plugin", "install", "--grant-all-permissions", "--disable", pName, "DEBUG=1")
  131. c.Assert(strings.TrimSpace(out), checker.Contains, pName)
  132. env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", pName)
  133. c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
  134. }
  135. func (s *DockerRegistrySuite) TestPluginInstallImage(c *check.C) {
  136. testRequires(c, DaemonIsLinux, IsAmd64)
  137. repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
  138. // tag the image to upload it to the private registry
  139. dockerCmd(c, "tag", "busybox", repoName)
  140. // push the image to the registry
  141. dockerCmd(c, "push", repoName)
  142. out, _, err := dockerCmdWithError("plugin", "install", repoName)
  143. c.Assert(err, checker.NotNil)
  144. c.Assert(out, checker.Contains, `Encountered remote "application/vnd.docker.container.image.v1+json"(image) when fetching`)
  145. }
  146. func (s *DockerSuite) TestPluginEnableDisableNegative(c *check.C) {
  147. testRequires(c, DaemonIsLinux, IsAmd64, Network)
  148. out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pName)
  149. c.Assert(err, checker.IsNil)
  150. c.Assert(strings.TrimSpace(out), checker.Contains, pName)
  151. out, _, err = dockerCmdWithError("plugin", "enable", pName)
  152. c.Assert(err, checker.NotNil)
  153. c.Assert(strings.TrimSpace(out), checker.Contains, "already enabled")
  154. _, _, err = dockerCmdWithError("plugin", "disable", pName)
  155. c.Assert(err, checker.IsNil)
  156. out, _, err = dockerCmdWithError("plugin", "disable", pName)
  157. c.Assert(err, checker.NotNil)
  158. c.Assert(strings.TrimSpace(out), checker.Contains, "already disabled")
  159. _, _, err = dockerCmdWithError("plugin", "remove", pName)
  160. c.Assert(err, checker.IsNil)
  161. }
  162. func (s *DockerSuite) TestPluginCreate(c *check.C) {
  163. testRequires(c, DaemonIsLinux, IsAmd64, Network)
  164. name := "foo/bar-driver"
  165. temp, err := ioutil.TempDir("", "foo")
  166. c.Assert(err, checker.IsNil)
  167. defer os.RemoveAll(temp)
  168. data := `{"description": "foo plugin"}`
  169. err = ioutil.WriteFile(filepath.Join(temp, "config.json"), []byte(data), 0644)
  170. c.Assert(err, checker.IsNil)
  171. err = os.MkdirAll(filepath.Join(temp, "rootfs"), 0700)
  172. c.Assert(err, checker.IsNil)
  173. out, _, err := dockerCmdWithError("plugin", "create", name, temp)
  174. c.Assert(err, checker.IsNil)
  175. c.Assert(out, checker.Contains, name)
  176. out, _, err = dockerCmdWithError("plugin", "ls")
  177. c.Assert(err, checker.IsNil)
  178. c.Assert(out, checker.Contains, name)
  179. out, _, err = dockerCmdWithError("plugin", "create", name, temp)
  180. c.Assert(err, checker.NotNil)
  181. c.Assert(out, checker.Contains, "already exist")
  182. out, _, err = dockerCmdWithError("plugin", "ls")
  183. c.Assert(err, checker.IsNil)
  184. c.Assert(out, checker.Contains, name)
  185. // The output will consists of one HEADER line and one line of foo/bar-driver
  186. c.Assert(len(strings.Split(strings.TrimSpace(out), "\n")), checker.Equals, 2)
  187. }
  188. func (s *DockerSuite) TestPluginInspect(c *check.C) {
  189. testRequires(c, DaemonIsLinux, IsAmd64, Network)
  190. _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
  191. c.Assert(err, checker.IsNil)
  192. out, _, err := dockerCmdWithError("plugin", "ls")
  193. c.Assert(err, checker.IsNil)
  194. c.Assert(out, checker.Contains, pName)
  195. c.Assert(out, checker.Contains, pTag)
  196. c.Assert(out, checker.Contains, "true")
  197. // Find the ID first
  198. out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pNameWithTag)
  199. c.Assert(err, checker.IsNil)
  200. id := strings.TrimSpace(out)
  201. c.Assert(id, checker.Not(checker.Equals), "")
  202. // Long form
  203. out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", id)
  204. c.Assert(err, checker.IsNil)
  205. c.Assert(strings.TrimSpace(out), checker.Equals, id)
  206. // Short form
  207. out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", id[:5])
  208. c.Assert(err, checker.IsNil)
  209. c.Assert(strings.TrimSpace(out), checker.Equals, id)
  210. // Name with tag form
  211. out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pNameWithTag)
  212. c.Assert(err, checker.IsNil)
  213. c.Assert(strings.TrimSpace(out), checker.Equals, id)
  214. // Name without tag form
  215. out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pName)
  216. c.Assert(err, checker.IsNil)
  217. c.Assert(strings.TrimSpace(out), checker.Equals, id)
  218. _, _, err = dockerCmdWithError("plugin", "disable", pNameWithTag)
  219. c.Assert(err, checker.IsNil)
  220. out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
  221. c.Assert(err, checker.IsNil)
  222. c.Assert(out, checker.Contains, pNameWithTag)
  223. // After remove nothing should be found
  224. _, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", id[:5])
  225. c.Assert(err, checker.NotNil)
  226. }
  227. // Test case for https://github.com/docker/docker/pull/29186#discussion_r91277345
  228. func (s *DockerSuite) TestPluginInspectOnWindows(c *check.C) {
  229. // This test should work on Windows only
  230. testRequires(c, DaemonIsWindows)
  231. out, _, err := dockerCmdWithError("plugin", "inspect", "foobar")
  232. c.Assert(err, checker.NotNil)
  233. c.Assert(out, checker.Contains, "plugins are not supported on this platform")
  234. c.Assert(err.Error(), checker.Contains, "plugins are not supported on this platform")
  235. }
  236. func (s *DockerTrustSuite) TestPluginTrustedInstall(c *check.C) {
  237. testRequires(c, DaemonIsLinux, IsAmd64, Network)
  238. trustedName := s.setupTrustedplugin(c, pNameWithTag, "trusted-plugin-install")
  239. cli.Docker(cli.Args("plugin", "install", "--grant-all-permissions", trustedName), trustedCmd).Assert(c, icmd.Expected{
  240. Out: trustedName,
  241. })
  242. out := cli.DockerCmd(c, "plugin", "ls").Combined()
  243. c.Assert(out, checker.Contains, "true")
  244. out = cli.DockerCmd(c, "plugin", "disable", trustedName).Combined()
  245. c.Assert(strings.TrimSpace(out), checker.Contains, trustedName)
  246. out = cli.DockerCmd(c, "plugin", "enable", trustedName).Combined()
  247. c.Assert(strings.TrimSpace(out), checker.Contains, trustedName)
  248. out = cli.DockerCmd(c, "plugin", "rm", "-f", trustedName).Combined()
  249. c.Assert(strings.TrimSpace(out), checker.Contains, trustedName)
  250. // Try untrusted pull to ensure we pushed the tag to the registry
  251. cli.Docker(cli.Args("plugin", "install", "--disable-content-trust=true", "--grant-all-permissions", trustedName), trustedCmd).Assert(c, SuccessDownloaded)
  252. out = cli.DockerCmd(c, "plugin", "ls").Combined()
  253. c.Assert(out, checker.Contains, "true")
  254. }
  255. func (s *DockerTrustSuite) TestPluginUntrustedInstall(c *check.C) {
  256. testRequires(c, DaemonIsLinux, IsAmd64, Network)
  257. pluginName := fmt.Sprintf("%v/dockercliuntrusted/plugintest:latest", privateRegistryURL)
  258. // install locally and push to private registry
  259. cli.DockerCmd(c, "plugin", "install", "--grant-all-permissions", "--alias", pluginName, pNameWithTag)
  260. cli.DockerCmd(c, "plugin", "push", pluginName)
  261. cli.DockerCmd(c, "plugin", "rm", "-f", pluginName)
  262. // Try trusted install on untrusted plugin
  263. cli.Docker(cli.Args("plugin", "install", "--grant-all-permissions", pluginName), trustedCmd).Assert(c, icmd.Expected{
  264. ExitCode: 1,
  265. Err: "Error: remote trust data does not exist",
  266. })
  267. }
  268. func (s *DockerSuite) TestPluginIDPrefix(c *check.C) {
  269. testRequires(c, DaemonIsLinux, IsAmd64, Network)
  270. _, _, err := dockerCmdWithError("plugin", "install", "--disable", "--grant-all-permissions", pNameWithTag)
  271. c.Assert(err, checker.IsNil)
  272. // Find ID first
  273. id, _, err := dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pNameWithTag)
  274. id = strings.TrimSpace(id)
  275. c.Assert(err, checker.IsNil)
  276. // List current state
  277. out, _, err := dockerCmdWithError("plugin", "ls")
  278. c.Assert(err, checker.IsNil)
  279. c.Assert(out, checker.Contains, pName)
  280. c.Assert(out, checker.Contains, pTag)
  281. c.Assert(out, checker.Contains, "false")
  282. env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", id[:5])
  283. c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=0]")
  284. dockerCmd(c, "plugin", "set", id[:5], "DEBUG=1")
  285. env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", id[:5])
  286. c.Assert(strings.TrimSpace(env), checker.Equals, "[DEBUG=1]")
  287. // Enable
  288. _, _, err = dockerCmdWithError("plugin", "enable", id[:5])
  289. c.Assert(err, checker.IsNil)
  290. out, _, err = dockerCmdWithError("plugin", "ls")
  291. c.Assert(err, checker.IsNil)
  292. c.Assert(out, checker.Contains, pName)
  293. c.Assert(out, checker.Contains, pTag)
  294. c.Assert(out, checker.Contains, "true")
  295. // Disable
  296. _, _, err = dockerCmdWithError("plugin", "disable", id[:5])
  297. c.Assert(err, checker.IsNil)
  298. out, _, err = dockerCmdWithError("plugin", "ls")
  299. c.Assert(err, checker.IsNil)
  300. c.Assert(out, checker.Contains, pName)
  301. c.Assert(out, checker.Contains, pTag)
  302. c.Assert(out, checker.Contains, "false")
  303. // Remove
  304. out, _, err = dockerCmdWithError("plugin", "remove", id[:5])
  305. c.Assert(err, checker.IsNil)
  306. // List returns none
  307. out, _, err = dockerCmdWithError("plugin", "ls")
  308. c.Assert(err, checker.IsNil)
  309. c.Assert(out, checker.Not(checker.Contains), pName)
  310. c.Assert(out, checker.Not(checker.Contains), pTag)
  311. }
  312. func (s *DockerSuite) TestPluginListDefaultFormat(c *check.C) {
  313. testRequires(c, DaemonIsLinux, Network, IsAmd64)
  314. config, err := ioutil.TempDir("", "config-file-")
  315. c.Assert(err, check.IsNil)
  316. defer os.RemoveAll(config)
  317. err = ioutil.WriteFile(filepath.Join(config, "config.json"), []byte(`{"pluginsFormat": "raw"}`), 0644)
  318. c.Assert(err, check.IsNil)
  319. out, _ := dockerCmd(c, "plugin", "install", "--grant-all-permissions", pName)
  320. c.Assert(strings.TrimSpace(out), checker.Contains, pName)
  321. out, _ = dockerCmd(c, "plugin", "inspect", "--format", "{{.ID}}", pNameWithTag)
  322. id := strings.TrimSpace(out)
  323. // We expect the format to be in `raw + --no-trunc`
  324. expectedOutput := fmt.Sprintf(`plugin_id: %s
  325. name: %s
  326. description: A sample volume plugin for Docker
  327. enabled: true`, id, pNameWithTag)
  328. out, _ = dockerCmd(c, "--config", config, "plugin", "ls", "--no-trunc")
  329. c.Assert(strings.TrimSpace(out), checker.Contains, expectedOutput)
  330. }
  331. func (s *DockerSuite) TestPluginUpgrade(c *check.C) {
  332. testRequires(c, DaemonIsLinux, Network, SameHostDaemon, IsAmd64)
  333. plugin := "cpuguy83/docker-volume-driver-plugin-local:latest"
  334. pluginV2 := "cpuguy83/docker-volume-driver-plugin-local:v2"
  335. dockerCmd(c, "plugin", "install", "--grant-all-permissions", plugin)
  336. dockerCmd(c, "volume", "create", "--driver", plugin, "bananas")
  337. dockerCmd(c, "run", "--rm", "-v", "bananas:/apple", "busybox", "sh", "-c", "touch /apple/core")
  338. out, _, err := dockerCmdWithError("plugin", "upgrade", "--grant-all-permissions", plugin, pluginV2)
  339. c.Assert(err, checker.NotNil, check.Commentf(out))
  340. c.Assert(out, checker.Contains, "disabled before upgrading")
  341. out, _ = dockerCmd(c, "plugin", "inspect", "--format={{.ID}}", plugin)
  342. id := strings.TrimSpace(out)
  343. // make sure "v2" does not exists
  344. _, err = os.Stat(filepath.Join(testEnv.DockerBasePath(), "plugins", id, "rootfs", "v2"))
  345. c.Assert(os.IsNotExist(err), checker.True, check.Commentf(out))
  346. dockerCmd(c, "plugin", "disable", "-f", plugin)
  347. dockerCmd(c, "plugin", "upgrade", "--grant-all-permissions", "--skip-remote-check", plugin, pluginV2)
  348. // make sure "v2" file exists
  349. _, err = os.Stat(filepath.Join(testEnv.DockerBasePath(), "plugins", id, "rootfs", "v2"))
  350. c.Assert(err, checker.IsNil)
  351. dockerCmd(c, "plugin", "enable", plugin)
  352. dockerCmd(c, "volume", "inspect", "bananas")
  353. dockerCmd(c, "run", "--rm", "-v", "bananas:/apple", "busybox", "sh", "-c", "ls -lh /apple/core")
  354. }
  355. func (s *DockerSuite) TestPluginMetricsCollector(c *check.C) {
  356. testRequires(c, DaemonIsLinux, Network, SameHostDaemon, IsAmd64)
  357. d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{})
  358. d.Start(c)
  359. defer d.Stop(c)
  360. name := "cpuguy83/docker-metrics-plugin-test:latest"
  361. r := cli.Docker(cli.Args("plugin", "install", "--grant-all-permissions", name), cli.Daemon(d))
  362. c.Assert(r.Error, checker.IsNil, check.Commentf(r.Combined()))
  363. // plugin lisens on localhost:19393 and proxies the metrics
  364. resp, err := http.Get("http://localhost:19393/metrics")
  365. c.Assert(err, checker.IsNil)
  366. defer resp.Body.Close()
  367. b, err := ioutil.ReadAll(resp.Body)
  368. c.Assert(err, checker.IsNil)
  369. // check that a known metric is there... don't expect this metric to change over time.. probably safe
  370. c.Assert(string(b), checker.Contains, "container_actions")
  371. }