Documentation ¶
Index ¶
- func RegisterDestroyer(name string, destroyer Destroyer)
- func RegisterKiller(name string, killer func(System) (Killer, error))
- func RegisterReadyParser(key string, parser func(*Config) ReadyParser)
- func RegisterSystem(name string, system func() System)
- func RegisterTestSystem(t *testing.T)
- type ChaosMaker
- type Config
- type Destroyer
- type DestroyerFunc
- type Hook
- type HookOption
- func WithPostChaos(postChaos func(context.Context) error) HookOption
- func WithPostReady(postReady func(context.Context) error) HookOption
- func WithPostSystemLoad(postSystemLoad func(context.Context) error) HookOption
- func WithPreChaos(preChaos func(context.Context) error) HookOption
- func WithPreReady(preReady func(context.Context) error) HookOption
- func WithPreSystemLoad(preSystemLoad func(context.Context) error) HookOption
- type ID
- type Identifier
- type Identifiers
- type Killer
- type KillerFunc
- type ReadyCond
- type ReadyFunc
- type ReadyParser
- type ReadyParserFunc
- type System
- type TestIdentifier
- type TestKiller
- type TestSystem
- func (t *TestSystem) AsJSON(ctx context.Context, reload bool) ([]byte, error)
- func (t *TestSystem) Identifiers() Identifiers
- func (t *TestSystem) Load(ctx context.Context) error
- func (t *TestSystem) Parse(m map[string]interface{}) (err error)
- func (t *TestSystem) Validate(ctx context.Context) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterDestroyer ¶
RegisterDestroyer is used by plugins to register custom destroyers.
func RegisterKiller ¶
RegisterKiller is used by plugins to register custom killers.
func RegisterReadyParser ¶
func RegisterReadyParser(key string, parser func(*Config) ReadyParser)
RegisterReadyParser registers ReadyParser creating functions that can be used by config file.
func RegisterSystem ¶
RegisterSystem is used by plugins to register custom systems.
func RegisterTestSystem ¶
Types ¶
type ChaosMaker ¶
type ChaosMaker struct { *Config logrus.FieldLogger *audit.Reporter }
ChaosMaker takes Config and executes chaos scenarios both pre-defined and randomly generated ones.
func (*ChaosMaker) CreateChaos ¶
func (cm *ChaosMaker) CreateChaos(ctx context.Context, opts ...HookOption) error
CreateChaos executes all the chaos scenarios and exits with error on first scenario which fails to recover and get into desired state or returns successfully if all systems get back into desired state from all chaos scenarios.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents the input configuration provided to execute chaos scenarios.
type Destroyer ¶
type Destroyer interface { // ParseDestroySection parses the any section under destroy block. ParseDestroySection(map[string]interface{}) (Identifiers, error) }
Destroyer parses the single section of destroy whether it be exclusions or scenarios. Plugin implementations need to implement this interface.
type DestroyerFunc ¶
type DestroyerFunc func(map[string]interface{}) (Identifiers, error)
DestroyerFunc is the syntax sugar for single method Destroyer interface so that a simple function can implement Destroyer interface.
func DestroyerTest ¶
func DestroyerTest() DestroyerFunc
func (DestroyerFunc) ParseDestroySection ¶
func (d DestroyerFunc) ParseDestroySection(m map[string]interface{}) (Identifiers, error)
ParseDestroySection calls d(m).
type Hook ¶
type Hook struct {
// contains filtered or unexported fields
}
Hook can be used to perform user defined actions at different stages of chaos execution such as log collection, fetching system state etc.
type HookOption ¶
type HookOption func(h *Hook)
HookOption is functional option implementation to create Hook.
func WithPostChaos ¶
func WithPostChaos(postChaos func(context.Context) error) HookOption
WithPostChaos functional option is used to hook user defined action to be executed after last chaos scenario is executed.
func WithPostReady ¶
func WithPostReady(postReady func(context.Context) error) HookOption
WithPostReady functional option is used to hook user defined action to be executed after ready condition is executed.
func WithPostSystemLoad ¶
func WithPostSystemLoad(postSystemLoad func(context.Context) error) HookOption
WithPostSystemLoad functional option is used to hook user defined action to be executed after systems are loaded.
func WithPreChaos ¶
func WithPreChaos(preChaos func(context.Context) error) HookOption
WithPreChaos functional option is used to hook user defined action to be executed before first chaos scenario is executed.
func WithPreReady ¶
func WithPreReady(preReady func(context.Context) error) HookOption
WithPreReady functional option is used to hook user defined action to be executed before ready condition is executed.
func WithPreSystemLoad ¶
func WithPreSystemLoad(preSystemLoad func(context.Context) error) HookOption
WithPreSystemLoad functional option is used to hook user defined action to be executed before systems are loaded.
type Identifier ¶
type Identifier interface { // ID returns the unique identifier of resource or operation in a particular system. ID() ID }
Identifier uniquely identifies any resource or operation in a particular system.
type Identifiers ¶
type Identifiers []Identifier
Identifiers is group of Identifier which can be used to create scenarios for creating chaos, excluding the chaos scenarios etc.
func (Identifiers) String ¶
func (idents Identifiers) String() string
String method returns string representation of Identifiers.
type Killer ¶
type Killer interface { // Kill kills given identifiers. Kill(context.Context, ...Identifier) error }
Killer kills the given identifiers. Definition of kill depends on system. For example, in kubernetes it could be deleting resource and for networks it could creating disconnection between systems.
type KillerFunc ¶
type KillerFunc func(context.Context, ...Identifier) error
KillerFunc is the syntax sugar for single method Killer interface so that a simple function can implement Killer interface.
func (KillerFunc) Kill ¶
func (k KillerFunc) Kill(ctx context.Context, i ...Identifier) error
KillerFunc calls k(ctx, i).
type ReadyCond ¶
type ReadyCond interface { // Ready checks whether system has reached desired state. Ready(context.Context) (bool, error) }
ReadyCond defines the condition where in all the systems are considered to be in desired state.
type ReadyFunc ¶
ReadyFunc is the syntax sugar for single method ReadyCond interface so that a simple function can implement ReadyCond interface.
func After ¶
After is a very simple ReadyFunc which sleeps for given duration and then marks systems as ready.
type ReadyParser ¶
type ReadyParser interface { // Parse parses the ready section and creates ReadyCond. Parse(map[string]interface{}) (ReadyCond, error) }
ReadyParser parses the ready section to create ReadyCond.
func AfterParser ¶
func AfterParser(config *Config) ReadyParser
AfterParser returns ReadyParser with can parse After ReadyFunc
type ReadyParserFunc ¶
ReadyParserFunc is the syntax sugar for single method ReadyParser interface so that a simple function can implement ReadyParser interface.
type System ¶
type System interface { // Parse parses the definition of system. Parse(map[string]interface{}) error // Load loads the state of system as per its definition. Load(context.Context) error // Validate validates at any point of time whether the actual state of system matches with its desired state // as determined by ReadyCond. Validate(context.Context) (bool, error) // Identifiers return Identifier values of all resources in the system. Identifiers() Identifiers // AsJSON returns the json representation of the state of the system. If `reload` is set to `true`, state of the system // will be reloaded before preparing json representation of system. AsJSON(ctx context.Context, reload bool) ([]byte, error) }
System is the core interface which represents any execution environment such as Kubernetes, AWS etc. Plugin implementations need to implement this interface which handles things such as parsing system definition, loading desired state, performing validation etc.
type TestIdentifier ¶
type TestIdentifier string
func (TestIdentifier) ID ¶
func (t TestIdentifier) ID() ID
type TestKiller ¶
type TestKiller struct {
System *TestSystem
}
func (*TestKiller) Kill ¶
func (t *TestKiller) Kill(_ context.Context, identifiers ...Identifier) (err error)
type TestSystem ¶
type TestSystem struct { Resources map[TestIdentifier]bool State map[TestIdentifier]bool }
func (*TestSystem) Identifiers ¶
func (t *TestSystem) Identifiers() Identifiers
func (*TestSystem) Parse ¶
func (t *TestSystem) Parse(m map[string]interface{}) (err error)