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 HasStack(err error) bool
- func NewConcurrentKVTest(clusterID uint64, nodeID uint64) sm.IConcurrentStateMachine
- func NewKVTest(clusterID uint64, nodeID uint64) sm.IStateMachine
- type ConcurrentKVTest
- func (s *ConcurrentKVTest) Close() error
- func (s *ConcurrentKVTest) GetHash() (uint64, error)
- func (s *ConcurrentKVTest) Lookup(key interface{}) (interface{}, error)
- func (s *ConcurrentKVTest) PrepareSnapshot() (interface{}, error)
- func (s *ConcurrentKVTest) RecoverFromSnapshot(r io.Reader, files []sm.SnapshotFile, done <-chan struct{}) error
- func (s *ConcurrentKVTest) SaveSnapshot(ctx interface{}, w io.Writer, fileCollection sm.ISnapshotFileCollection, ...) error
- func (s *ConcurrentKVTest) Update(ents []sm.Entry) ([]sm.Entry, error)
- type ConcurrentSnapshot
- func (c *ConcurrentSnapshot) Close() error
- func (c *ConcurrentSnapshot) GetHash() (uint64, error)
- func (c *ConcurrentSnapshot) Lookup(query interface{}) (interface{}, error)
- func (c *ConcurrentSnapshot) PrepareSnapshot() (interface{}, error)
- func (c *ConcurrentSnapshot) RecoverFromSnapshot(r io.Reader, files []sm.SnapshotFile, stopc <-chan struct{}) error
- func (c *ConcurrentSnapshot) SaveSnapshot(ctx interface{}, w io.Writer, fc sm.ISnapshotFileCollection, ...) error
- func (c *ConcurrentSnapshot) Update(entries []sm.Entry) ([]sm.Entry, error)
- type ConcurrentUpdate
- func (c *ConcurrentUpdate) Close() error
- func (c *ConcurrentUpdate) GetHash() (uint64, error)
- func (c *ConcurrentUpdate) Lookup(query interface{}) (interface{}, error)
- func (c *ConcurrentUpdate) PrepareSnapshot() (interface{}, error)
- func (c *ConcurrentUpdate) RecoverFromSnapshot(r io.Reader, files []sm.SnapshotFile, stopc <-chan struct{}) error
- func (c *ConcurrentUpdate) SaveSnapshot(ctx interface{}, w io.Writer, fc sm.ISnapshotFileCollection, ...) error
- func (c *ConcurrentUpdate) Update(entries []sm.Entry) ([]sm.Entry, error)
- type FakeDiskSM
- func (f *FakeDiskSM) Aborted() bool
- func (f *FakeDiskSM) ClearAborted()
- func (f *FakeDiskSM) Close() error
- func (f *FakeDiskSM) GetHash() (uint64, error)
- func (f *FakeDiskSM) Lookup(query interface{}) (interface{}, error)
- func (f *FakeDiskSM) Open(stopc <-chan struct{}) (uint64, uint64, error)
- func (f *FakeDiskSM) PrepareSnapshot() (interface{}, error)
- func (f *FakeDiskSM) RecoverFromSnapshot(r io.Reader, stopc <-chan struct{}) error
- func (f *FakeDiskSM) Recovered() bool
- func (f *FakeDiskSM) SaveSnapshot(ctx interface{}, w io.Writer, stopc <-chan struct{}) error
- func (f *FakeDiskSM) SetAborted()
- func (f *FakeDiskSM) Sync() error
- func (f *FakeDiskSM) Update(ents []sm.Entry) ([]sm.Entry, error)
- type KVJson
- type KVTest
- func (s *KVTest) Close() error
- func (s *KVTest) DisableLargeDelay()
- func (s *KVTest) GetHash() (uint64, error)
- func (s *KVTest) Lookup(key interface{}) (interface{}, error)
- func (s *KVTest) RecoverFromSnapshot(r io.Reader, files []sm.SnapshotFile, done <-chan struct{}) error
- func (s *KVTest) SaveSnapshot(w io.Writer, fileCollection sm.ISnapshotFileCollection, done <-chan struct{}) error
- func (s *KVTest) Update(data []byte) (sm.Result, error)
- type NoOP
- func (n *NoOP) Close() error
- func (n *NoOP) GetHash() (uint64, error)
- func (n *NoOP) Lookup(key interface{}) (interface{}, error)
- func (n *NoOP) NALookup(key []byte) ([]byte, error)
- func (n *NoOP) RecoverFromSnapshot(r io.Reader, files []sm.SnapshotFile, done <-chan struct{}) error
- func (n *NoOP) SaveSnapshot(w io.Writer, fileCollection sm.ISnapshotFileCollection, done <-chan struct{}) error
- func (n *NoOP) SetSleepTime(v uint64)
- func (n *NoOP) Update(data []byte) (sm.Result, error)
- type SimDiskSM
- func (s *SimDiskSM) Close() error
- func (s *SimDiskSM) GetApplied() uint64
- func (s *SimDiskSM) GetRecovered() uint64
- func (s *SimDiskSM) Lookup(query interface{}) (interface{}, error)
- func (s *SimDiskSM) Open(stopc <-chan struct{}) (uint64, uint64, error)
- func (s *SimDiskSM) PrepareSnapshot() (interface{}, error)
- func (s *SimDiskSM) RecoverFromSnapshot(r io.Reader, stopc <-chan struct{}) error
- func (s *SimDiskSM) SaveSnapshot(ctx interface{}, w io.Writer, stopc <-chan struct{}) error
- func (s *SimDiskSM) Sync() error
- func (s *SimDiskSM) Update(ents []sm.Entry) ([]sm.Entry, error)
- type TestSnapshot
- func (c *TestSnapshot) Close() error
- func (c *TestSnapshot) GetHash() (uint64, error)
- func (c *TestSnapshot) Lookup(query interface{}) (interface{}, error)
- func (c *TestSnapshot) RecoverFromSnapshot(r io.Reader, files []sm.SnapshotFile, stopc <-chan struct{}) error
- func (c *TestSnapshot) SaveSnapshot(w io.Writer, fc sm.ISnapshotFileCollection, stopc <-chan struct{}) error
- func (c *TestSnapshot) Update(data []byte) (sm.Result, error)
- type TestUpdate
- func (c *TestUpdate) Close() error
- func (c *TestUpdate) GetHash() (uint64, error)
- func (c *TestUpdate) Lookup(query interface{}) (interface{}, error)
- func (c *TestUpdate) RecoverFromSnapshot(r io.Reader, files []sm.SnapshotFile, stopc <-chan struct{}) error
- func (c *TestUpdate) SaveSnapshot(w io.Writer, fc sm.ISnapshotFileCollection, stopc <-chan struct{}) error
- func (c *TestUpdate) Update(data []byte) (sm.Result, error)
- type VerboseSnapshotSM
- func (v *VerboseSnapshotSM) Close() error
- func (v *VerboseSnapshotSM) Lookup(q interface{}) (interface{}, error)
- func (v *VerboseSnapshotSM) RecoverFromSnapshot(r io.Reader, collection []sm.SnapshotFile, stopc <-chan struct{}) error
- func (v *VerboseSnapshotSM) SaveSnapshot(w io.Writer, collection sm.ISnapshotFileCollection, stopc <-chan struct{}) error
- func (v *VerboseSnapshotSM) Update(data []byte) (sm.Result, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasStack ¶
HasStack returns a boolean value indicating whether the specified error has stacktrace attached to it.
func NewConcurrentKVTest ¶
func NewConcurrentKVTest(clusterID uint64, nodeID uint64) sm.IConcurrentStateMachine
NewConcurrentKVTest creates and return a new KVTest object.
Types ¶
type ConcurrentKVTest ¶
type ConcurrentKVTest struct { ClusterID uint64 NodeID uint64 // contains filtered or unexported fields }
ConcurrentKVTest 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 (*ConcurrentKVTest) Close ¶
func (s *ConcurrentKVTest) Close() error
Close closes the IStateMachine instance
func (*ConcurrentKVTest) GetHash ¶
func (s *ConcurrentKVTest) GetHash() (uint64, error)
GetHash returns a uint64 representing the current object state.
func (*ConcurrentKVTest) Lookup ¶
func (s *ConcurrentKVTest) Lookup(key interface{}) (interface{}, error)
Lookup performances local looks up for the sepcified data.
func (*ConcurrentKVTest) PrepareSnapshot ¶
func (s *ConcurrentKVTest) PrepareSnapshot() (interface{}, error)
PrepareSnapshot makes preparations for taking concurrent snapshot.
func (*ConcurrentKVTest) RecoverFromSnapshot ¶
func (s *ConcurrentKVTest) RecoverFromSnapshot(r io.Reader, files []sm.SnapshotFile, done <-chan struct{}) error
RecoverFromSnapshot recovers the state using the provided snapshot.
func (*ConcurrentKVTest) SaveSnapshot ¶
func (s *ConcurrentKVTest) SaveSnapshot(ctx interface{}, w io.Writer, fileCollection sm.ISnapshotFileCollection, done <-chan struct{}) error
SaveSnapshot saves the current object state into a snapshot using the specified io.Writer object.
type ConcurrentSnapshot ¶
type ConcurrentSnapshot struct {
// contains filtered or unexported fields
}
ConcurrentSnapshot is a IConcurrentStateMachine used for testing purposes.
func (*ConcurrentSnapshot) Close ¶
func (c *ConcurrentSnapshot) Close() error
Close closes the state machine.
func (*ConcurrentSnapshot) GetHash ¶
func (c *ConcurrentSnapshot) GetHash() (uint64, error)
GetHash returns the uint64 hash value representing the state of a state machine.
func (*ConcurrentSnapshot) Lookup ¶
func (c *ConcurrentSnapshot) Lookup(query interface{}) (interface{}, error)
Lookup queries the state machine.
func (*ConcurrentSnapshot) PrepareSnapshot ¶
func (c *ConcurrentSnapshot) PrepareSnapshot() (interface{}, error)
PrepareSnapshot makes preparations for taking concurrent snapshot.
func (*ConcurrentSnapshot) RecoverFromSnapshot ¶
func (c *ConcurrentSnapshot) RecoverFromSnapshot(r io.Reader, files []sm.SnapshotFile, stopc <-chan struct{}) error
RecoverFromSnapshot recovers the state machine from a snapshot.
func (*ConcurrentSnapshot) SaveSnapshot ¶
func (c *ConcurrentSnapshot) SaveSnapshot(ctx interface{}, w io.Writer, fc sm.ISnapshotFileCollection, stopc <-chan struct{}) error
SaveSnapshot saves the snapshot.
type ConcurrentUpdate ¶
type ConcurrentUpdate struct { UpdateCount int // contains filtered or unexported fields }
ConcurrentUpdate is a IConcurrentStateMachine used for testing purposes.
func (*ConcurrentUpdate) Close ¶
func (c *ConcurrentUpdate) Close() error
Close closes the state machine.
func (*ConcurrentUpdate) GetHash ¶
func (c *ConcurrentUpdate) GetHash() (uint64, error)
GetHash returns the uint64 hash value representing the state of a state machine.
func (*ConcurrentUpdate) Lookup ¶
func (c *ConcurrentUpdate) Lookup(query interface{}) (interface{}, error)
Lookup queries the state machine.
func (*ConcurrentUpdate) PrepareSnapshot ¶
func (c *ConcurrentUpdate) PrepareSnapshot() (interface{}, error)
PrepareSnapshot makes preparations for taking concurrent snapshot.
func (*ConcurrentUpdate) RecoverFromSnapshot ¶
func (c *ConcurrentUpdate) RecoverFromSnapshot(r io.Reader, files []sm.SnapshotFile, stopc <-chan struct{}) error
RecoverFromSnapshot recovers the state machine from a snapshot.
func (*ConcurrentUpdate) SaveSnapshot ¶
func (c *ConcurrentUpdate) SaveSnapshot(ctx interface{}, w io.Writer, fc sm.ISnapshotFileCollection, stopc <-chan struct{}) error
SaveSnapshot saves the snapshot.
type FakeDiskSM ¶
type FakeDiskSM struct { SlowOpen uint32 // contains filtered or unexported fields }
FakeDiskSM is a test state machine.
func NewFakeDiskSM ¶
func NewFakeDiskSM(initialApplied uint64) *FakeDiskSM
NewFakeDiskSM creates a new fake disk sm for testing purpose.
func (*FakeDiskSM) GetHash ¶
func (f *FakeDiskSM) GetHash() (uint64, error)
GetHash returns the hash of the state.
func (*FakeDiskSM) Lookup ¶
func (f *FakeDiskSM) Lookup(query interface{}) (interface{}, error)
Lookup queries the state machine.
func (*FakeDiskSM) Open ¶
func (f *FakeDiskSM) Open(stopc <-chan struct{}) (uint64, uint64, error)
Open opens the state machine.
func (*FakeDiskSM) PrepareSnapshot ¶
func (f *FakeDiskSM) PrepareSnapshot() (interface{}, error)
PrepareSnapshot prepares snapshotting.
func (*FakeDiskSM) RecoverFromSnapshot ¶
func (f *FakeDiskSM) RecoverFromSnapshot(r io.Reader, stopc <-chan struct{}) error
RecoverFromSnapshot recovers the state of the state machine from a snapshot.
func (*FakeDiskSM) SaveSnapshot ¶
func (f *FakeDiskSM) SaveSnapshot(ctx interface{}, w io.Writer, stopc <-chan struct{}) error
SaveSnapshot saves the state to a snapshot.
type KVJson ¶
type KVJson struct { KVStore map[string]string `json:"KVStore"` Count uint64 `json:"Count"` Junk []byte `json:"Junk"` }
KVJson is an util struct for serializing and deserializing data.
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) DisableLargeDelay ¶
func (s *KVTest) DisableLargeDelay()
DisableLargeDelay disables random large delays.
func (*KVTest) RecoverFromSnapshot ¶
func (s *KVTest) RecoverFromSnapshot(r io.Reader, files []sm.SnapshotFile, done <-chan struct{}) error
RecoverFromSnapshot recovers the state using the provided snapshot.
func (*KVTest) SaveSnapshot ¶
func (s *KVTest) SaveSnapshot(w io.Writer, fileCollection sm.ISnapshotFileCollection, done <-chan struct{}) error
SaveSnapshot saves the current object state into a snapshot using the specified io.Writer object.
type NoOP ¶
NoOP is a IStateMachine struct used for testing purpose.
func (*NoOP) RecoverFromSnapshot ¶
func (n *NoOP) RecoverFromSnapshot(r io.Reader, files []sm.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 sm.ISnapshotFileCollection, done <-chan struct{}) error
SaveSnapshot saves the state of the object to the provided io.Writer object.
func (*NoOP) SetSleepTime ¶
SetSleepTime sets the sleep time of the state machine.
type SimDiskSM ¶
type SimDiskSM struct {
// contains filtered or unexported fields
}
SimDiskSM is a fake disk based state machine used for testing purposes
func (*SimDiskSM) PrepareSnapshot ¶
PrepareSnapshot ...
func (*SimDiskSM) RecoverFromSnapshot ¶
RecoverFromSnapshot ...
func (*SimDiskSM) SaveSnapshot ¶
SaveSnapshot ...
type TestSnapshot ¶
type TestSnapshot struct {
// contains filtered or unexported fields
}
TestSnapshot is a IConcurrentStateMachine used for testing purposes.
func (*TestSnapshot) GetHash ¶
func (c *TestSnapshot) GetHash() (uint64, error)
GetHash returns the uint64 hash value representing the state of a state machine.
func (*TestSnapshot) Lookup ¶
func (c *TestSnapshot) Lookup(query interface{}) (interface{}, error)
Lookup queries the state machine.
func (*TestSnapshot) RecoverFromSnapshot ¶
func (c *TestSnapshot) RecoverFromSnapshot(r io.Reader, files []sm.SnapshotFile, stopc <-chan struct{}) error
RecoverFromSnapshot recovers the state machine from a snapshot.
func (*TestSnapshot) SaveSnapshot ¶
func (c *TestSnapshot) SaveSnapshot(w io.Writer, fc sm.ISnapshotFileCollection, stopc <-chan struct{}) error
SaveSnapshot saves the snapshot.
type TestUpdate ¶
type TestUpdate struct {
// contains filtered or unexported fields
}
TestUpdate is a IStateMachine used for testing purposes.
func (*TestUpdate) GetHash ¶
func (c *TestUpdate) GetHash() (uint64, error)
GetHash returns the uint64 hash value representing the state of a state machine.
func (*TestUpdate) Lookup ¶
func (c *TestUpdate) Lookup(query interface{}) (interface{}, error)
Lookup queries the state machine.
func (*TestUpdate) RecoverFromSnapshot ¶
func (c *TestUpdate) RecoverFromSnapshot(r io.Reader, files []sm.SnapshotFile, stopc <-chan struct{}) error
RecoverFromSnapshot recovers the state machine from a snapshot.
func (*TestUpdate) SaveSnapshot ¶
func (c *TestUpdate) SaveSnapshot(w io.Writer, fc sm.ISnapshotFileCollection, stopc <-chan struct{}) error
SaveSnapshot saves the snapshot.
type VerboseSnapshotSM ¶
type VerboseSnapshotSM struct {
// contains filtered or unexported fields
}
VerboseSnapshotSM ...
func (*VerboseSnapshotSM) Lookup ¶
func (v *VerboseSnapshotSM) Lookup(q interface{}) (interface{}, error)
Lookup ...
func (*VerboseSnapshotSM) RecoverFromSnapshot ¶
func (v *VerboseSnapshotSM) RecoverFromSnapshot(r io.Reader, collection []sm.SnapshotFile, stopc <-chan struct{}) error
RecoverFromSnapshot ...
func (*VerboseSnapshotSM) SaveSnapshot ¶
func (v *VerboseSnapshotSM) SaveSnapshot(w io.Writer, collection sm.ISnapshotFileCollection, stopc <-chan struct{}) error
SaveSnapshot ...