Documentation
¶
Overview ¶
Package engine provides the framework for a snapshot repository testing engine
Index ¶
- Constants
- Variables
- type Action
- type ActionKey
- type ActionOpts
- type ActionStats
- type Args
- type Engine
- func (e *Engine) CheckErrRecovery(ctx context.Context, incomingErr error, actionOpts ActionOpts) (outgoingErr error)
- func (e *Engine) ExecAction(ctx context.Context, actionKey ActionKey, opts map[string]string) (map[string]string, error)
- func (e *Engine) Init(ctx context.Context) error
- func (e *Engine) RandomAction(ctx context.Context, actionOpts ActionOpts) error
- func (e *Engine) Shutdown(ctx context.Context) error
- func (e *Engine) Stats() string
- type Log
- func (elog *Log) AddCompleted(logEntry *LogEntry, err error)
- func (elog *Log) AddEntry(l *LogEntry)
- func (elog *Log) FindLast(actionKey ActionKey) *LogEntry
- func (elog *Log) FindLastThisRun(actionKey ActionKey) (found *LogEntry)
- func (elog *Log) String() string
- func (elog *Log) StringThisRun() string
- type LogEntry
- type Stats
Constants ¶
const ( ActionRepeaterField = "repeat-action" ThrowNoSpaceOnDeviceErrField = "throw-no-space-error" SnapshotIDField = "snapshot-ID" SubPathOptionName = "sub-path" )
Option field names.
Variables ¶
var ( // ErrInvalidArgs is returned if the constructor arguments are incorrect. ErrInvalidArgs = fmt.Errorf("invalid arguments") )
Functions ¶
This section is empty.
Types ¶
type Action ¶ added in v0.8.0
type Action struct {
// contains filtered or unexported fields
}
Action is a unit of functionality that can be executed by the engine.
type ActionKey ¶ added in v0.8.0
type ActionKey string
ActionKey refers to an action that can be executed by the engine.
const ( ActionControlActionKey ActionKey = "action-control" SnapshotDirActionKey ActionKey = "snapshot-root" RestoreSnapshotActionKey ActionKey = "restore-random-snapID" DeleteRandomSnapshotActionKey ActionKey = "delete-random-snapID" WriteRandomFilesActionKey ActionKey = "write-random-files" DeleteRandomSubdirectoryActionKey ActionKey = "delete-random-subdirectory" DeleteDirectoryContentsActionKey ActionKey = "delete-files" RestoreIntoDataDirectoryActionKey ActionKey = "restore-into-data-dir" GCActionKey ActionKey = "run-gc" )
List of action keys.
type ActionOpts ¶ added in v0.8.0
ActionOpts is a structure that designates the options for picking and running an action.
type ActionStats ¶ added in v0.8.0
type ActionStats struct {
Count int64
TotalRuntime time.Duration
MinRuntime time.Duration
MaxRuntime time.Duration
ErrorCount int64
}
ActionStats tracks runtime statistics for an action.
func (*ActionStats) AverageRuntime ¶ added in v0.8.0
func (s *ActionStats) AverageRuntime() time.Duration
AverageRuntime returns the average run time for the action.
type Args ¶ added in v0.8.0
type Args struct {
// Interfaces used by the engine.
MetaStore robustness.Persister
TestRepo robustness.Snapshotter
FileWriter robustness.FileWriter
// WorkingDir is a directory to use for temporary data.
WorkingDir string
// SyncRepositories should be set to true to reconcile differences.
SyncRepositories bool
}
Args contain the parameters for the engine constructor.
type Engine ¶
type Engine struct {
FileWriter robustness.FileWriter
TestRepo robustness.Snapshotter
MetaStore robustness.Persister
Checker *checker.Checker
RunStats Stats
CumulativeStats Stats
EngineLog Log
// contains filtered or unexported fields
}
Engine is the outer level testing framework for robustness testing.
func (*Engine) CheckErrRecovery ¶ added in v0.14.0
func (e *Engine) CheckErrRecovery(ctx context.Context, incomingErr error, actionOpts ActionOpts) (outgoingErr error)
CheckErrRecovery tries to recover from no space left error by deleting data directories.
func (*Engine) ExecAction ¶ added in v0.8.0
func (e *Engine) ExecAction(ctx context.Context, actionKey ActionKey, opts map[string]string) (map[string]string, error)
ExecAction executes the action denoted by the provided ActionKey.
func (*Engine) RandomAction ¶ added in v0.8.0
func (e *Engine) RandomAction(ctx context.Context, actionOpts ActionOpts) error
RandomAction executes a random action picked by the relative weights given in actionOpts[ActionControlActionKey], or uniform probability if that key is not present in the input options.
type Log ¶ added in v0.8.0
type Log struct {
Log []*LogEntry
// contains filtered or unexported fields
}
Log keeps track of the actions taken by the engine.
func (*Log) AddCompleted ¶ added in v0.8.0
AddCompleted finalizes a log entry at the time it is called and with the provided error, before adding it to the Log.
func (*Log) FindLast ¶ added in v0.8.0
FindLast finds the most recent log entry with the provided ActionKey.
func (*Log) FindLastThisRun ¶ added in v0.8.0
FindLastThisRun finds the most recent log entry with the provided ActionKey, limited to the current run only.
func (*Log) StringThisRun ¶ added in v0.8.0
StringThisRun returns a string of only the log entries generated by actions in this run of the engine.
type LogEntry ¶ added in v0.8.0
type LogEntry struct {
StartTime time.Time
EndTime time.Time
EngineTimestamp int64
Action ActionKey
Error string
Idx int64
ActionOpts map[string]string
CmdOpts map[string]string
}
LogEntry is an entry for the engine log.
type Stats ¶ added in v0.8.0
type Stats struct {
RunCounter int64
ActionCounter int64
CreationTime time.Time
RunTime time.Duration
PerActionStats map[ActionKey]*ActionStats
DataRestoreCount int64
DataPurgeCount int64
ErrorRecoveryCount int64
NoOpCount int64
}
Stats tracks statistics during engine runtime.