Documentation ¶
Index ¶
Constants ¶
const ( // BaseListenPort defines the starting port number on which test replicas will be listening // in case the test is being run with the "grpc" setting for networking. // A node with numeric ID id will listen on port (BaseListenPort + id) BaseListenPort = 10000 // RequestListenPort is the port number on which nodes' RequestReceivers listen for incoming requests. RequestListenPort = 20000 )
Variables ¶
var (
FakeClientHasher modules.Hasher = crypto.SHA256
)
Functions ¶
Types ¶
type Deployment ¶
type Deployment struct { // The fake transport layer is only used if the deployment is configured to use it // by setting testConfig.Net to "fake". // Otherwise, the fake transport might be created, but will not be used. FakeTransport *FakeTransport // The replicas of the deployment. TestReplicas []*TestReplica // Dummy clients to submit requests to replicas over the (local loopback) network. Clients []*dummyclient.DummyClient // contains filtered or unexported fields }
The Deployment represents a list of replicas interconnected by a simulated network transport.
func NewDeployment ¶
func NewDeployment(testConfig *TestConfig) (*Deployment, error)
NewDeployment returns a Deployment initialized according to the passed configuration.
func (*Deployment) Run ¶
func (d *Deployment) Run(tickInterval time.Duration, stopC <-chan struct{}) []NodeStatus
Run launches the test deployment. It starts all test replicas, the dummy client, and the fake message transport subsystem, waits until the replicas stop, and returns the final statuses of all the replicas. Closing the passed stopC channel makes the deployment terminate by signaling all those subsystems to stop gracefully.
type FakeApp ¶
type FakeApp struct { // The state of the FakeApp only consists of a counter of processed requests. RequestsProcessed uint64 }
FakeApp represents a dummy stub application used for testing only.
func (*FakeApp) RestoreState ¶
type FakeLink ¶
type FakeLink struct { FakeTransport *FakeTransport Source t.NodeID }
func (*FakeLink) ReceiveChan ¶
func (fl *FakeLink) ReceiveChan() <-chan modules.ReceivedMessage
type FakeTransport ¶
type FakeTransport struct { // Buffers is source x dest Buffers [][]chan *messagepb.Message NodeSinks []chan modules.ReceivedMessage WaitGroup sync.WaitGroup DoneC chan struct{} }
func NewFakeTransport ¶
func NewFakeTransport(nodes int) *FakeTransport
func (*FakeTransport) RecvC ¶
func (ft *FakeTransport) RecvC(dest t.NodeID) <-chan modules.ReceivedMessage
func (*FakeTransport) Send ¶
func (ft *FakeTransport) Send(source, dest t.NodeID, msg *messagepb.Message)
func (*FakeTransport) Start ¶
func (ft *FakeTransport) Start()
func (*FakeTransport) Stop ¶
func (ft *FakeTransport) Stop()
type NodeStatus ¶
type NodeStatus struct { // Status as returned by mirbft.Node.Status() Status *statuspb.NodeStatus // Potential error returned by mirbft.Node.Status() in case of obtaining of the status failed. StatusErr error // Reason the node terminated, as returned by mirbft.Node.Run() ExitErr error }
NodeStatus represents the final status of a test replica.
type TestConfig ¶
type TestConfig struct { // Number of replicas in the tested deployment. NumReplicas int // Number of clients in the tested deployment. NumClients int // Type of networking to use. // Current possible values: "fake", "grpc" Transport string // The number of requests each client submits during the execution of the deployment. NumFakeRequests int // The number of requests sent over the network (by a single DummyClient) NumNetRequests int // Directory where all the test-related files will be stored. // If empty, an OS-default temporary directory will be used. Directory string // Duration after which the test deployment will be asked to shut down. Duration time.Duration }
TestConfig contains the parameters of the deployment to be tested.
type TestReplica ¶
type TestReplica struct { // ID of the replica as seen by the protocol. Id t.NodeID // Dummy test application the replica is running. App *FakeApp // Name of the directory where the persisted state of this TestReplica will be stored, // along with the logs produced by running the replica. Dir string // Configuration of the node corresponding to this replica. Config *mirbft.NodeConfig // List of replica IDs constituting the (static) membership. Membership []t.NodeID // List of IDs of all clients the replica will accept requests from. ClientIDs []t.ClientID // Network transport subsystem. Net modules.Net // Number of simulated requests inserted in the test replica by a hypothetical client. NumFakeRequests int // Configuration of the ISS protocol, if used. If set to nil, the default ISS configuration is assumed. ISSConfig *iss.Config }
TestReplica represents one replica (that uses one instance of the mirbft.Node) in the test system.
func (*TestReplica) EventLogFile ¶
func (tr *TestReplica) EventLogFile() string
EventLogFile returns the name of the file where the replica's event log is stored.
func (*TestReplica) Run ¶
func (tr *TestReplica) Run(tickInterval time.Duration, stopC <-chan struct{}) NodeStatus
Run initializes all the required modules and starts the test replica. The function blocks until the replica stops. The replica stops when stopC is closed. Run returns, in this order
- The final status of the replica
- The error that made the node terminate
- The error that occurred while obtaining the final node status