testutils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureStdout

func CaptureStdout(fn func()) (string, error)

func ClearContainer

func ClearContainer(ctx context.Context, cont containerd.Container)

func ClearContainers

func ClearContainers(cl *containerd.Client, ns string) error

func ClearImages

func ClearImages(cl *containerd.Client, ns string) error

func GetFreePort added in v0.3.0

func GetFreePort(t testing.TB) int

GetFreePort returns a port that is free for both TCP and UDP. This is important for QUIC-based servers (like the RPC server) which bind both protocols. The function binds both protocols to verify availability, then releases them. Fails the test if a suitable port cannot be obtained after several attempts.

func IsModuleLoaded

func IsModuleLoaded(moduleName string) bool

IsModuleLoaded does a naive check to see if the given linux kernel module is available

func ListContainers

func ListContainers(cl *containerd.Client, ns string) ([]string, error)

func MonitorContainers

func MonitorContainers(ctx context.Context, cl *containerd.Client, ns string) error

func NukeBridges

func NukeBridges()

func NukeNamespace

func NukeNamespace(cl *containerd.Client, ns string)

func WaitForContainerReady

func WaitForContainerReady(ctx context.Context, cl *containerd.Client, ns, id string) error

Types

type TestDeps added in v0.3.0

type TestDeps struct {
	// Containerd
	CC        *containerd.Client
	Namespace string

	// Network
	Bridge          string
	Subnet          *netdb.Subnet
	IPv4Routable    netip.Prefix
	ServicePrefixes []netip.Prefix
	NetServ         *network.ServiceManager
	Resolver        netresolve.Resolver

	// Paths
	DataPath string
	TempDir  string

	// Buildkit
	Buildkit *build.Buildkit

	// Metrics
	Writer      *metrics.VictoriaMetricsWriter
	Reader      *metrics.VictoriaMetricsReader
	CPU         *metrics.CPUUsage
	Mem         *metrics.MemoryUsage
	HTTPMetrics *metrics.HTTPMetrics

	// Observability
	LogsMaintainer      *observability.LogsMaintainer
	StatusMon           *observability.StatusMonitor
	LogWriter           observability.LogWriter
	PersistentLogReader *observability.PersistentLogReader
	Logs                *observability.LogReader

	// Coordinator and Entity Access
	Coordinator *coordinate.Coordinator
	EAC         *entityserver_v1alpha.EntityAccessClient
	RPCState    *rpc.State

	// Logger
	Log *slog.Logger

	// Context
	Ctx    context.Context
	Cancel context.CancelFunc
	// contains filtered or unexported fields
}

TestDeps holds all test dependencies explicitly for use in tests.

func NewTestDeps added in v0.3.0

func NewTestDeps() (*TestDeps, func())

NewTestDeps creates a TestDeps with explicit dependencies. This is the preferred way to set up test dependencies.

func (*TestDeps) NewImageImporter added in v0.3.0

func (d *TestDeps) NewImageImporter() image.ImageImporter

NewImageImporter creates an ImageImporter using the test dependencies.

Jump to

Keyboard shortcuts

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