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 ¶
- Variables
- type CommitEvidenceV1
- type EvidenceKindV1
- type Harness
- func (h *Harness) ApplyCommittedEntriesToNode(id raftcluster.NodeID, entries ...raftfsm.CommittedEntryV1) ([]raftentry.ApplyResultV1, error)
- func (h *Harness) CatchUpNode(id raftcluster.NodeID) ([]raftentry.ApplyResultV1, error)
- func (h *Harness) CatchUpNodeThrough(id raftcluster.NodeID, maxIndex uint64) ([]raftentry.ApplyResultV1, error)
- func (h *Harness) Close() error
- func (h *Harness) CloseNode(id raftcluster.NodeID) error
- func (h *Harness) Commit(entries ...raftfsm.CommittedEntryV1) (CommitEvidenceV1, error)
- func (h *Harness) CommitAndApply(nodeIDs []raftcluster.NodeID, entries ...raftfsm.CommittedEntryV1) (CommitEvidenceV1, error)
- func (h *Harness) InstallSnapshotPrefixToNodeV1(id raftcluster.NodeID, manifest raftcluster.SnapshotManifestV1) (SnapshotInstallEvidenceV1, error)
- func (h *Harness) LogTruncationRecoveryStatusV1(nodeID raftcluster.NodeID) (raftcluster.RecoveryStatusV1, error)
- func (h *Harness) Node(id raftcluster.NodeID) (*Node, bool)
- func (h *Harness) PreCommitEvidence(entries ...raftfsm.CommittedEntryV1) CommitEvidenceV1
- func (h *Harness) ProductionRejoinRecoveryStatusV1(nodeID raftcluster.NodeID) (raftcluster.RecoveryStatusV1, error)
- func (h *Harness) ProductionSnapshotTransferRecoveryStatusV1(nodeID raftcluster.NodeID) (raftcluster.RecoveryStatusV1, error)
- func (h *Harness) ReadBarrier(nodeID raftcluster.NodeID) *ReadBarrier
- func (h *Harness) ReadIndexProvider(nodeID raftcluster.NodeID) *ReadIndexProvider
- func (h *Harness) RecoveryStatusV1(ctx context.Context, nodeID raftcluster.NodeID, opts RecoveryStatusOptionsV1) (raftcluster.RecoveryStatusV1, error)
- func (h *Harness) ReopenNode(id raftcluster.NodeID) (*Node, error)
- func (h *Harness) ReplaySnapshotTailToNodeV1(id raftcluster.NodeID, manifest raftcluster.SnapshotManifestV1) ([]raftentry.ApplyResultV1, error)
- type Node
- func (n *Node) AppliedProgress(ctx context.Context) (raftcluster.AppliedProgress, error)
- func (n *Node) ApplyCommittedEntriesV1(entries ...raftfsm.CommittedEntryV1) ([]raftentry.ApplyResultV1, error)
- func (n *Node) DB() *backenddb.DB
- func (n *Node) ID() raftcluster.NodeID
- func (n *Node) LastApplied() (raftentry.ApplyEntryID, bool)
- func (n *Node) LogicalDigestV1(opts raftapply.LogicalDigestOptionsV1) (raftapply.LogicalDigestV1, error)
- func (n *Node) WaitAppliedIndex(ctx context.Context, barrier raftcluster.AppliedIndexReadBarrier) (raftcluster.AppliedProgress, error)
- type NodeConfig
- type Options
- type ReadBarrier
- type ReadIndexProvider
- type RecoveryStatusOptionsV1
- type SnapshotInstallEvidenceV1
Constants ¶
This section is empty.
Variables ¶
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 (*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) 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) 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 (h *Harness) RecoveryStatusV1(ctx context.Context, nodeID raftcluster.NodeID, opts RecoveryStatusOptionsV1) (raftcluster.RecoveryStatusV1, error)
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) ID ¶
func (n *Node) ID() raftcluster.NodeID
func (*Node) LastApplied ¶
func (n *Node) LastApplied() (raftentry.ApplyEntryID, bool)
func (*Node) LogicalDigestV1 ¶
func (n *Node) LogicalDigestV1(opts raftapply.LogicalDigestOptionsV1) (raftapply.LogicalDigestV1, error)
func (*Node) WaitAppliedIndex ¶
func (n *Node) WaitAppliedIndex(ctx context.Context, barrier raftcluster.AppliedIndexReadBarrier) (raftcluster.AppliedProgress, error)
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 ¶
func (b *ReadBarrier) WaitAppliedIndex(ctx context.Context, barrier raftcluster.AppliedIndexReadBarrier) (raftcluster.AppliedProgress, error)
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 ¶
func (p *ReadIndexProvider) ReadIndex(ctx context.Context, target raftcluster.ReadIndexBarrier) (raftcluster.ReadIndexProof, error)
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