Documentation
¶
Index ¶
- Variables
- func IsMessageAcrossPartition() sm.Condition
- func IsMessageFromPart(partLabel string) sm.Condition
- func IsMessageWithinPartition() sm.Condition
- func NewReportStore() *reportStore
- type Action
- type Context
- type FilterFunc
- type FilterSet
- type FilterSetOption
- type FilterSetStats
- type IfThenHandler
- type Partition
- type TestCase
- type TestCaseDriver
- type TestingServer
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotEnoughReplicas = errors.New("not enough replicas") ErrSizeLabelsMismatch = errors.New("sizes and labels are not of the same length") )
Functions ¶
func IsMessageAcrossPartition ¶ added in v0.2.1
func IsMessageFromPart ¶ added in v0.1.1
func IsMessageWithinPartition ¶ added in v0.2.1
func NewReportStore ¶
func NewReportStore() *reportStore
Types ¶
type Action ¶
Action is used to specify the consequence in the `If().Then()` handler
func DeliverAllFromSet ¶ added in v0.2.0
func DeliverAllFromSet(s *sm.SetWrapper) Action
DeliverAll returns an action which inturn returns all the messages in the message set and removes the messages from the set.
func DeliverMessage ¶
func DeliverMessage() Action
DeliverMessage returns the message if the event is a message send event
func IncrCounter ¶ added in v0.2.0
func IncrCounter(c *sm.CountWrapper) Action
IncrCounter returns an action which increments the counter value
func OnceAction ¶ added in v0.1.1
func RecordMessageAs ¶
RecordMessageAs returns an action. If the event is a message send or receive, the message is recorded in context with the label as reference
func StoreInSet ¶ added in v0.2.0
func StoreInSet(s *sm.SetWrapper) Action
Store returns an action. If the event is a message send or receive, the action adds the message to the message set
type Context ¶
Context struct is passed to the calls of StateAction and Condition encapsulates all information needed by the StateAction and Condition to function
func NewContext ¶ added in v0.2.0
func NewContext(c *context.RootContext, testcase *TestCase) *Context
newContext instantiates a Context from the RootContext
func NewContextFrom ¶ added in v0.2.0
func (*Context) CreatePartition ¶ added in v0.1.1
func (*Context) EndTestCase ¶
func (c *Context) EndTestCase()
Ends the testcase without failing. The assertion will determine the success of the testcase
func (*Context) NewMessage ¶
func (c *Context) NewMessage(cur *types.Message, data []byte, pMsg types.ParsedMessage) *types.Message
NewMessage crafts a new message with a new ID The current message contents are replaced with `data`
type FilterFunc ¶
FilterFunc type to define a conditional handler returns false in the second return value if the handler is not concerned about the event
func IsolateNode ¶ added in v0.2.3
func IsolateNode(replica types.ReplicaID) FilterFunc
func NewStateMachineHandler ¶
func NewStateMachineHandler(stateMachine *sm.StateMachine) FilterFunc
NewStateMachineHandler returns a HandlerFunc that encodes the execution logic of the StateMachine For every invocation of the handler, internal a state machine step is executed which may or may not transition. If the StateMachine transitions to FailureState, the handler aborts the test case
type FilterSet ¶
type FilterSet struct {
Filters []FilterFunc
DefaultFilter FilterFunc
// contains filtered or unexported fields
}
FilterSet implements Handler Executes handlers in the specified order until the event is handled If no handler handles the event then the default handler is called
func NewFilterSet ¶
func NewFilterSet(opts ...FilterSetOption) *FilterSet
NewFilterSet creates a new cascade handler with the specified state machine and options
func (*FilterSet) AddFilter ¶
func (c *FilterSet) AddFilter(h FilterFunc)
AddFilter adds a handler to the cascade
func (*FilterSet) Stats ¶ added in v0.2.7
func (c *FilterSet) Stats() *FilterSetStats
type FilterSetOption ¶
type FilterSetOption func(*FilterSet)
FilterSetOption changes the parameters of the HandlerCascade
func WithDefault ¶
func WithDefault(d FilterFunc) FilterSetOption
WithDefault changes the HandlerCascade default handler
type FilterSetStats ¶ added in v0.2.7
type FilterSetStats struct {
// contains filtered or unexported fields
}
func (*FilterSetStats) MarshalJSON ¶ added in v0.2.7
func (s *FilterSetStats) MarshalJSON() ([]byte, error)
func (*FilterSetStats) String ¶ added in v0.2.7
func (s *FilterSetStats) String() string
type IfThenHandler ¶
type IfThenHandler struct {
// contains filtered or unexported fields
}
IfThenHandler struct is used to wrap the attributes of the `If().Then()` handler
func If ¶
func If(cond sm.Condition) *IfThenHandler
If creates a IfThenHandler with the specified condition
func (*IfThenHandler) Then ¶
func (i *IfThenHandler) Then(action Action, rest ...Action) FilterFunc
Then returns a HandlerFunc which encodes the `If().Then()` semantics. Accepts actions as arguments
type Partition ¶ added in v0.2.1
type Partition struct {
// contains filtered or unexported fields
}
func NewRandomPartition ¶ added in v0.2.2
func (*Partition) GetPartLabel ¶ added in v0.2.1
type TestCase ¶
type TestCase struct {
// Name name of the testcase
Name string
// Timeout maximum duration of the testcase execution
Timeout time.Duration
// Setup function called prior to initiation of the execution
Setup func(*Context) error
// Cascade instance of *HandlerCascade
Cascade *FilterSet
// StateMachine instance of *StateMachine to assert a property
StateMachine *sm.StateMachine
// Logger to log information
Logger *log.Logger
// contains filtered or unexported fields
}
TestCase represents a unit test case
func NewTestCase ¶
func NewTestCase(name string, timeout time.Duration, sm *sm.StateMachine, cascade *FilterSet) *TestCase
NewTestCase instantiates a TestCase based on the parameters specified The new testcase has three states by default. - Start state where the execution starts from - Fail state that can be used to fail the testcase - Success state that can be used to indicate a success of the testcase
type TestCaseDriver ¶ added in v0.1.1
type TestCaseDriver struct {
TestCase *TestCase
// contains filtered or unexported fields
}
func NewTestDriver ¶ added in v0.1.1
func NewTestDriver(ctx *context.RootContext, testcase *TestCase) *TestCaseDriver
type TestingServer ¶
type TestingServer struct {
*types.BaseService
// contains filtered or unexported fields
}
TestingServer is used to run the scheduler tool for unit testing
func NewTestingServer ¶
func NewTestingServer(config *config.Config, messageParser types.MessageParser, testcases []*TestCase) (*TestingServer, error)
NewTestingServer instantiates TestingServer testcases are passed as arguments
func (*TestingServer) Done ¶
func (srv *TestingServer) Done() chan string
Done returns the channel which will be closed once all testcases are run
func (*TestingServer) Name ¶
func (srv *TestingServer) Name() string
Name implements DashboardRouter
func (*TestingServer) SetupRouter ¶
func (srv *TestingServer) SetupRouter(router *gin.RouterGroup)
SetupRouter for setting up the dashboard routes implements DashboardRouter
func (*TestingServer) Start ¶
func (srv *TestingServer) Start()
Start starts the TestingServer and implements Service
func (*TestingServer) Stop ¶
func (srv *TestingServer) Stop()
Stop stops the TestingServer and implements Service