A scenario test allows developer to describe a specific scenario that should occur in the distributed system and test specific property for the scenario. Here is an example scenario test:
// MsgApp from a leader would mean election succeeded — failure condition.
sm := netrix.NewStateMachine()
sm.Builder().On(netrix.IsMessageType(pb.MsgApp), netrix.FailureState)
filters := netrix.NewFilterSet()
filters.AddFilter(netrix.If(netrix.IsMessageType(pb.MsgVote)).Then(netrix.DropMessage()))
filters.AddFilter(netrix.If(netrix.IsMessageType(pb.MsgVoteResp)).Then(netrix.DropMessage()))
...
result := runNetrixTest(t, tc, envFunc)
require.NoError(t, result.Err)
require.False(t, result.IsFailure(), "no leader should be elected when all votes are dropped")
The test states a simple property and enforces a specific scenario in the execution of the distributed system - one where votes and their responses are never delivered and hence, no leader is ever elected. The test has two components, (1) The state machine, and (2) the filters. The state machine tracks the state of the test, derived either from messages sent or from the local state of the nodes in the distributed system. The filters decide which messages are delivered, dropped, duplicated, manipulated, or just observed. Together, they create a scenario and describe a property that needs to be satisfied.
The idea comes from a research paper - https://dl.acm.org/doi/10.1007/978-3-031-67321-4_6
A scenario test allows developer to describe a specific scenario that should occur in the distributed system and test specific property for the scenario. Here is an example scenario test:
The test states a simple property and enforces a specific scenario in the execution of the distributed system - one where votes and their responses are never delivered and hence, no leader is ever elected. The test has two components, (1) The state machine, and (2) the filters. The state machine tracks the state of the test, derived either from messages sent or from the local state of the nodes in the distributed system. The filters decide which messages are delivered, dropped, duplicated, manipulated, or just observed. Together, they create a scenario and describe a property that needs to be satisfied.
The idea comes from a research paper - https://dl.acm.org/doi/10.1007/978-3-031-67321-4_6