Fix layer comparison and enable read-only checks

fstest.CheckDirectoryEqual checks if any files in the diff matches a
list of known metadataFiles. This only happens if we specify the initial
layer as the first parameter and the mutated layer as the second.

This also enables the read-only view checks, as the bind filter allows
us to mount a layer as ro.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2023-02-04 02:39:30 -08:00
parent 36dc2782c4
commit feb637f92d

View File

@ -796,10 +796,6 @@ func checkRemove(ctx context.Context, t *testing.T, snapshotter snapshots.Snapsh
// checkSnapshotterViewReadonly ensures a KindView snapshot to be mounted as a read-only filesystem. // checkSnapshotterViewReadonly ensures a KindView snapshot to be mounted as a read-only filesystem.
// This function is called only when WithTestViewReadonly is true. // This function is called only when WithTestViewReadonly is true.
func checkSnapshotterViewReadonly(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) { func checkSnapshotterViewReadonly(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
if runtime.GOOS == "windows" {
t.Skip("Read-only protection on views is not supported on WCOW")
}
preparing := filepath.Join(work, "preparing") preparing := filepath.Join(work, "preparing")
if _, err := snapshotter.Prepare(ctx, preparing, "", opt); err != nil { if _, err := snapshotter.Prepare(ctx, preparing, "", opt); err != nil {
t.Fatal(err) t.Fatal(err)
@ -943,7 +939,7 @@ func check128LayersMount(name string) func(ctx context.Context, t *testing.T, sn
t.Log("mount", preparing) t.Log("mount", preparing)
if err := fstest.CheckDirectoryEqual(preparing, flat); err != nil { if err := fstest.CheckDirectoryEqual(flat, preparing); err != nil {
testutil.Unmount(t, preparing) testutil.Unmount(t, preparing)
t.Fatalf("[layer %d] preparing doesn't equal to flat before apply: %+v", i, err) t.Fatalf("[layer %d] preparing doesn't equal to flat before apply: %+v", i, err)
} }
@ -958,7 +954,7 @@ func check128LayersMount(name string) func(ctx context.Context, t *testing.T, sn
t.Fatalf("[layer %d] failed to apply on preparing dir: %+v", i, err) t.Fatalf("[layer %d] failed to apply on preparing dir: %+v", i, err)
} }
if err := fstest.CheckDirectoryEqual(preparing, flat); err != nil { if err := fstest.CheckDirectoryEqual(flat, preparing); err != nil {
testutil.Unmount(t, preparing) testutil.Unmount(t, preparing)
t.Fatalf("[layer %d] preparing doesn't equal to flat after apply: %+v", i, err) t.Fatalf("[layer %d] preparing doesn't equal to flat after apply: %+v", i, err)
} }
@ -987,7 +983,7 @@ func check128LayersMount(name string) func(ctx context.Context, t *testing.T, sn
} }
defer testutil.Unmount(t, view) defer testutil.Unmount(t, view)
if err := fstest.CheckDirectoryEqual(view, flat); err != nil { if err := fstest.CheckDirectoryEqual(flat, view); err != nil {
t.Fatalf("fullview should equal to flat: %+v", err) t.Fatalf("fullview should equal to flat: %+v", err)
} }
} }