simcluster

package
v0.1.0-alpha.8 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package simcluster runs an in-process multi-node Zattera control plane for unit and chaos tests: real hashicorp/raft with in-memory transports, real FSM/state, fake container runtime, fake clock. No Docker, no network.

It is the backbone of scheduler, HA and failover verification: kill the leader, partition nodes, advance time, assert convergence.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	T     *testing.T
	Nodes []*Node
	Clock *clock.Fake
}

Cluster is a set of interconnected nodes sharing one fake clock.

func New

func New(t *testing.T, n int) *Cluster

New builds and boots an n-node cluster and waits for a leader.

func (*Cluster) Apply

func (c *Cluster) Apply(cmd *clusterv1.Command) error

Apply proposes a command on the current leader, retrying across elections until timeout. Business errors are returned immediately.

func (*Cluster) Heal

func (c *Cluster) Heal()

Heal reconnects every live node to every other.

func (*Cluster) Kill

func (c *Cluster) Kill(id string)

Kill shuts a node down abruptly (no dcommission), simulating a crash.

func (*Cluster) KillLeader

func (c *Cluster) KillLeader() string

KillLeader crashes the current leader and returns its id.

func (*Cluster) Leader

func (c *Cluster) Leader() *Node

Leader returns the current leader node, or nil.

func (*Cluster) Partition

func (c *Cluster) Partition(groups ...[]string)

Partition splits the cluster into isolated groups of node ids. Nodes within a group stay connected; links across groups are severed.

func (*Cluster) Shutdown

func (c *Cluster) Shutdown()

Shutdown stops every live node.

func (*Cluster) WaitLeader

func (c *Cluster) WaitLeader(timeout time.Duration) *Node

WaitLeader blocks until some live node is leader.

type Node

type Node struct {
	ID        string
	Store     *raftstore.Store
	State     *state.Store
	Runtime   *fakeruntime.Fake
	Transport *raft.InmemTransport
	// contains filtered or unexported fields
}

Node is one simulated control(+worker) node.

Jump to

Keyboard shortcuts

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