Documentation
¶
Index ¶
- func CreateMinimalSandboxSpec(image string) *compute_v1alpha.SandboxSpec
- func CreateTestSandbox(ctx context.Context, eac *entityserver_v1alpha.EntityAccessClient, name string, ...) (entity.Id, error)
- func TestDebugLogger(t *testing.T) *slog.Logger
- func TestLogger(t *testing.T) *slog.Logger
- type EtcdEntityServer
- type InMemEntityServer
- type MockSandboxController
- func (c *MockSandboxController) MarkFailed(id entity.Id)
- func (c *MockSandboxController) Reset()
- func (c *MockSandboxController) Start(ctx context.Context) error
- func (c *MockSandboxController) Stop()
- func (c *MockSandboxController) WaitForSandbox(ctx context.Context, id entity.Id) (compute_v1alpha.SandboxStatus, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMinimalSandboxSpec ¶ added in v0.2.0
func CreateMinimalSandboxSpec(image string) *compute_v1alpha.SandboxSpec
CreateMinimalSandboxSpec creates a minimal sandbox spec for testing.
func CreateTestSandbox ¶ added in v0.2.0
func CreateTestSandbox( ctx context.Context, eac *entityserver_v1alpha.EntityAccessClient, name string, spec *compute_v1alpha.SandboxSpec, ) (entity.Id, error)
CreateTestSandbox creates a sandbox entity for testing with minimal configuration.
func TestDebugLogger ¶
TestDebugLogger creates a test logger that outputs logs
Types ¶
type EtcdEntityServer ¶
type EtcdEntityServer struct {
Store *entity.EtcdStore
Server *entityserver.EntityServer
EAC *entityserver_v1alpha.EntityAccessClient
Client *apiserver.Client
Prefix string
// contains filtered or unexported fields
}
EtcdEntityServer provides an etcd-backed entity server for testing This enforces proper optimistic concurrency control unlike the in-memory version
func NewEtcdEntityServer ¶
func NewEtcdEntityServer(t *testing.T) (*EtcdEntityServer, func())
NewEtcdEntityServer creates a new etcd-backed entity server for testing. It connects to etcd:2379 and uses a random prefix for isolation. Fails fast with a clear message if etcd is not reachable (i.e. outside dev env).
type InMemEntityServer ¶
type InMemEntityServer struct {
Store *entity.MockStore
Server *entityserver.EntityServer
EAC *entityserver_v1alpha.EntityAccessClient
Client *apiserver.Client
}
InMemEntityServer provides an in-memory entity server for testing
func NewInMemEntityServer ¶
func NewInMemEntityServer(t *testing.T) (*InMemEntityServer, func())
NewInMemEntityServer creates a new in-memory entity server for testing
func (*InMemEntityServer) AddEntity ¶
func (s *InMemEntityServer) AddEntity(ent *entity.Entity)
AddEntity adds an entity to the mock store
type MockSandboxController ¶ added in v0.2.0
type MockSandboxController struct {
Log *slog.Logger
EAC *entityserver_v1alpha.EntityAccessClient
// PollInterval controls how often the controller checks for pending sandboxes.
// Defaults to 50ms if not set.
PollInterval time.Duration
// StartupDelay is the delay before transitioning a sandbox from PENDING to RUNNING.
// Defaults to 0 (immediate transition).
StartupDelay time.Duration
// FailSandboxes is a set of sandbox IDs that should transition to DEAD instead of RUNNING.
FailSandboxes map[entity.Id]bool
// FailAll causes all sandboxes to transition to DEAD.
FailAll bool
// OnSandboxReady is called when a sandbox transitions to RUNNING.
// Can be used for test synchronization.
OnSandboxReady func(id entity.Id)
// OnSandboxFailed is called when a sandbox transitions to DEAD.
OnSandboxFailed func(id entity.Id)
// AssignNetwork controls whether to assign a mock network address.
// Defaults to true.
AssignNetwork bool
// NodeID is the mock node ID to assign to sandboxes.
// Defaults to "node/mock-node".
NodeID entity.Id
// contains filtered or unexported fields
}
MockSandboxController simulates a sandbox controller for testing. It watches for PENDING sandboxes and transitions them to RUNNING (or DEAD if configured).
func NewMockSandboxController ¶ added in v0.2.0
func NewMockSandboxController(log *slog.Logger, eac *entityserver_v1alpha.EntityAccessClient) *MockSandboxController
NewMockSandboxController creates a new mock sandbox controller with default settings.
func (*MockSandboxController) MarkFailed ¶ added in v0.2.0
func (c *MockSandboxController) MarkFailed(id entity.Id)
MarkFailed adds a sandbox ID to the list of sandboxes that should fail.
func (*MockSandboxController) Reset ¶ added in v0.2.0
func (c *MockSandboxController) Reset()
Reset clears the processed sandbox tracking, allowing sandboxes to be processed again.
func (*MockSandboxController) Start ¶ added in v0.2.0
func (c *MockSandboxController) Start(ctx context.Context) error
Start begins the mock sandbox controller in a background goroutine. Call Stop() to shut it down.
func (*MockSandboxController) Stop ¶ added in v0.2.0
func (c *MockSandboxController) Stop()
Stop shuts down the mock sandbox controller and waits for it to finish.
func (*MockSandboxController) WaitForSandbox ¶ added in v0.2.0
func (c *MockSandboxController) WaitForSandbox(ctx context.Context, id entity.Id) (compute_v1alpha.SandboxStatus, error)
WaitForSandbox waits for a sandbox to reach a terminal state (RUNNING or DEAD). Returns the final status or an error if the context times out.