testutil

package
v1.0.0-beta.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

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

View Source
const Namespace = "snapshot-transfer-test"

Variables

View Source
var FileTime = time.Unix(1700000000, 0).UTC()

Functions

func CheckFile

func CheckFile(t testing.TB, ref bkcache.ImmutableRef, name, want string)

func RequireNativeMount

func RequireNativeMount(t testing.TB)

RequireNativeMount skips the test with the reason when the host denies the read-only bind mount that a native snapshot read needs. Tests that read a snapshot through core.MountRef (File.Contents, Directory.Entries, the evaluation of a subdirectory) call it first; the in-place store makes every other store test independent of mount privileges, and this probe marks the remaining ones as unexecuted, not failed, on hosts and CI runners without them.

func Root

func Root(t testing.TB, ref bkcache.ImmutableRef) string

Root returns the directory behind a committed snapshot of this store, for a test that reads the bytes it expects there.

Types

type Provider

type Provider struct {
	content.InfoReaderProvider
	Reads      atomic.Int64
	BeforeRead func(context.Context, ocispecs.Descriptor) error
}

func (*Provider) ReaderAt

func (p *Provider) ReaderAt(ctx context.Context, desc ocispecs.Descriptor) (content.ReaderAt, 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
	// 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)
	// contains filtered or unexported fields
}

func NewStore

func NewStore(t testing.TB) *Store

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) GC

func (s *Store) GC(t testing.TB)

func (*Store) Reload

func (s *Store) Reload(t testing.TB)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL