Documentation ¶
Overview ¶
Package tests contains various helper functions and modules used in tests.
This package is internally used by Dragonboat, applications are not expected to import this package.
Index ¶
- func NewKVTest(clusterID uint64, nodeID uint64) statemachine.IStateMachine
- type KVTest
- func (s *KVTest) Close()
- func (s *KVTest) GetHash() uint64
- func (s *KVTest) Lookup(key []byte) []byte
- func (s *KVTest) RecoverFromSnapshot(r io.Reader, files []statemachine.SnapshotFile, done <-chan struct{}) error
- func (s *KVTest) SaveSnapshot(w io.Writer, fileCollection statemachine.ISnapshotFileCollection, ...) (uint64, error)
- func (s *KVTest) Update(data []byte) uint64
- type NoOP
- func (n *NoOP) Close()
- func (n *NoOP) GetHash() uint64
- func (n *NoOP) Lookup(key []byte) []byte
- func (n *NoOP) RecoverFromSnapshot(r io.Reader, files []statemachine.SnapshotFile, done <-chan struct{}) error
- func (n *NoOP) SaveSnapshot(w io.Writer, fileCollection statemachine.ISnapshotFileCollection, ...) (uint64, error)
- func (n *NoOP) Update(data []byte) uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewKVTest ¶
func NewKVTest(clusterID uint64, nodeID uint64) statemachine.IStateMachine
NewKVTest creates and return a new KVTest object.
Types ¶
type KVTest ¶
type KVTest struct { ClusterID uint64 `json:"-"` NodeID uint64 `json:"-"` KVStore map[string]string `json:"KVStore"` Count uint64 `json:"Count"` Junk []byte `json:"Junk"` // contains filtered or unexported fields }
KVTest is a in memory key-value store struct used for testing purposes. Note that both key/value are suppose to be valid utf-8 strings.
func (*KVTest) GetHash ¶
GetHash returns a uint64 representing the current object state.
func (*KVTest) Lookup ¶
Lookup performances local looks up for the sepcified data.
func (*KVTest) RecoverFromSnapshot ¶
func (s *KVTest) RecoverFromSnapshot(r io.Reader, files []statemachine.SnapshotFile, done <-chan struct{}) error
RecoverFromSnapshot recovers the state using the provided snapshot.
func (*KVTest) SaveSnapshot ¶
func (s *KVTest) SaveSnapshot(w io.Writer, fileCollection statemachine.ISnapshotFileCollection, done <-chan struct{}) (uint64, error)
SaveSnapshot saves the current object state into a snapshot using the specified io.Writer object.
type NoOP ¶
type NoOP struct { }
NoOP is a IStateMachine struct used for testing purpose.
func (*NoOP) GetHash ¶
GetHash returns a uint64 value representing the current state of the object.
func (*NoOP) RecoverFromSnapshot ¶
func (n *NoOP) RecoverFromSnapshot(r io.Reader, files []statemachine.SnapshotFile, done <-chan struct{}) error
RecoverFromSnapshot recovers the object from the snapshot specified by the io.Reader object.
func (*NoOP) SaveSnapshot ¶
func (n *NoOP) SaveSnapshot(w io.Writer, fileCollection statemachine.ISnapshotFileCollection, done <-chan struct{}) (uint64, error)
SaveSnapshot saves the state of the object to the provided io.Writer object.