Documentation
¶
Overview ¶
Package testutil builds real local snapshot and content stores for transfer tests. The stores need no privileges: see inplace.go for what that costs.
Index ¶
- Constants
- Variables
- func CheckFile(t testing.TB, ref bkcache.ImmutableRef, name, want string)
- func Root(t testing.TB, ref bkcache.ImmutableRef) string
- type Provider
- type Store
- func (s *Store) Build(t testing.TB, parent bkcache.ImmutableRef, name, value string) (bkcache.ImmutableRef, string)
- func (s *Store) GC(t testing.TB)
- func (s *Store) Reload(t testing.TB)
- func (s *Store) WithBuiltin(t testing.TB, provider content.InfoReaderProvider)
- func (s *Store) WithSharedMounts(t testing.TB, linger time.Duration, maxIdle int)
Constants ¶
View Source
const Namespace = "snapshot-transfer-test"
Variables ¶
View Source
var FileTime = time.Unix(1700000000, 0).UTC()
Functions ¶
Types ¶
type Provider ¶
type Provider struct {
content.InfoReaderProvider
Reads atomic.Int64
BeforeRead func(context.Context, ocispecs.Descriptor) error
}
type Store ¶
type Store struct {
Manager bkcache.SnapshotManager
Content *containerdsnapshot.Store
Snapshots bkcache.Snapshotter
Leases leases.Manager
DB *metadata.DB
Applies atomic.Int64
Diffs atomic.Int64
BeforeWrite func([]byte) error
BeforeApply func(context.Context, ocispecs.Descriptor) error
BeforeDiff func(context.Context) error
// BeforeSnapshotUpdate runs before each snapshot label update.
BeforeSnapshotUpdate func(context.Context, ctdsnapshots.Info) error
// BeforeStat runs before each snapshot Stat the manager makes.
BeforeStat func(ctx context.Context, key string)
// LeaseCommitErr, when set, rolls back each transaction the manager
// makes through SnapshotManagerOpt.MetadataDB and returns it.
LeaseCommitErr error
// Builtin, when set before the manager is (re)opened, plays the engine's
// builtin image store for chain imports.
Builtin content.InfoReaderProvider
BeforeAdd func(context.Context, leases.Lease, leases.Resource) error
AfterAdd func(context.Context, leases.Lease, leases.Resource)
AfterCreate func(leases.Lease)
// SharedMountLinger and MaxIdleSharedMounts, when set before the manager
// is (re)opened, bound its idle shared read-only mounts.
// LocalMounts and LocalUnmounts count the shared read-only mounts made
// and unmounted; they are made in place, without privileges.
LocalMounts atomic.Int64
LocalUnmounts atomic.Int64
// BeforeLocalUnmount runs before each of those unmounts.
BeforeLocalUnmount func()
// contains filtered or unexported fields
}
func (*Store) Build ¶
func (s *Store) Build(t testing.TB, parent bkcache.ImmutableRef, name, value string) (bkcache.ImmutableRef, string)
Build writes through an ordinary mutable ref, commits, and keeps an ordinary owner lease. The caller can release that owner independently of returned refs.
func (*Store) WithBuiltin ¶
func (s *Store) WithBuiltin(t testing.TB, provider content.InfoReaderProvider)
WithBuiltin reopens the manager with provider as the builtin image store, keeping the persistent metadata.
Click to show internal directories.
Click to hide internal directories.