metaflags

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package metaflags defines command-line flags for the metamorphic tests and provides functionality to construct the respective metamorphic.RunOptions/RunOnceOptions.

Index

Constants

This section is empty.

Variables

View Source
var KeyFormats = map[string]metamorphic.KeyFormat{
	"testkeys":     metamorphic.TestkeysKeyFormat,
	"cockroachkvs": metamorphic.CockroachKeyFormat,
}

KeyFormats is a map of available key formats.

Functions

func InitAllFlags

func InitAllFlags() (*RunOnceFlags, *RunFlags)

InitAllFlags initializes all metamorphic test flags: those used for a single run, and those used for a "top level" run.

func RunOnceOnlyFlagNames added in v2.1.0

func RunOnceOnlyFlagNames() map[string]struct{}

RunOnceOnlyFlagNames returns the names of the flags that are used only for RunOnce/Compare.

func RunOnlyFlagNames added in v2.1.0

func RunOnlyFlagNames() map[string]struct{}

RunOnlyFlagNames returns the names of the flags that are used only for metamorphic.Run.

Types

type CommonFlags

type CommonFlags struct {
	// Dir is the directory storing test state. See "dir" flag below.
	Dir string
	// Seed for generation of random operations. See "seed" flag below.
	Seed uint64
	// ErrorRate is the rate of injected filesystem errors. See "error-rate" flag
	// below.
	ErrorRate float64
	// FailRE causes the test to fail if the output matches this regex. See "fail"
	// flag below.
	FailRE string
	// Keep determines if the DB directory is kept on successful runs. See "keep"
	// flag below.
	Keep bool
	// MaxThreads used by a single run. See "max-threads" flag below.
	MaxThreads int
	// NumInstances is the number of Pebble instances to create in one run. See
	// "num-instances" flag below.
	NumInstances int
	// OpTimeout is a per-operation timeout.
	OpTimeout time.Duration
	// KeyFormatName is the name of the KeyFormat to use. Defaults to "testkeys".
	// Acceptable values are "testkeys" and "cockroachkvs".
	KeyFormatName string
	// InitialStatePath is the path to a database data directory from a previous
	// run. See the "initial-state" flag below.
	InitialStatePath string
}

CommonFlags contains flags that apply to both metamorphic.Run and metamorphic.RunOnce/Compare.

func (*CommonFlags) KeyFormat added in v2.1.0

func (c *CommonFlags) KeyFormat() metamorphic.KeyFormat

KeyFormat returns the KeyFormat indicated by the flags KeyFormatName.

type RunFlags

type RunFlags struct {
	*CommonFlags
	// FS controls the type of filesystems to use. See "fs" flag below.
	FS string
	// TraceFile for execution tracing. See "trace-file" flag below.
	TraceFile string
	// Ops describes how the total number of operations is generated. See "ops" flags below.
	Ops randvar.Flag
	// InnerBinary is the binary to invoke for a single run. See "inner-binary"
	// flag below.
	InnerBinary string
	// PreviousOps is the path to the ops file of a previous run. See the
	// "previous-ops" flag below.
	PreviousOps string
	// InitialStateDesc is a human-readable description of the initial database
	// state. See "initial-state-desc" flag below.
	InitialStateDesc string
}

RunFlags contains flags that apply only to metamorphic.Run.

func (*RunFlags) MakeRunOptions

func (r *RunFlags) MakeRunOptions() ([]metamorphic.RunOption, error)

MakeRunOptions constructs RunOptions based on the flags.

type RunOnceFlags

type RunOnceFlags struct {
	*CommonFlags
	// RunDir applies to metamorphic.RunOnce and contains the specific
	// configuration of the run. See "run-dir" flag below.
	RunDir string
	// Compare applies to metamorphic.Compare. See "compare" flag below.
	Compare string
	// TryToReduce enables a mode where we try to find a minimal subset of
	// operations that reproduce a problem during a test run (e.g. panic or
	// internal error).
	TryToReduce bool
	// ReduceAttempts is the number of attempts to reduce (for each op removal
	// probability).
	ReduceAttempts int
}

RunOnceFlags contains flags that apply only to metamorphic.RunOnce/Compare.

func InitRunOnceFlags

func InitRunOnceFlags() *RunOnceFlags

InitRunOnceFlags initializes the flags that are used for a single run of the metamorphic test.

func (*RunOnceFlags) MakeRunOnceOptions

func (ro *RunOnceFlags) MakeRunOnceOptions() []metamorphic.RunOnceOption

MakeRunOnceOptions constructs RunOnceOptions based on the flags.

func (*RunOnceFlags) ParseCompare

func (ro *RunOnceFlags) ParseCompare() (testRootDir string, runSubdirs []string)

ParseCompare parses the value of the compare flag, in format "test-root-dir/{run1,run2,...}". Exits if the value is not valid.

Returns the common test root dir (e.g. "test-root-dir") and a list of subdirectories (e.g. {"run1", "run2"}).

Jump to

Keyboard shortcuts

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