mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
testutil/daemon: daemon.Cleanup(): unmount daemon root-dir as part of cleanup
test-daemons remove their docker.pid when stopped, so the `.integration-daemon-stop` script did not find the mounts for those daemons, and therefore was not unmounting them. As a result, cleaning up the bundles directory on consecutive runs of the tests would fail; rm: cannot remove 'bundles/test-integration/TestDockerSwarmSuite/TestSwarmInit/d1f188f3f5472/root': Device or resource busy This patch unmounts the root directory of the daemon as part of the cleanup step. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
9407a57522
commit
1fe7a9552c
1 changed files with 11 additions and 0 deletions
|
@ -19,6 +19,7 @@ import (
|
|||
"github.com/docker/docker/client"
|
||||
"github.com/docker/docker/opts"
|
||||
"github.com/docker/docker/pkg/ioutils"
|
||||
"github.com/docker/docker/pkg/mount"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/docker/docker/testutil/request"
|
||||
"github.com/docker/go-connections/sockets"
|
||||
|
@ -213,6 +214,7 @@ func (d *Daemon) NewClient(extraOpts ...client.Opt) (*client.Client, error) {
|
|||
// Cleanup cleans the daemon files : exec root (network namespaces, ...), swarmkit files
|
||||
func (d *Daemon) Cleanup(t testing.TB) {
|
||||
t.Helper()
|
||||
cleanupMount(t, d)
|
||||
// Cleanup swarmkit wal files if present
|
||||
cleanupRaftDir(t, d.Root)
|
||||
cleanupNetworkNamespace(t, d.execRoot)
|
||||
|
@ -710,6 +712,15 @@ func (d *Daemon) Info(t testing.TB) types.Info {
|
|||
return info
|
||||
}
|
||||
|
||||
// cleanupMount unmounts the daemon root directory, or logs a message if
|
||||
// unmounting failed.
|
||||
func cleanupMount(t testing.TB, d *Daemon) {
|
||||
t.Helper()
|
||||
if err := mount.Unmount(d.Root); err != nil {
|
||||
d.log.Logf("[%s] unable to unmount daemon root (%s): %v", d.id, d.Root, err)
|
||||
}
|
||||
}
|
||||
|
||||
func cleanupRaftDir(t testing.TB, rootPath string) {
|
||||
t.Helper()
|
||||
for _, p := range []string{"wal", "wal-v3-encrypted", "snap-v3-encrypted"} {
|
||||
|
|
Loading…
Add table
Reference in a new issue