From b6fb234142c4c2f896d8b5b8b7120e6b0f718c0d Mon Sep 17 00:00:00 2001 From: Kunal Kushwaha Date: Thu, 7 Sep 2017 13:34:33 +0900 Subject: [PATCH] Testcase added for deletion of files in lower layer Files/folders deleted in lower layer and commited, it should not reflect on upper layer Signed-off-by: Kunal Kushwaha --- snapshot/testsuite/testsuite.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/snapshot/testsuite/testsuite.go b/snapshot/testsuite/testsuite.go index 3b2c0c474..67e35b5a0 100644 --- a/snapshot/testsuite/testsuite.go +++ b/snapshot/testsuite/testsuite.go @@ -36,7 +36,7 @@ func SnapshotterSuite(t *testing.T, name string, snapshotterFn func(ctx context. t.Run("Chown", makeTest(name, snapshotterFn, checkChown)) t.Run("DirectoryPermissionOnCommit", makeTest(name, snapshotterFn, checkDirectoryPermissionOnCommit)) t.Run("RemoveIntermediateSnapshot", makeTest(name, snapshotterFn, checkRemoveIntermediateSnapshot)) - + t.Run("DeletedFilesInChildSnapshot", makeTest(name, snapshotterFn, checkDeletedFilesInChildSnapshot)) // Rename test still fails on some kernels with overlay //t.Run("Rename", makeTest(name, snapshotterFn, checkRename)) @@ -438,6 +438,24 @@ func checkSnapshotterPrepareView(ctx context.Context, t *testing.T, snapshotter } +// Deletion of files/folder of base layer in new layer, On Commit, those files should not be visible. +func checkDeletedFilesInChildSnapshot(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { + + l1Init := fstest.Apply( + fstest.CreateFile("/foo", []byte("foo\n"), 0777), + fstest.CreateFile("/foobar", []byte("foobar\n"), 0777), + ) + l2Init := fstest.Apply( + fstest.RemoveAll("/foobar"), + ) + l3Init := fstest.Apply() + + if err := checkSnapshots(ctx, snapshotter, work, l1Init, l2Init, l3Init); err != nil { + t.Fatalf("Check snapshots failed: %+v", err) + } + +} + //Create three layers. Deleting intermediate layer must fail. func checkRemoveIntermediateSnapshot(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) {