Testcase added for Moving files in snapshot layers
Movement of files/folder from base layer to folder in new layer should be allowed Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
This commit is contained in:
		| @@ -37,6 +37,7 @@ func SnapshotterSuite(t *testing.T, name string, snapshotterFn func(ctx context. | ||||
| 	t.Run("DirectoryPermissionOnCommit", makeTest(name, snapshotterFn, checkDirectoryPermissionOnCommit)) | ||||
| 	t.Run("RemoveIntermediateSnapshot", makeTest(name, snapshotterFn, checkRemoveIntermediateSnapshot)) | ||||
| 	t.Run("DeletedFilesInChildSnapshot", makeTest(name, snapshotterFn, checkDeletedFilesInChildSnapshot)) | ||||
| 	t.Run("MoveFileFromLowerLayer", makeTest(name, snapshotterFn, checkFileFromLowerLayer)) | ||||
| 	// Rename test still fails on some kernels with overlay | ||||
| 	//t.Run("Rename", makeTest(name, snapshotterFn, checkRename)) | ||||
|  | ||||
| @@ -761,3 +762,25 @@ func checkSnapshotterViewReadonly(ctx context.Context, t *testing.T, snapshotter | ||||
| 	assert.NoError(t, snapshotter.Remove(ctx, view)) | ||||
| 	assert.NoError(t, snapshotter.Remove(ctx, committed)) | ||||
| } | ||||
|  | ||||
| // Move files from base layer to new location in intermediate layer. | ||||
| // Verify if the file at source is deleted and copied to new location. | ||||
| func checkFileFromLowerLayer(ctx context.Context, t *testing.T, snapshotter snapshot.Snapshotter, work string) { | ||||
| 	l1Init := fstest.Apply( | ||||
| 		fstest.CreateDir("/dir1", 0700), | ||||
| 		fstest.CreateFile("/dir1/f1", []byte("Hello"), 0644), | ||||
| 		fstest.CreateDir("dir2", 0700), | ||||
| 		fstest.CreateFile("dir2/f2", []byte("..."), 0644), | ||||
| 	) | ||||
| 	l2Init := fstest.Apply( | ||||
| 		fstest.CreateDir("/dir3", 0700), | ||||
| 		fstest.CreateFile("/dir3/f1", []byte("Hello"), 0644), | ||||
| 		fstest.RemoveAll("/dir1"), | ||||
| 		fstest.Link("dir2/f2", "dir3/f2"), | ||||
| 		fstest.RemoveAll("dir2/f2"), | ||||
| 	) | ||||
|  | ||||
| 	if err := checkSnapshots(ctx, snapshotter, work, l1Init, l2Init); err != nil { | ||||
| 		t.Fatalf("Check snapshots failed: %+v", err) | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Kunal Kushwaha
					Kunal Kushwaha