docker_cli_plugins_test.go 18 KB

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