Documentation
¶
Index ¶
- func PollUntil(ctx context.Context, interval time.Duration, condition func() bool) error
- func PollUntilWithError(ctx context.Context, interval time.Duration, condition func() (bool, error)) error
- func Retry(ctx context.Context, attempts int, initialDelay time.Duration, ...) error
- type Assertions
- func (a *Assertions) ContainerHealthy(containerID string, client *Client)
- func (a *Assertions) ContainerRunning(containerID string, client *Client)
- func (a *Assertions) Contains(haystack, needle, msg string)
- func (a *Assertions) Equal(expected, actual interface{}, msg string)
- func (a *Assertions) Error(err error, msg string)
- func (a *Assertions) Errorf(format string, args ...interface{})
- func (a *Assertions) Eventually(condition func() bool, timeout, interval time.Duration, msg string)
- func (a *Assertions) EventuallyWithContext(ctx context.Context, condition func() bool, interval time.Duration, msg string)
- func (a *Assertions) Fail(msg string)
- func (a *Assertions) FailNow()
- func (a *Assertions) False(condition bool, msg string)
- func (a *Assertions) Fatalf(format string, args ...interface{})
- func (a *Assertions) HasLeader(cluster *Cluster)
- func (a *Assertions) Info(msg string)
- func (a *Assertions) Len(obj interface{}, expected int, msg string)
- func (a *Assertions) Log(msg string)
- func (a *Assertions) Logf(format string, args ...interface{})
- func (a *Assertions) Nil(obj interface{}, msg string)
- func (a *Assertions) NoError(err error, msg string)
- func (a *Assertions) NodeCount(expected int, client *Client)
- func (a *Assertions) NodeRole(nodeID, expectedRole string, client *Client)
- func (a *Assertions) NotContains(haystack, needle, msg string)
- func (a *Assertions) NotEqual(expected, actual interface{}, msg string)
- func (a *Assertions) NotNil(obj interface{}, msg string)
- func (a *Assertions) QuorumSize(expected int, cluster *Cluster)
- func (a *Assertions) ServiceDeleted(name string, client *Client)
- func (a *Assertions) ServiceExists(name string, client *Client)
- func (a *Assertions) ServiceReplicas(name string, expected int, client *Client)
- func (a *Assertions) ServiceRunning(name string, client *Client)
- func (a *Assertions) Step(step string)
- func (a *Assertions) Success(msg string)
- func (a *Assertions) True(condition bool, msg string)
- func (a *Assertions) Warning(msg string)
- type Client
- func (c *Client) CreateIngress(name string, spec *IngressSpec) error
- func (c *Client) CreateService(name, image string, replicas int) error
- func (c *Client) CreateServiceWithEnv(name, image string, replicas int, env map[string]string) error
- func (c *Client) DeleteIngress(name string) error
- func (c *Client) ListIngresses() ([]*proto.Ingress, error)
- type Cluster
- func (c *Cluster) Cleanup() error
- func (c *Cluster) GetLeader() (*Manager, error)
- func (c *Cluster) KillManager(id string) error
- func (c *Cluster) RestartManager(id string) error
- func (c *Cluster) Start() error
- func (c *Cluster) Stop() error
- func (c *Cluster) WaitForQuorum() error
- func (c *Cluster) WaitForWorkers() error
- type ClusterConfig
- type IngressBackend
- type IngressSpec
- type IngressTLS
- type LogBuffer
- type Manager
- type Process
- func (p *Process) IsRunning() bool
- func (p *Process) Kill() error
- func (p *Process) Logs() string
- func (p *Process) LogsSince(since time.Time) string
- func (p *Process) Restart() error
- func (p *Process) Start() error
- func (p *Process) Stop() error
- func (p *Process) Wait() error
- func (p *Process) WaitForLog(pattern string, timeout time.Duration) error
- type RuntimeType
- type ServicePort
- type ServiceSpec
- type TestContext
- type TestingT
- type VM
- type VMConfig
- type Waiter
- func (w *Waiter) WaitFor(ctx context.Context, condition func() bool, description string) error
- func (w *Waiter) WaitForClusterHealthy(ctx context.Context, client *Client) error
- func (w *Waiter) WaitForConditionWithRetry(ctx context.Context, condition func() (bool, error), description string) error
- func (w *Waiter) WaitForContainer(ctx context.Context, client *Client, containerID string, status string) error
- func (w *Waiter) WaitForContainerHealthy(ctx context.Context, client *Client, containerID string) error
- func (w *Waiter) WaitForContainerRunning(ctx context.Context, client *Client, containerID string) error
- func (w *Waiter) WaitForLeaderElection(ctx context.Context, cluster *Cluster) error
- func (w *Waiter) WaitForManagerNodes(ctx context.Context, client *Client, count int) error
- func (w *Waiter) WaitForNodeCount(ctx context.Context, client *Client, count int) error
- func (w *Waiter) WaitForQuorum(ctx context.Context, cluster *Cluster) error
- func (w *Waiter) WaitForReplicas(ctx context.Context, client *Client, serviceName string, count int) error
- func (w *Waiter) WaitForSecret(ctx context.Context, client *Client, name string) error
- func (w *Waiter) WaitForSecretDeleted(ctx context.Context, client *Client, name string) error
- func (w *Waiter) WaitForServiceDeleted(ctx context.Context, client *Client, name string) error
- func (w *Waiter) WaitForServiceRunning(ctx context.Context, client *Client, name string) error
- func (w *Waiter) WaitForVolume(ctx context.Context, client *Client, name string) error
- func (w *Waiter) WaitForVolumeDeleted(ctx context.Context, client *Client, name string) error
- func (w *Waiter) WaitForWorkerNodes(ctx context.Context, client *Client, count int) error
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Assertions ¶
type Assertions struct {
// contains filtered or unexported fields
}
Assertions provides test assertion helpers
func NewAssertions ¶
func NewAssertions(t TestingT) *Assertions
NewAssertions creates a new Assertions instance
func (*Assertions) ContainerHealthy ¶
func (a *Assertions) ContainerHealthy(containerID string, client *Client)
ContainerHealthy asserts that a container is healthy TODO: Container proto doesn't have health_status field yet - using actual_state as proxy
func (*Assertions) ContainerRunning ¶
func (a *Assertions) ContainerRunning(containerID string, client *Client)
ContainerRunning asserts that a container is running
func (*Assertions) Contains ¶
func (a *Assertions) Contains(haystack, needle, msg string)
Contains asserts that a string contains a substring
func (*Assertions) Equal ¶
func (a *Assertions) Equal(expected, actual interface{}, msg string)
Equal asserts that two values are equal
func (*Assertions) Error ¶
func (a *Assertions) Error(err error, msg string)
Error asserts that the error is not nil
func (*Assertions) Errorf ¶
func (a *Assertions) Errorf(format string, args ...interface{})
Errorf logs an error and fails the test
func (*Assertions) Eventually ¶
func (a *Assertions) Eventually(condition func() bool, timeout, interval time.Duration, msg string)
Eventually repeatedly runs a condition until it returns true or timeout occurs
func (*Assertions) EventuallyWithContext ¶
func (a *Assertions) EventuallyWithContext(ctx context.Context, condition func() bool, interval time.Duration, msg string)
EventuallyWithContext is like Eventually but uses a provided context
func (*Assertions) Fail ¶
func (a *Assertions) Fail(msg string)
Fail marks the test as failed but continues execution
func (*Assertions) FailNow ¶
func (a *Assertions) FailNow()
FailNow fails the test immediately without logging
func (*Assertions) False ¶
func (a *Assertions) False(condition bool, msg string)
False asserts that a condition is false
func (*Assertions) Fatalf ¶
func (a *Assertions) Fatalf(format string, args ...interface{})
Fatalf logs a fatal error and stops the test immediately
func (*Assertions) HasLeader ¶
func (a *Assertions) HasLeader(cluster *Cluster)
HasLeader asserts that the cluster has a leader
func (*Assertions) Len ¶
func (a *Assertions) Len(obj interface{}, expected int, msg string)
Len asserts that a slice or map has a specific length
func (*Assertions) Logf ¶
func (a *Assertions) Logf(format string, args ...interface{})
Logf logs a formatted message (non-failing)
func (*Assertions) Nil ¶
func (a *Assertions) Nil(obj interface{}, msg string)
Nil asserts that a value is nil
func (*Assertions) NoError ¶
func (a *Assertions) NoError(err error, msg string)
NoError asserts that the error is nil
func (*Assertions) NodeCount ¶
func (a *Assertions) NodeCount(expected int, client *Client)
NodeCount asserts that the cluster has the expected number of nodes
func (*Assertions) NodeRole ¶
func (a *Assertions) NodeRole(nodeID, expectedRole string, client *Client)
NodeRole asserts that a node has a specific role
func (*Assertions) NotContains ¶
func (a *Assertions) NotContains(haystack, needle, msg string)
NotContains asserts that a string does not contain a substring
func (*Assertions) NotEqual ¶
func (a *Assertions) NotEqual(expected, actual interface{}, msg string)
NotEqual asserts that two values are not equal
func (*Assertions) NotNil ¶
func (a *Assertions) NotNil(obj interface{}, msg string)
NotNil asserts that a value is not nil
func (*Assertions) QuorumSize ¶
func (a *Assertions) QuorumSize(expected int, cluster *Cluster)
QuorumSize asserts that the cluster has the expected quorum size
func (*Assertions) ServiceDeleted ¶
func (a *Assertions) ServiceDeleted(name string, client *Client)
ServiceDeleted asserts that a service no longer exists
func (*Assertions) ServiceExists ¶
func (a *Assertions) ServiceExists(name string, client *Client)
ServiceExists asserts that a service exists
func (*Assertions) ServiceReplicas ¶
func (a *Assertions) ServiceReplicas(name string, expected int, client *Client)
ServiceReplicas asserts that a service has the expected number of running replicas
func (*Assertions) ServiceRunning ¶
func (a *Assertions) ServiceRunning(name string, client *Client)
ServiceRunning asserts that a service has at least one running task
func (*Assertions) Step ¶
func (a *Assertions) Step(step string)
Step logs a test step (for visibility in test output)
func (*Assertions) Success ¶
func (a *Assertions) Success(msg string)
Success logs a success message
func (*Assertions) True ¶
func (a *Assertions) True(condition bool, msg string)
True asserts that a condition is true
func (*Assertions) Warning ¶
func (a *Assertions) Warning(msg string)
Warning logs a warning message
type Client ¶
Client wraps the Warren client with test-friendly methods
func (*Client) CreateIngress ¶
func (c *Client) CreateIngress(name string, spec *IngressSpec) error
CreateIngress creates an ingress rule
func (*Client) CreateService ¶
CreateService creates a service with default environment
func (*Client) CreateServiceWithEnv ¶
func (c *Client) CreateServiceWithEnv(name, image string, replicas int, env map[string]string) error
CreateServiceWithEnv creates a service with custom environment variables
func (*Client) DeleteIngress ¶
DeleteIngress deletes an ingress rule
type Cluster ¶
type Cluster struct {
// Config is the cluster configuration
Config *ClusterConfig
// Managers contains all manager nodes in the cluster
Managers []*Manager
// Workers contains all worker nodes in the cluster
Workers []*Worker
// contains filtered or unexported fields
}
Cluster represents a test Warren cluster
func NewCluster ¶
func NewCluster(config *ClusterConfig) (*Cluster, error)
NewCluster creates a new test cluster with the given configuration
func (*Cluster) KillManager ¶
KillManager kills a specific manager (simulates crash)
func (*Cluster) RestartManager ¶
RestartManager restarts a specific manager
func (*Cluster) WaitForQuorum ¶
WaitForQuorum waits for Raft quorum to be established
func (*Cluster) WaitForWorkers ¶
WaitForWorkers waits for all workers to connect to the cluster
type ClusterConfig ¶
type ClusterConfig struct {
// NumManagers is the number of manager nodes to create
NumManagers int
// NumWorkers is the number of worker nodes to create
NumWorkers int
// UseLima indicates whether to use Lima VMs (default: true)
UseLima bool
// Runtime specifies which runtime to use (Lima, Docker, Local)
Runtime RuntimeType
// ManagerVMConfig is the VM configuration for manager nodes
ManagerVMConfig *VMConfig
// WorkerVMConfig is the VM configuration for worker nodes
WorkerVMConfig *VMConfig
// DataDir is the base directory for cluster data
DataDir string
// WarrenBinary is the path to the Warren binary
WarrenBinary string
// KeepOnFailure keeps the cluster running if tests fail (for debugging)
KeepOnFailure bool
// LogLevel sets the logging level for Warren processes
LogLevel string
}
ClusterConfig defines the configuration for a test cluster
func DefaultClusterConfig ¶
func DefaultClusterConfig() *ClusterConfig
DefaultClusterConfig returns a default cluster configuration
type IngressBackend ¶
IngressBackend defines the backend service for an ingress rule
type IngressSpec ¶
type IngressSpec struct {
Host string
Path string
PathType string // "Exact" or "Prefix"
Backend IngressBackend
TLS *IngressTLS
}
IngressSpec defines an ingress rule for testing
type IngressTLS ¶
IngressTLS defines TLS configuration for an ingress
type LogBuffer ¶
type LogBuffer struct {
// contains filtered or unexported fields
}
LogBuffer provides thread-safe log buffering with timestamps
type Manager ¶
type Manager struct {
// ID is the unique identifier for this manager
ID string
// VM is the virtual machine or container running this manager
VM VM
// APIAddr is the gRPC API address (host:port)
APIAddr string
// RaftAddr is the Raft consensus address (host:port)
RaftAddr string
// Client is the Warren client connected to this manager
Client *Client
// RawClient is the underlying Warren client (for advanced use)
RawClient *client.Client
// Process is the Warren process (if running locally)
Process *Process
// DataDir is the data directory for this manager
DataDir string
// IsLeader indicates if this manager is the Raft leader
IsLeader bool
}
Manager represents a manager node in the test cluster
type Process ¶
type Process struct {
Binary string
Args []string
Env []string
Ctx context.Context
Cancel context.CancelFunc
LogFile string
PID int
// contains filtered or unexported fields
}
Process manages a Warren process with logging and lifecycle control
type RuntimeType ¶
type RuntimeType string
RuntimeType defines the type of runtime for test clusters
const ( // RuntimeLima uses Lima VMs for testing RuntimeLima RuntimeType = "lima" // RuntimeDocker uses Docker containers for testing RuntimeDocker RuntimeType = "docker" // RuntimeLocal uses local processes for testing RuntimeLocal RuntimeType = "local" )
type ServicePort ¶
ServicePort defines a port mapping
type ServiceSpec ¶
type ServiceSpec struct {
Name string
Image string
Replicas int
Env map[string]string
Ports []ServicePort
}
ServiceSpec defines a service for testing
type TestContext ¶
type TestContext struct {
// T is the testing.T instance
T TestingT
// Ctx is the context for test operations
Ctx context.Context
// Cancel cancels the test context
Cancel context.CancelFunc
// Timeout is the default timeout for operations
Timeout time.Duration
// contains filtered or unexported fields
}
TestContext provides utilities for test execution
type TestingT ¶
type TestingT interface {
Logf(format string, args ...interface{})
Errorf(format string, args ...interface{})
Fatalf(format string, args ...interface{})
FailNow()
Failed() bool
Name() string
Helper()
}
TestingT is an interface matching testing.T
type VM ¶
type VM interface {
// ID returns the unique identifier for this VM
ID() string
// Start starts the VM
Start(ctx context.Context) error
// Stop stops the VM gracefully
Stop(ctx context.Context) error
// Kill forcefully terminates the VM
Kill(ctx context.Context) error
// IsRunning returns true if the VM is currently running
IsRunning() bool
// Exec executes a command in the VM and returns the output
Exec(ctx context.Context, command string, args ...string) (string, error)
// CopyFile copies a file from the host to the VM
CopyFile(ctx context.Context, src, dst string) error
// GetIP returns the IP address of the VM
GetIP() (string, error)
// WaitForBoot waits for the VM to finish booting
WaitForBoot(ctx context.Context) error
}
VM represents a virtual machine or container for testing
type VMConfig ¶
type VMConfig struct {
// CPUs is the number of CPUs to allocate
CPUs int
// Memory is the amount of memory to allocate (e.g., "2GiB")
Memory string
// Disk is the disk size (e.g., "10GiB")
Disk string
}
VMConfig defines the configuration for a VM
type Waiter ¶
type Waiter struct {
// contains filtered or unexported fields
}
Waiter provides utilities for waiting on conditions with timeouts
func DefaultWaiter ¶
func DefaultWaiter() *Waiter
DefaultWaiter returns a waiter with sensible defaults (30s timeout, 1s interval)
func (*Waiter) WaitForClusterHealthy ¶
WaitForClusterHealthy waits for all nodes in the cluster to be healthy
func (*Waiter) WaitForConditionWithRetry ¶
func (w *Waiter) WaitForConditionWithRetry(ctx context.Context, condition func() (bool, error), description string) error
WaitForConditionWithRetry waits for a condition with exponential backoff retry
func (*Waiter) WaitForContainer ¶
func (w *Waiter) WaitForContainer(ctx context.Context, client *Client, containerID string, status string) error
WaitForContainer waits for a specific container to reach a status
func (*Waiter) WaitForContainerHealthy ¶
func (w *Waiter) WaitForContainerHealthy(ctx context.Context, client *Client, containerID string) error
WaitForContainerHealthy waits for a container to become healthy TODO: Use actual health_status field when added to proto
func (*Waiter) WaitForContainerRunning ¶
func (w *Waiter) WaitForContainerRunning(ctx context.Context, client *Client, containerID string) error
WaitForContainerRunning waits for a container to be running
func (*Waiter) WaitForLeaderElection ¶
WaitForLeaderElection waits for a leader to be elected in the cluster
func (*Waiter) WaitForManagerNodes ¶
WaitForManagerNodes waits for a specific number of manager nodes
func (*Waiter) WaitForNodeCount ¶
WaitForNodeCount waits for a specific number of nodes to join the cluster
func (*Waiter) WaitForQuorum ¶
WaitForQuorum waits for Raft quorum to be established
func (*Waiter) WaitForReplicas ¶
func (w *Waiter) WaitForReplicas(ctx context.Context, client *Client, serviceName string, count int) error
WaitForReplicas waits for a service to have a specific number of running replicas
func (*Waiter) WaitForSecret ¶
WaitForSecret waits for a secret to exist
func (*Waiter) WaitForSecretDeleted ¶
WaitForSecretDeleted waits for a secret to be deleted
func (*Waiter) WaitForServiceDeleted ¶
WaitForServiceDeleted waits for a service to be deleted
func (*Waiter) WaitForServiceRunning ¶
WaitForServiceRunning waits for a service to have at least one running task
func (*Waiter) WaitForVolume ¶
WaitForVolume waits for a volume to exist
func (*Waiter) WaitForVolumeDeleted ¶
WaitForVolumeDeleted waits for a volume to be deleted
type Worker ¶
type Worker struct {
// ID is the unique identifier for this worker
ID string
// VM is the virtual machine or container running this worker
VM VM
// ManagerAddr is the address of the manager this worker connects to
ManagerAddr string
// Process is the Warren process (if running locally)
Process *Process
// DataDir is the data directory for this worker
DataDir string
}
Worker represents a worker node in the test cluster