@@ -35,8 +35,7 @@ import (
|
||||
"github.com/containerd/containerd/pkg/testutil"
|
||||
"github.com/containerd/containerd/snapshots"
|
||||
"github.com/containerd/continuity/fs/fstest"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// SnapshotterFunc is used in SnapshotterSuite
|
||||
@@ -173,8 +172,8 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh
|
||||
t.Fatalf("failure reason: %+v", err)
|
||||
}
|
||||
|
||||
assert.Check(t, is.Equal("", si.Parent))
|
||||
assert.Check(t, is.Equal(snapshots.KindCommitted, si.Kind))
|
||||
assert.Empty(t, si.Parent)
|
||||
assert.Equal(t, snapshots.KindCommitted, si.Kind)
|
||||
|
||||
_, err = snapshotter.Stat(ctx, preparing)
|
||||
if err == nil {
|
||||
@@ -209,8 +208,8 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
assert.Check(t, is.Equal(committed, ni.Parent))
|
||||
assert.Check(t, is.Equal(snapshots.KindActive, ni.Kind))
|
||||
assert.Equal(t, committed, ni.Parent)
|
||||
assert.Equal(t, snapshots.KindActive, ni.Kind)
|
||||
|
||||
nextCommitted := filepath.Join(work, "committed-next")
|
||||
if err := snapshotter.Commit(ctx, nextCommitted, next, opt); err != nil {
|
||||
@@ -222,8 +221,8 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh
|
||||
t.Fatalf("failure reason: %+v", err)
|
||||
}
|
||||
|
||||
assert.Check(t, is.Equal(committed, si2.Parent))
|
||||
assert.Check(t, is.Equal(snapshots.KindCommitted, si2.Kind))
|
||||
assert.Equal(t, committed, si2.Parent)
|
||||
assert.Equal(t, snapshots.KindCommitted, si2.Kind)
|
||||
|
||||
_, err = snapshotter.Stat(ctx, next)
|
||||
if err == nil {
|
||||
@@ -235,7 +234,7 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh
|
||||
si2.Name: si2,
|
||||
}
|
||||
walked := map[string]snapshots.Info{} // walk is not ordered
|
||||
assert.NilError(t, snapshotter.Walk(ctx, func(ctx context.Context, si snapshots.Info) error {
|
||||
assert.Nil(t, snapshotter.Walk(ctx, func(ctx context.Context, si snapshots.Info) error {
|
||||
walked[si.Name] = si
|
||||
return nil
|
||||
}))
|
||||
@@ -246,7 +245,7 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh
|
||||
t.Errorf("Missing stat for %v", ek)
|
||||
continue
|
||||
}
|
||||
assert.Check(t, is.DeepEqual(ev, av))
|
||||
assert.Equal(t, ev, av)
|
||||
}
|
||||
|
||||
nextnext := filepath.Join(work, "nextnextlayer")
|
||||
@@ -269,10 +268,16 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh
|
||||
}
|
||||
|
||||
testutil.Unmount(t, nextnext)
|
||||
assert.NilError(t, snapshotter.Remove(ctx, nextnext))
|
||||
assert.Assert(t, is.ErrorContains(snapshotter.Remove(ctx, committed), "remove"))
|
||||
assert.NilError(t, snapshotter.Remove(ctx, nextCommitted))
|
||||
assert.NilError(t, snapshotter.Remove(ctx, committed))
|
||||
assert.Nil(t, snapshotter.Remove(ctx, nextnext))
|
||||
|
||||
err = snapshotter.Remove(ctx, committed)
|
||||
assert.NotNil(t, err)
|
||||
if err != nil {
|
||||
assert.Contains(t, err.Error(), "remove")
|
||||
}
|
||||
|
||||
assert.Nil(t, snapshotter.Remove(ctx, nextCommitted))
|
||||
assert.Nil(t, snapshotter.Remove(ctx, committed))
|
||||
}
|
||||
|
||||
// Create a New Layer on top of base layer with Prepare, Stat on new layer, should return Active layer.
|
||||
@@ -304,9 +309,9 @@ func checkSnapshotterStatActive(ctx context.Context, t *testing.T, snapshotter s
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Check(t, is.Equal(si.Name, preparing))
|
||||
assert.Check(t, is.Equal(snapshots.KindActive, si.Kind))
|
||||
assert.Check(t, is.Equal("", si.Parent))
|
||||
assert.Equal(t, si.Name, preparing)
|
||||
assert.Equal(t, snapshots.KindActive, si.Kind)
|
||||
assert.Equal(t, "", si.Parent)
|
||||
}
|
||||
|
||||
// Commit a New Layer on top of base layer with Prepare & Commit , Stat on new layer, should return Committed layer.
|
||||
@@ -343,9 +348,9 @@ func checkSnapshotterStatCommitted(ctx context.Context, t *testing.T, snapshotte
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Check(t, is.Equal(si.Name, committed))
|
||||
assert.Check(t, is.Equal(snapshots.KindCommitted, si.Kind))
|
||||
assert.Check(t, is.Equal("", si.Parent))
|
||||
assert.Equal(t, si.Name, committed)
|
||||
assert.Equal(t, snapshots.KindCommitted, si.Kind)
|
||||
assert.Equal(t, "", si.Parent)
|
||||
|
||||
}
|
||||
|
||||
@@ -418,9 +423,9 @@ func checkSnapshotterTransitivity(ctx context.Context, t *testing.T, snapshotter
|
||||
}
|
||||
|
||||
// Test the transivity
|
||||
assert.Check(t, is.Equal("", siA.Parent))
|
||||
assert.Check(t, is.Equal(snapA, siB.Parent))
|
||||
assert.Check(t, is.Equal("", siParentB.Parent))
|
||||
assert.Equal(t, "", siA.Parent)
|
||||
assert.Equal(t, snapA, siB.Parent)
|
||||
assert.Equal(t, "", siParentB.Parent)
|
||||
|
||||
}
|
||||
|
||||
@@ -450,7 +455,7 @@ func checkSnapshotterPrepareView(ctx context.Context, t *testing.T, snapshotter
|
||||
}
|
||||
|
||||
_, err = snapshotter.View(ctx, newLayer, snapA, opt)
|
||||
assert.Check(t, err != nil)
|
||||
assert.True(t, err != nil)
|
||||
|
||||
// Two Prepare with same key
|
||||
prepLayer := filepath.Join(work, "prepLayer")
|
||||
@@ -464,7 +469,7 @@ func checkSnapshotterPrepareView(ctx context.Context, t *testing.T, snapshotter
|
||||
}
|
||||
|
||||
_, err = snapshotter.Prepare(ctx, prepLayer, snapA, opt)
|
||||
assert.Check(t, err != nil)
|
||||
assert.True(t, err != nil)
|
||||
|
||||
// Two View with same key
|
||||
viewLayer := filepath.Join(work, "viewLayer")
|
||||
@@ -478,7 +483,7 @@ func checkSnapshotterPrepareView(ctx context.Context, t *testing.T, snapshotter
|
||||
}
|
||||
|
||||
_, err = snapshotter.View(ctx, viewLayer, snapA, opt)
|
||||
assert.Check(t, err != nil)
|
||||
assert.True(t, err != nil)
|
||||
|
||||
}
|
||||
|
||||
@@ -809,8 +814,8 @@ func checkSnapshotterViewReadonly(ctx context.Context, t *testing.T, snapshotter
|
||||
t.Fatalf("write to %q should fail (EROFS) but did not fail", testfile)
|
||||
}
|
||||
testutil.Unmount(t, viewMountPoint)
|
||||
assert.NilError(t, snapshotter.Remove(ctx, view))
|
||||
assert.NilError(t, snapshotter.Remove(ctx, committed))
|
||||
assert.Nil(t, snapshotter.Remove(ctx, view))
|
||||
assert.Nil(t, snapshotter.Remove(ctx, committed))
|
||||
}
|
||||
|
||||
// Move files from base layer to new location in intermediate layer.
|
||||
|
||||
Reference in New Issue
Block a user