raftharness

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package raftharness provides a deterministic in-process harness for the TreeDB single-group Raft apply substrate.

The harness records and replays injected committed raftfsm entries across local node directories. It is integration-test scaffolding for failover, restart, follower catch-up, and logical snapshot-prefix install behavior around the committed-entry boundary. It does not run a Raft library, elect leaders, form quorums, replicate logs, transfer production snapshots, or prove production consensus.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNodeNotFound         = errors.New("raftharness: node not found")
	ErrNodeClosed           = errors.New("raftharness: node closed")
	ErrHarnessClosed        = errors.New("raftharness: harness closed")
	ErrCommittedLogGap      = errors.New("raftharness: committed log gap")
	ErrCommittedLogConflict = errors.New("raftharness: committed log conflict")
)

Functions

This section is empty.

Types

type CommitEvidenceV1

type CommitEvidenceV1 struct {
	Kind                EvidenceKindV1
	Committed           bool
	ProductionConsensus bool
	EntryIDs            []raftentry.ApplyEntryID
	Applied             map[raftcluster.NodeID][]raftentry.ApplyResultV1
}

func (CommitEvidenceV1) HasCommittedSuccess

func (e CommitEvidenceV1) HasCommittedSuccess() bool

func (CommitEvidenceV1) ProvesProductionConsensus

func (e CommitEvidenceV1) ProvesProductionConsensus() bool

type EvidenceKindV1

type EvidenceKindV1 string
const (
	// EvidenceInjectedCommittedEntryReplayV1 means the harness applied entries
	// that the test injected as already committed. It is not production Raft
	// consensus evidence.
	EvidenceInjectedCommittedEntryReplayV1 EvidenceKindV1 = "injected-committed-entry-replay-v1"
	// EvidenceInjectedSnapshotInstallV1 means the harness reconstructed a
	// logical snapshot cut from injected committed entries. It is not production
	// Raft snapshot-transfer evidence.
	EvidenceInjectedSnapshotInstallV1 EvidenceKindV1 = "injected-snapshot-install-v1"
)

type Harness

type Harness struct {
	// contains filtered or unexported fields
}

func Open

func Open(opts Options) (*Harness, error)

func (*Harness) ApplyCommittedEntriesToNode

func (h *Harness) ApplyCommittedEntriesToNode(id raftcluster.NodeID, entries ...raftfsm.CommittedEntryV1) ([]raftentry.ApplyResultV1, error)

func (*Harness) CatchUpNode

func (h *Harness) CatchUpNode(id raftcluster.NodeID) ([]raftentry.ApplyResultV1, error)

func (*Harness) CatchUpNodeThrough

func (h *Harness) CatchUpNodeThrough(id raftcluster.NodeID, maxIndex uint64) ([]raftentry.ApplyResultV1, error)

CatchUpNodeThrough catches the node up only through maxIndex. A maxIndex of zero catches up through the full committed log.

func (*Harness) Close

func (h *Harness) Close() error

func (*Harness) CloseNode

func (h *Harness) CloseNode(id raftcluster.NodeID) error

func (*Harness) Commit

func (h *Harness) Commit(entries ...raftfsm.CommittedEntryV1) (CommitEvidenceV1, error)

func (*Harness) CommitAndApply

func (h *Harness) CommitAndApply(nodeIDs []raftcluster.NodeID, entries ...raftfsm.CommittedEntryV1) (CommitEvidenceV1, error)

func (*Harness) InstallSnapshotPrefixToNodeV1

func (h *Harness) InstallSnapshotPrefixToNodeV1(id raftcluster.NodeID, manifest raftcluster.SnapshotManifestV1) (SnapshotInstallEvidenceV1, error)

func (*Harness) LogTruncationRecoveryStatusV1

func (h *Harness) LogTruncationRecoveryStatusV1(nodeID raftcluster.NodeID) (raftcluster.RecoveryStatusV1, error)

func (*Harness) Node

func (h *Harness) Node(id raftcluster.NodeID) (*Node, bool)

func (*Harness) PreCommitEvidence

func (h *Harness) PreCommitEvidence(entries ...raftfsm.CommittedEntryV1) CommitEvidenceV1

func (*Harness) ProductionRejoinRecoveryStatusV1

func (h *Harness) ProductionRejoinRecoveryStatusV1(nodeID raftcluster.NodeID) (raftcluster.RecoveryStatusV1, error)

func (*Harness) ProductionSnapshotTransferRecoveryStatusV1

func (h *Harness) ProductionSnapshotTransferRecoveryStatusV1(nodeID raftcluster.NodeID) (raftcluster.RecoveryStatusV1, error)

func (*Harness) ReadBarrier

func (h *Harness) ReadBarrier(nodeID raftcluster.NodeID) *ReadBarrier

func (*Harness) ReadIndexProvider

func (h *Harness) ReadIndexProvider(nodeID raftcluster.NodeID) *ReadIndexProvider

func (*Harness) RecoveryStatusV1

func (*Harness) ReopenNode

func (h *Harness) ReopenNode(id raftcluster.NodeID) (*Node, error)

func (*Harness) ReplaySnapshotTailToNodeV1

func (h *Harness) ReplaySnapshotTailToNodeV1(id raftcluster.NodeID, manifest raftcluster.SnapshotManifestV1) ([]raftentry.ApplyResultV1, error)

ReplaySnapshotTailToNodeV1 verifies that id contains the manifest boundary, then replays only committed entries after LastIncludedIndex.

type Node

type Node struct {
	// contains filtered or unexported fields
}

func (*Node) AppliedProgress

func (n *Node) AppliedProgress(ctx context.Context) (raftcluster.AppliedProgress, error)

func (*Node) ApplyCommittedEntriesV1

func (n *Node) ApplyCommittedEntriesV1(entries ...raftfsm.CommittedEntryV1) ([]raftentry.ApplyResultV1, error)

func (*Node) DB

func (n *Node) DB() *backenddb.DB

func (*Node) ID

func (n *Node) ID() raftcluster.NodeID

func (*Node) LastApplied

func (n *Node) LastApplied() (raftentry.ApplyEntryID, bool)

func (*Node) LogicalDigestV1

func (*Node) WaitAppliedIndex

type NodeConfig

type NodeConfig struct {
	ID      raftcluster.NodeID
	Address string
}

type Options

type Options struct {
	RootDir      string
	GroupID      raftcluster.GroupID
	Nodes        []NodeConfig
	StoreOptions raftapply.DurableApplyStoreOptions
}

type ReadBarrier

type ReadBarrier struct {
	// contains filtered or unexported fields
}

ReadBarrier is a per-node test adapter for injected committed-entry harnesses. It may catch the target node up through the requested index before proving local applied progress. It does not prove production consensus.

func (*ReadBarrier) AppliedProgress

func (b *ReadBarrier) AppliedProgress(ctx context.Context) (raftcluster.AppliedProgress, error)

func (*ReadBarrier) WaitAppliedIndex

type ReadIndexProvider

type ReadIndexProvider struct {
	// contains filtered or unexported fields
}

ReadIndexProvider is a test-only adapter for injected committed-entry harnesses. It reports the latest injected committed entry as read-index evidence for a configured node/group, but it does not prove production consensus and it does not apply entries locally.

func (*ReadIndexProvider) ReadIndex

type RecoveryStatusOptionsV1

type RecoveryStatusOptionsV1 struct {
	SnapshotManifest *raftcluster.SnapshotManifestV1
	TailTargetIndex  uint64

	RequireReadSafety bool
	ReadBarrier       raftcluster.AppliedIndexReadBarrier
}

type SnapshotInstallEvidenceV1

type SnapshotInstallEvidenceV1 struct {
	Kind               EvidenceKindV1
	Installed          bool
	ProductionSnapshot bool
	Manifest           raftcluster.SnapshotManifestV1
	EntryIDs           []raftentry.ApplyEntryID
	Applied            []raftentry.ApplyResultV1
}

func (SnapshotInstallEvidenceV1) ProvesProductionSnapshot

func (e SnapshotInstallEvidenceV1) ProvesProductionSnapshot() bool

Jump to

Keyboard shortcuts

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