Help us shape the future of Go! Take the 2026 Go Developer Survey

crashtest

package
v0.57.21 Latest Latest
Warning

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

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

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.

const (
	// DurableBlocks targets publish pending blocks with durable commits only.
	DurableBlocks Blocks = iota
	// AllBlocks targets publish pending blocks with every commit.
	AllBlocks
)

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.

Jump to

Keyboard shortcuts

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