docker_cli_plugins_test.go 17 KB

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