strategies

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: MIT Imports: 11 Imported by: 4

Documentation

Overview

Package strategies provides the framework to define testing strategies.

Test strategy can incorporate any exploration logic and run for a specified number of iterations. The package provides some inbuilt strategies like PCTCP and unittest (running a unit test for many iterations)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action added in v0.1.3

type Action struct {
	// Unique name for the action
	Name string
	// Function that performs the action
	Do func(*Context, *apiserver.APIServer) error
}

Action that the strategy can perform

func ActionSequence added in v0.1.4

func ActionSequence(actions ...Action) *Action

ActionSequence actions executes actions in a sequence

func DeliverMany added in v0.2.2

func DeliverMany(messages []*types.Message) *Action

DeliverMany action delivered all the specified messages

func DeliverMessage added in v0.1.3

func DeliverMessage(m *types.Message) *Action

DeliverMessage action that delivered the given message using apiserver.APIServer

func DoNothing added in v0.1.3

func DoNothing() *Action

DoNothing is a no-op action

type Context added in v0.1.1

type Context struct {
	*sm.Context
	// ActionSequence stores the sequence of actions performed in the current iteration
	ActionSequence *types.List[*Action]
	// contains filtered or unexported fields
}

Context here references to the execution context of a strategy

func (*Context) Abort added in v0.2.0

func (c *Context) Abort()

Abort the current iteration

func (*Context) CurIteration added in v0.1.3

func (c *Context) CurIteration() int

CurIteration returns the current iteration number

type Driver

type Driver struct {
	*types.BaseService
	// contains filtered or unexported fields
}

Driver runs the strategy with the specified configuration

func NewStrategyDriver added in v0.1.3

func NewStrategyDriver(
	config *config.Config,
	mp types.MessageParser,
	strategy Strategy,
	sConfig *StrategyConfig,
) *Driver

NewStrategyDriver creates a strategy and initializes the APIServer

func (*Driver) Name

func (srv *Driver) Name() string

Name implements DashboardRouter

func (*Driver) SetupRouter

func (srv *Driver) SetupRouter(router *gin.RouterGroup)

SetupRouter for setting up the dashboard routes implements DashboardRouter

func (*Driver) Start

func (d *Driver) Start() error

Start the driver and in turn start running the iterations

func (*Driver) Stop

func (d *Driver) Stop() error

Stop running the driver

type RandomStrategy added in v0.3.3

type RandomStrategy struct {
	*types.BaseService
	// contains filtered or unexported fields
}

func NewRandomStrategy added in v0.3.3

func NewRandomStrategy(dur time.Duration) *RandomStrategy

func (*RandomStrategy) ActionsCh added in v0.3.3

func (r *RandomStrategy) ActionsCh() *types.Channel[*Action]

func (*RandomStrategy) EndCurIteration added in v0.3.3

func (r *RandomStrategy) EndCurIteration(*Context)

func (*RandomStrategy) Finalize added in v0.3.3

func (r *RandomStrategy) Finalize(*Context)

func (*RandomStrategy) NextIteration added in v0.3.3

func (r *RandomStrategy) NextIteration(*Context)

func (*RandomStrategy) Start added in v0.3.3

func (r *RandomStrategy) Start() error

func (*RandomStrategy) Step added in v0.3.3

func (r *RandomStrategy) Step(e *types.Event, ctx *Context)

func (*RandomStrategy) Stop added in v0.3.3

func (r *RandomStrategy) Stop() error

type Strategy

type Strategy interface {
	types.Service
	// ActionsCh should return a channel that is used to
	// communicate the actions that needs to be performed
	ActionsCh() *types.Channel[*Action]
	// Step is called for each event, actions to be performed can be decided within the step call
	Step(*types.Event, *Context)
	// EndCurIteration is called at the end of every iteration
	EndCurIteration(*Context)
	// NextIteration is called at the beginning of every iteration
	NextIteration(*Context)
	// Finalize is called after executing all the iteration.
	// This function can be used to record/log telemetry or other stats
	Finalize(*Context)
}

Strategy interface to define an exploration strategy An exploration strategy should be encoded in this strategy

func NewStrategyWithProperty added in v0.2.0

func NewStrategyWithProperty(strategy Strategy, prop *sm.StateMachine) Strategy

Creates a new StrategyWithProperty

type StrategyConfig added in v0.1.4

type StrategyConfig struct {
	// Iterations the number of iterations to be run
	Iterations int `json:"iterations"`
	// IterationTimeout timeout for each iteration
	IterationTimeout time.Duration `json:"iteration_timeout"`
	// SetupFunc invoked at the start of every iteration
	SetupFunc func(*Context)
	// StepFunc invoked for every event in all iterations
	StepFunc func(*types.Event, *Context)
	// FinalizeFunc is invoked after all the iterations are completed
	FinalizeFunc func(*Context)
}

StrategyConfig store the config used for running strategies

type StrategyWithProperty added in v0.2.0

type StrategyWithProperty struct {
	Strategy
	Property *sm.StateMachine
	// contains filtered or unexported fields
}

StrategyWithProperty encapsulates a strategy with a property The property is specified as a state machine

func (*StrategyWithProperty) EndCurIteration added in v0.2.0

func (s *StrategyWithProperty) EndCurIteration(ctx *Context)

func (*StrategyWithProperty) Finalize added in v0.2.0

func (s *StrategyWithProperty) Finalize(ctx *Context)

func (*StrategyWithProperty) NextIteration added in v0.2.0

func (s *StrategyWithProperty) NextIteration(ctx *Context)

func (*StrategyWithProperty) Step added in v0.2.0

func (s *StrategyWithProperty) Step(e *types.Event, ctx *Context)

Directories

Path Synopsis
Package pct defines the PCTCP testing strategy
Package pct defines the PCTCP testing strategy
Package timeout encodes a strategy where timeout durations are chosen non deterministically
Package timeout encodes a strategy where timeout durations are chosen non deterministically
Package unittest strategy runs the same unit test for each iteration
Package unittest strategy runs the same unit test for each iteration

Jump to

Keyboard shortcuts

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