Skip to content

Commit 6f463d3

Browse files
Eric Renrenzhen.rz
authored andcommitted
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 <[email protected]>
1 parent 3887053 commit 6f463d3

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

snapshots/testsuite/testsuite.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,12 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh
149149
if err := mount.All(mounts, preparing); err != nil {
150150
t.Fatalf("failure reason: %+v", err)
151151
}
152-
defer testutil.Unmount(t, preparing)
153152

154153
if err := initialApplier.Apply(preparing); err != nil {
155154
t.Fatalf("failure reason: %+v", err)
156155
}
156+
// unmount before commit
157+
testutil.Unmount(t, preparing)
157158

158159
committed := filepath.Join(work, "committed")
159160
if err := snapshotter.Commit(ctx, committed, preparing, opt); err != nil {
@@ -185,7 +186,6 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh
185186
if err := mount.All(mounts, next); err != nil {
186187
t.Fatalf("failure reason: %+v", err)
187188
}
188-
defer testutil.Unmount(t, next)
189189

190190
if err := fstest.CheckDirectoryEqualWithApplier(next, initialApplier); err != nil {
191191
t.Fatalf("failure reason: %+v", err)
@@ -194,6 +194,8 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh
194194
if err := diffApplier.Apply(next); err != nil {
195195
t.Fatalf("failure reason: %+v", err)
196196
}
197+
// unmount before commit
198+
testutil.Unmount(t, next)
197199

198200
ni, err := snapshotter.Stat(ctx, next)
199201
if err != nil {

0 commit comments

Comments
 (0)