github.com/afbjorklund/moby@v20.10.5+incompatible/integration-cli/docker_cli_external_volume_driver_test.go (about) 1 package main 2 3 import ( 4 "encoding/json" 5 "fmt" 6 "io" 7 "io/ioutil" 8 "net/http" 9 "net/http/httptest" 10 "os" 11 "os/exec" 12 "path/filepath" 13 "strings" 14 "testing" 15 "time" 16 17 "github.com/docker/docker/api/types" 18 "github.com/docker/docker/integration-cli/daemon" 19 "github.com/docker/docker/pkg/stringid" 20 testdaemon "github.com/docker/docker/testutil/daemon" 21 "github.com/docker/docker/volume" 22 "gotest.tools/v3/assert" 23 ) 24 25 const volumePluginName = "test-external-volume-driver" 26 27 type eventCounter struct { 28 activations int 29 creations int 30 removals int 31 mounts int 32 unmounts int 33 paths int 34 lists int 35 gets int 36 caps int 37 } 38 39 type DockerExternalVolumeSuite struct { 40 ds *DockerSuite 41 d *daemon.Daemon 42 *volumePlugin 43 } 44 45 func (s *DockerExternalVolumeSuite) SetUpTest(c *testing.T) { 46 testRequires(c, testEnv.IsLocalDaemon) 47 s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) 48 s.ec = &eventCounter{} 49 } 50 51 func (s *DockerExternalVolumeSuite) TearDownTest(c *testing.T) { 52 if s.d != nil { 53 s.d.Stop(c) 54 s.ds.TearDownTest(c) 55 } 56 } 57 58 func (s *DockerExternalVolumeSuite) SetUpSuite(c *testing.T) { 59 s.volumePlugin = newVolumePlugin(c, volumePluginName) 60 } 61 62 type volumePlugin struct { 63 ec *eventCounter 64 *httptest.Server 65 vols map[string]vol 66 } 67 68 type vol struct { 69 Name string 70 Mountpoint string 71 Ninja bool // hack used to trigger a null volume return on `Get` 72 Status map[string]interface{} 73 Options map[string]string 74 } 75 76 func (p *volumePlugin) Close() { 77 p.Server.Close() 78 } 79 80 func newVolumePlugin(c *testing.T, name string) *volumePlugin { 81 mux := http.NewServeMux() 82 s := &volumePlugin{Server: httptest.NewServer(mux), ec: &eventCounter{}, vols: make(map[string]vol)} 83 84 type pluginRequest struct { 85 Name string 86 Opts map[string]string 87 ID string 88 } 89 90 type pluginResp struct { 91 Mountpoint string `json:",omitempty"` 92 Err string `json:",omitempty"` 93 } 94 95 read := func(b io.ReadCloser) (pluginRequest, error) { 96 defer b.Close() 97 var pr pluginRequest 98 err := json.NewDecoder(b).Decode(&pr) 99 return pr, err 100 } 101 102 send := func(w http.ResponseWriter, data interface{}) { 103 switch t := data.(type) { 104 case error: 105 http.Error(w, t.Error(), 500) 106 case string: 107 w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json") 108 fmt.Fprintln(w, t) 109 default: 110 w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json") 111 json.NewEncoder(w).Encode(&data) 112 } 113 } 114 115 mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) { 116 s.ec.activations++ 117 send(w, `{"Implements": ["VolumeDriver"]}`) 118 }) 119 120 mux.HandleFunc("/VolumeDriver.Create", func(w http.ResponseWriter, r *http.Request) { 121 s.ec.creations++ 122 pr, err := read(r.Body) 123 if err != nil { 124 send(w, err) 125 return 126 } 127 _, isNinja := pr.Opts["ninja"] 128 status := map[string]interface{}{"Hello": "world"} 129 s.vols[pr.Name] = vol{Name: pr.Name, Ninja: isNinja, Status: status, Options: pr.Opts} 130 send(w, nil) 131 }) 132 133 mux.HandleFunc("/VolumeDriver.List", func(w http.ResponseWriter, r *http.Request) { 134 s.ec.lists++ 135 vols := make([]vol, 0, len(s.vols)) 136 for _, v := range s.vols { 137 if v.Ninja { 138 continue 139 } 140 vols = append(vols, v) 141 } 142 send(w, map[string][]vol{"Volumes": vols}) 143 }) 144 145 mux.HandleFunc("/VolumeDriver.Get", func(w http.ResponseWriter, r *http.Request) { 146 s.ec.gets++ 147 pr, err := read(r.Body) 148 if err != nil { 149 send(w, err) 150 return 151 } 152 153 v, exists := s.vols[pr.Name] 154 if !exists { 155 send(w, `{"Err": "no such volume"}`) 156 } 157 158 if v.Ninja { 159 send(w, map[string]vol{}) 160 return 161 } 162 163 v.Mountpoint = hostVolumePath(pr.Name) 164 send(w, map[string]vol{"Volume": v}) 165 }) 166 167 mux.HandleFunc("/VolumeDriver.Remove", func(w http.ResponseWriter, r *http.Request) { 168 s.ec.removals++ 169 pr, err := read(r.Body) 170 if err != nil { 171 send(w, err) 172 return 173 } 174 175 v, ok := s.vols[pr.Name] 176 if !ok { 177 send(w, nil) 178 return 179 } 180 181 if err := os.RemoveAll(hostVolumePath(v.Name)); err != nil { 182 send(w, &pluginResp{Err: err.Error()}) 183 return 184 } 185 delete(s.vols, v.Name) 186 send(w, nil) 187 }) 188 189 mux.HandleFunc("/VolumeDriver.Path", func(w http.ResponseWriter, r *http.Request) { 190 s.ec.paths++ 191 192 pr, err := read(r.Body) 193 if err != nil { 194 send(w, err) 195 return 196 } 197 p := hostVolumePath(pr.Name) 198 send(w, &pluginResp{Mountpoint: p}) 199 }) 200 201 mux.HandleFunc("/VolumeDriver.Mount", func(w http.ResponseWriter, r *http.Request) { 202 s.ec.mounts++ 203 204 pr, err := read(r.Body) 205 if err != nil { 206 send(w, err) 207 return 208 } 209 210 if v, exists := s.vols[pr.Name]; exists { 211 // Use this to simulate a mount failure 212 if _, exists := v.Options["invalidOption"]; exists { 213 send(w, fmt.Errorf("invalid argument")) 214 return 215 } 216 } 217 218 p := hostVolumePath(pr.Name) 219 if err := os.MkdirAll(p, 0755); err != nil { 220 send(w, &pluginResp{Err: err.Error()}) 221 return 222 } 223 224 if err := ioutil.WriteFile(filepath.Join(p, "test"), []byte(s.Server.URL), 0644); err != nil { 225 send(w, err) 226 return 227 } 228 229 if err := ioutil.WriteFile(filepath.Join(p, "mountID"), []byte(pr.ID), 0644); err != nil { 230 send(w, err) 231 return 232 } 233 234 send(w, &pluginResp{Mountpoint: p}) 235 }) 236 237 mux.HandleFunc("/VolumeDriver.Unmount", func(w http.ResponseWriter, r *http.Request) { 238 s.ec.unmounts++ 239 240 _, err := read(r.Body) 241 if err != nil { 242 send(w, err) 243 return 244 } 245 246 send(w, nil) 247 }) 248 249 mux.HandleFunc("/VolumeDriver.Capabilities", func(w http.ResponseWriter, r *http.Request) { 250 s.ec.caps++ 251 252 _, err := read(r.Body) 253 if err != nil { 254 send(w, err) 255 return 256 } 257 258 send(w, `{"Capabilities": { "Scope": "global" }}`) 259 }) 260 261 err := os.MkdirAll("/etc/docker/plugins", 0755) 262 assert.NilError(c, err) 263 264 err = ioutil.WriteFile("/etc/docker/plugins/"+name+".spec", []byte(s.Server.URL), 0644) 265 assert.NilError(c, err) 266 return s 267 } 268 269 func (s *DockerExternalVolumeSuite) TearDownSuite(c *testing.T) { 270 s.volumePlugin.Close() 271 272 err := os.RemoveAll("/etc/docker/plugins") 273 assert.NilError(c, err) 274 } 275 276 func (s *DockerExternalVolumeSuite) TestVolumeCLICreateOptionConflict(c *testing.T) { 277 dockerCmd(c, "volume", "create", "test") 278 279 out, _, err := dockerCmdWithError("volume", "create", "test", "--driver", volumePluginName) 280 assert.Assert(c, err != nil, "volume create exception name already in use with another driver") 281 assert.Assert(c, strings.Contains(out, "must be unique")) 282 out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Driver }}", "test") 283 _, _, err = dockerCmdWithError("volume", "create", "test", "--driver", strings.TrimSpace(out)) 284 assert.NilError(c, err) 285 } 286 287 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverNamed(c *testing.T) { 288 s.d.StartWithBusybox(c) 289 290 out, err := s.d.Cmd("run", "--rm", "--name", "test-data", "-v", "external-volume-test:/tmp/external-volume-test", "--volume-driver", volumePluginName, "busybox:latest", "cat", "/tmp/external-volume-test/test") 291 assert.NilError(c, err, out) 292 assert.Assert(c, strings.Contains(out, s.Server.URL)) 293 _, err = s.d.Cmd("volume", "rm", "external-volume-test") 294 assert.NilError(c, err) 295 296 p := hostVolumePath("external-volume-test") 297 _, err = os.Lstat(p) 298 assert.ErrorContains(c, err, "") 299 assert.Assert(c, os.IsNotExist(err), "Expected volume path in host to not exist: %s, %v\n", p, err) 300 301 assert.Equal(c, s.ec.activations, 1) 302 assert.Equal(c, s.ec.creations, 1) 303 assert.Equal(c, s.ec.removals, 1) 304 assert.Equal(c, s.ec.mounts, 1) 305 assert.Equal(c, s.ec.unmounts, 1) 306 } 307 308 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnnamed(c *testing.T) { 309 s.d.StartWithBusybox(c) 310 311 out, err := s.d.Cmd("run", "--rm", "--name", "test-data", "-v", "/tmp/external-volume-test", "--volume-driver", volumePluginName, "busybox:latest", "cat", "/tmp/external-volume-test/test") 312 assert.NilError(c, err, out) 313 assert.Assert(c, strings.Contains(out, s.Server.URL)) 314 assert.Equal(c, s.ec.activations, 1) 315 assert.Equal(c, s.ec.creations, 1) 316 assert.Equal(c, s.ec.removals, 1) 317 assert.Equal(c, s.ec.mounts, 1) 318 assert.Equal(c, s.ec.unmounts, 1) 319 } 320 321 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverVolumesFrom(c *testing.T) { 322 s.d.StartWithBusybox(c) 323 324 out, err := s.d.Cmd("run", "--name", "vol-test1", "-v", "/foo", "--volume-driver", volumePluginName, "busybox:latest") 325 assert.NilError(c, err, out) 326 327 out, err = s.d.Cmd("run", "--rm", "--volumes-from", "vol-test1", "--name", "vol-test2", "busybox", "ls", "/tmp") 328 assert.NilError(c, err, out) 329 330 out, err = s.d.Cmd("rm", "-fv", "vol-test1") 331 assert.NilError(c, err, out) 332 333 assert.Equal(c, s.ec.activations, 1) 334 assert.Equal(c, s.ec.creations, 1) 335 assert.Equal(c, s.ec.removals, 1) 336 assert.Equal(c, s.ec.mounts, 2) 337 assert.Equal(c, s.ec.unmounts, 2) 338 } 339 340 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverDeleteContainer(c *testing.T) { 341 s.d.StartWithBusybox(c) 342 343 out, err := s.d.Cmd("run", "--name", "vol-test1", "-v", "/foo", "--volume-driver", volumePluginName, "busybox:latest") 344 assert.NilError(c, err, out) 345 346 out, err = s.d.Cmd("rm", "-fv", "vol-test1") 347 assert.NilError(c, err, out) 348 349 assert.Equal(c, s.ec.activations, 1) 350 assert.Equal(c, s.ec.creations, 1) 351 assert.Equal(c, s.ec.removals, 1) 352 assert.Equal(c, s.ec.mounts, 1) 353 assert.Equal(c, s.ec.unmounts, 1) 354 } 355 356 func hostVolumePath(name string) string { 357 return fmt.Sprintf("/var/lib/docker/volumes/%s", name) 358 } 359 360 // Make sure a request to use a down driver doesn't block other requests 361 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverLookupNotBlocked(c *testing.T) { 362 specPath := "/etc/docker/plugins/down-driver.spec" 363 err := ioutil.WriteFile(specPath, []byte("tcp://127.0.0.7:9999"), 0644) 364 assert.NilError(c, err) 365 defer os.RemoveAll(specPath) 366 367 chCmd1 := make(chan struct{}) 368 chCmd2 := make(chan error, 1) 369 cmd1 := exec.Command(dockerBinary, "volume", "create", "-d", "down-driver") 370 cmd2 := exec.Command(dockerBinary, "volume", "create") 371 372 assert.Assert(c, cmd1.Start() == nil) 373 defer cmd1.Process.Kill() 374 time.Sleep(100 * time.Millisecond) // ensure API has been called 375 assert.Assert(c, cmd2.Start() == nil) 376 377 go func() { 378 cmd1.Wait() 379 close(chCmd1) 380 }() 381 go func() { 382 chCmd2 <- cmd2.Wait() 383 }() 384 385 select { 386 case <-chCmd1: 387 cmd2.Process.Kill() 388 c.Fatalf("volume create with down driver finished unexpectedly") 389 case err := <-chCmd2: 390 assert.NilError(c, err) 391 case <-time.After(5 * time.Second): 392 cmd2.Process.Kill() 393 c.Fatal("volume creates are blocked by previous create requests when previous driver is down") 394 } 395 } 396 397 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverRetryNotImmediatelyExists(c *testing.T) { 398 s.d.StartWithBusybox(c) 399 driverName := "test-external-volume-driver-retry" 400 401 errchan := make(chan error, 1) 402 started := make(chan struct{}) 403 go func() { 404 close(started) 405 if out, err := s.d.Cmd("run", "--rm", "--name", "test-data-retry", "-v", "external-volume-test:/tmp/external-volume-test", "--volume-driver", driverName, "busybox:latest"); err != nil { 406 errchan <- fmt.Errorf("%v:\n%s", err, out) 407 } 408 close(errchan) 409 }() 410 411 <-started 412 // wait for a retry to occur, then create spec to allow plugin to register 413 time.Sleep(2 * time.Second) 414 p := newVolumePlugin(c, driverName) 415 defer p.Close() 416 417 select { 418 case err := <-errchan: 419 assert.NilError(c, err) 420 case <-time.After(8 * time.Second): 421 c.Fatal("volume creates fail when plugin not immediately available") 422 } 423 424 _, err := s.d.Cmd("volume", "rm", "external-volume-test") 425 assert.NilError(c, err) 426 427 assert.Equal(c, p.ec.activations, 1) 428 assert.Equal(c, p.ec.creations, 1) 429 assert.Equal(c, p.ec.removals, 1) 430 assert.Equal(c, p.ec.mounts, 1) 431 assert.Equal(c, p.ec.unmounts, 1) 432 } 433 434 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverBindExternalVolume(c *testing.T) { 435 dockerCmd(c, "volume", "create", "-d", volumePluginName, "foo") 436 dockerCmd(c, "run", "-d", "--name", "testing", "-v", "foo:/bar", "busybox", "top") 437 438 var mounts []struct { 439 Name string 440 Driver string 441 } 442 out := inspectFieldJSON(c, "testing", "Mounts") 443 assert.Assert(c, json.NewDecoder(strings.NewReader(out)).Decode(&mounts) == nil) 444 assert.Equal(c, len(mounts), 1, out) 445 assert.Equal(c, mounts[0].Name, "foo") 446 assert.Equal(c, mounts[0].Driver, volumePluginName) 447 } 448 449 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverList(c *testing.T) { 450 dockerCmd(c, "volume", "create", "-d", volumePluginName, "abc3") 451 out, _ := dockerCmd(c, "volume", "ls") 452 ls := strings.Split(strings.TrimSpace(out), "\n") 453 assert.Equal(c, len(ls), 2, fmt.Sprintf("\n%s", out)) 454 455 vol := strings.Fields(ls[len(ls)-1]) 456 assert.Equal(c, len(vol), 2, fmt.Sprintf("%v", vol)) 457 assert.Equal(c, vol[0], volumePluginName) 458 assert.Equal(c, vol[1], "abc3") 459 460 assert.Equal(c, s.ec.lists, 1) 461 } 462 463 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGet(c *testing.T) { 464 out, _, err := dockerCmdWithError("volume", "inspect", "dummy") 465 assert.ErrorContains(c, err, "", out) 466 assert.Assert(c, strings.Contains(out, "No such volume")) 467 assert.Equal(c, s.ec.gets, 1) 468 469 dockerCmd(c, "volume", "create", "test", "-d", volumePluginName) 470 out, _ = dockerCmd(c, "volume", "inspect", "test") 471 472 type vol struct { 473 Status map[string]string 474 } 475 var st []vol 476 477 assert.Assert(c, json.Unmarshal([]byte(out), &st) == nil) 478 assert.Equal(c, len(st), 1) 479 assert.Equal(c, len(st[0].Status), 1, fmt.Sprintf("%v", st[0])) 480 assert.Equal(c, st[0].Status["Hello"], "world", fmt.Sprintf("%v", st[0].Status)) 481 } 482 483 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverWithDaemonRestart(c *testing.T) { 484 dockerCmd(c, "volume", "create", "-d", volumePluginName, "abc1") 485 s.d.Restart(c) 486 487 dockerCmd(c, "run", "--name=test", "-v", "abc1:/foo", "busybox", "true") 488 var mounts []types.MountPoint 489 inspectFieldAndUnmarshall(c, "test", "Mounts", &mounts) 490 assert.Equal(c, len(mounts), 1) 491 assert.Equal(c, mounts[0].Driver, volumePluginName) 492 } 493 494 // Ensures that the daemon handles when the plugin responds to a `Get` request with a null volume and a null error. 495 // Prior the daemon would panic in this scenario. 496 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGetEmptyResponse(c *testing.T) { 497 s.d.Start(c) 498 499 out, err := s.d.Cmd("volume", "create", "-d", volumePluginName, "abc2", "--opt", "ninja=1") 500 assert.NilError(c, err, out) 501 502 out, err = s.d.Cmd("volume", "inspect", "abc2") 503 assert.ErrorContains(c, err, "", out) 504 assert.Assert(c, strings.Contains(out, "No such volume")) 505 } 506 507 // Ensure only cached paths are used in volume list to prevent N+1 calls to `VolumeDriver.Path` 508 // 509 // TODO(@cpuguy83): This test is testing internal implementation. In all the cases here, there may not even be a path 510 // available because the volume is not even mounted. Consider removing this test. 511 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverPathCalls(c *testing.T) { 512 s.d.Start(c) 513 assert.Equal(c, s.ec.paths, 0) 514 515 out, err := s.d.Cmd("volume", "create", "test", "--driver=test-external-volume-driver") 516 assert.NilError(c, err, out) 517 assert.Equal(c, s.ec.paths, 0) 518 519 out, err = s.d.Cmd("volume", "ls") 520 assert.NilError(c, err, out) 521 assert.Equal(c, s.ec.paths, 0) 522 } 523 524 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverMountID(c *testing.T) { 525 s.d.StartWithBusybox(c) 526 527 out, err := s.d.Cmd("run", "--rm", "-v", "external-volume-test:/tmp/external-volume-test", "--volume-driver", volumePluginName, "busybox:latest", "cat", "/tmp/external-volume-test/test") 528 assert.NilError(c, err, out) 529 assert.Assert(c, strings.TrimSpace(out) != "") 530 } 531 532 // Check that VolumeDriver.Capabilities gets called, and only called once 533 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverCapabilities(c *testing.T) { 534 s.d.Start(c) 535 assert.Equal(c, s.ec.caps, 0) 536 537 for i := 0; i < 3; i++ { 538 out, err := s.d.Cmd("volume", "create", "-d", volumePluginName, fmt.Sprintf("test%d", i)) 539 assert.NilError(c, err, out) 540 assert.Equal(c, s.ec.caps, 1) 541 out, err = s.d.Cmd("volume", "inspect", "--format={{.Scope}}", fmt.Sprintf("test%d", i)) 542 assert.NilError(c, err) 543 assert.Equal(c, strings.TrimSpace(out), volume.GlobalScope) 544 } 545 } 546 547 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverOutOfBandDelete(c *testing.T) { 548 driverName := stringid.GenerateRandomID() 549 p := newVolumePlugin(c, driverName) 550 defer p.Close() 551 552 s.d.StartWithBusybox(c) 553 554 out, err := s.d.Cmd("volume", "create", "-d", driverName, "--name", "test") 555 assert.NilError(c, err, out) 556 557 out, err = s.d.Cmd("volume", "create", "-d", "local", "--name", "test") 558 assert.ErrorContains(c, err, "", out) 559 assert.Assert(c, strings.Contains(out, "must be unique")) 560 // simulate out of band volume deletion on plugin level 561 delete(p.vols, "test") 562 563 // test re-create with same driver 564 out, err = s.d.Cmd("volume", "create", "-d", driverName, "--opt", "foo=bar", "--name", "test") 565 assert.NilError(c, err, out) 566 out, err = s.d.Cmd("volume", "inspect", "test") 567 assert.NilError(c, err, out) 568 569 var vs []types.Volume 570 err = json.Unmarshal([]byte(out), &vs) 571 assert.NilError(c, err) 572 assert.Equal(c, len(vs), 1) 573 assert.Equal(c, vs[0].Driver, driverName) 574 assert.Assert(c, vs[0].Options != nil) 575 assert.Equal(c, vs[0].Options["foo"], "bar") 576 assert.Equal(c, vs[0].Driver, driverName) 577 578 // simulate out of band volume deletion on plugin level 579 delete(p.vols, "test") 580 581 // test create with different driver 582 out, err = s.d.Cmd("volume", "create", "-d", "local", "--name", "test") 583 assert.NilError(c, err, out) 584 585 out, err = s.d.Cmd("volume", "inspect", "test") 586 assert.NilError(c, err, out) 587 vs = nil 588 err = json.Unmarshal([]byte(out), &vs) 589 assert.NilError(c, err) 590 assert.Equal(c, len(vs), 1) 591 assert.Equal(c, len(vs[0].Options), 0) 592 assert.Equal(c, vs[0].Driver, "local") 593 } 594 595 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnmountOnMountFail(c *testing.T) { 596 s.d.StartWithBusybox(c) 597 s.d.Cmd("volume", "create", "-d", "test-external-volume-driver", "--opt=invalidOption=1", "--name=testumount") 598 599 out, _ := s.d.Cmd("run", "-v", "testumount:/foo", "busybox", "true") 600 assert.Equal(c, s.ec.unmounts, 0, out) 601 out, _ = s.d.Cmd("run", "-w", "/foo", "-v", "testumount:/foo", "busybox", "true") 602 assert.Equal(c, s.ec.unmounts, 0, out) 603 } 604 605 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnmountOnCp(c *testing.T) { 606 s.d.StartWithBusybox(c) 607 s.d.Cmd("volume", "create", "-d", "test-external-volume-driver", "--name=test") 608 609 out, _ := s.d.Cmd("run", "-d", "--name=test", "-v", "test:/foo", "busybox", "/bin/sh", "-c", "touch /test && top") 610 assert.Equal(c, s.ec.mounts, 1, out) 611 612 out, _ = s.d.Cmd("cp", "test:/test", "/tmp/test") 613 assert.Equal(c, s.ec.mounts, 2, out) 614 assert.Equal(c, s.ec.unmounts, 1, out) 615 616 out, _ = s.d.Cmd("kill", "test") 617 assert.Equal(c, s.ec.unmounts, 2, out) 618 }