Documentation
¶
Overview ¶
Package crashtest checks that a volume engine recovers from a crash at any point of a randomized workload to a state its commits allow.
The workload mixes durable and ordered key-value commits, block puts and removes, journal appends, and syncs. A durable commit or sync makes the whole live state durable. An ordered commit may survive a crash only after every ordered commit before it, and block writes survive only through a later commit that publishes them. The commit a crash interrupts may or may not survive.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run[D Device](t *testing.T, blocks Blocks, newDevice func() D, open func(ctx context.Context, d D) (Target, error))
Run runs each workload on a new device from newDevice, crashes it at every mutating device call, applies a power loss, and checks that the target open reopens holds an allowed state and keeps working. blocks is which commits of the target publish its pending blocks.
Types ¶
type Blocks ¶
type Blocks int
Blocks is which commits of a target publish its pending block writes and removes.
type Device ¶
type Device interface {
// Calls returns the number of mutating calls made so far.
Calls() int
// CrashAfter fails every mutating call after the next n succeed.
CrashAfter(n int)
// PowerLoss replaces the contents with a state a power loss could leave
// and accepts calls again.
PowerLoss(rng *rand.Rand)
}
Device is storage that crashes and loses power on request.
type Target ¶
type Target interface {
kvtx.Store
block.StoreOps
// AppendJournal durably journals reference graph changes.
AppendJournal(ctx context.Context, adds, removes []block_gc.RefEdge) error
// AppendJournalOrdered journals reference graph changes with write
// ordering only.
AppendJournalOrdered(ctx context.Context, adds, removes []block_gc.RefEdge) error
// ReplayJournal passes every journal entry in order to apply and removes
// the entries.
ReplayJournal(ctx context.Context, apply func(adds, removes []block_gc.RefEdge) error) error
// Close releases the engine.
Close() error
}
Target is the engine under test.