From 6f463d35057134cfdf6736d3c19daedc41b101e3 Mon Sep 17 00:00:00 2001 From: Eric Ren Date: Wed, 8 May 2019 11:19:23 +0800 Subject: [PATCH] test/snapshots: umount before committing snapshot For block device like devicemapper, umount before committing active snapshot can sync data onto disk. Otherewise: 1. deactivating a block device in use will fail or IO error when forced; 2. new snapshot on it will not catch the data not laid on disk yet. Signed-off-by: Eric Ren --- snapshots/testsuite/testsuite.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/snapshots/testsuite/testsuite.go b/snapshots/testsuite/testsuite.go index 8fa64fe61..ea2a88b6a 100644 --- a/snapshots/testsuite/testsuite.go +++ b/snapshots/testsuite/testsuite.go @@ -149,11 +149,12 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh if err := mount.All(mounts, preparing); err != nil { t.Fatalf("failure reason: %+v", err) } - defer testutil.Unmount(t, preparing) if err := initialApplier.Apply(preparing); err != nil { t.Fatalf("failure reason: %+v", err) } + // unmount before commit + testutil.Unmount(t, preparing) committed := filepath.Join(work, "committed") if err := snapshotter.Commit(ctx, committed, preparing, opt); err != nil { @@ -185,7 +186,6 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh if err := mount.All(mounts, next); err != nil { t.Fatalf("failure reason: %+v", err) } - defer testutil.Unmount(t, next) if err := fstest.CheckDirectoryEqualWithApplier(next, initialApplier); err != nil { t.Fatalf("failure reason: %+v", err) @@ -194,6 +194,8 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh if err := diffApplier.Apply(next); err != nil { t.Fatalf("failure reason: %+v", err) } + // unmount before commit + testutil.Unmount(t, next) ni, err := snapshotter.Stat(ctx, next) if err != nil {