snapshot: Fix leaked mounts and temp directories
Signed-off-by: Samuel Karp <skarp@amazon.com>
This commit is contained in:
parent
e2eb06dd3d
commit
2c36c387de
4 changed files with 36 additions and 24 deletions
|
@ -18,7 +18,13 @@ func TestSnapshotManagerBasic(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// defer os.RemoveAll(tmpDir)
|
||||
defer func() {
|
||||
t.Log("Removing", tmpDir)
|
||||
err := os.RemoveAll(tmpDir)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}()
|
||||
|
||||
root := filepath.Join(tmpDir, "root")
|
||||
|
||||
|
@ -52,6 +58,7 @@ func TestSnapshotManagerBasic(t *testing.T) {
|
|||
if err := containerd.MountAll(mounts...); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer unmountAll(t, mounts)
|
||||
|
||||
if err := ioutil.WriteFile(filepath.Join(preparing, "foo"), []byte("foo\n"), 0777); err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -59,8 +66,6 @@ func TestSnapshotManagerBasic(t *testing.T) {
|
|||
|
||||
os.MkdirAll(preparing+"/a/b/c", 0755)
|
||||
|
||||
// defer os.Remove(filepath.Join(tmpDir, "foo"))
|
||||
|
||||
committed := filepath.Join(lm.root, "committed")
|
||||
|
||||
if err := lm.Commit(committed, preparing); err != nil {
|
||||
|
@ -83,6 +88,7 @@ func TestSnapshotManagerBasic(t *testing.T) {
|
|||
if err := containerd.MountAll(mounts...); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer unmountAll(t, mounts)
|
||||
|
||||
for _, mount := range mounts {
|
||||
if !strings.HasPrefix(mount.Target, next) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue