tests

package
v0.0.0-...-a582c34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasStack

func HasStack(err error) bool

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.

func NewKVTest

func NewKVTest(clusterID uint64, nodeID uint64) sm.IStateMachine

NewKVTest 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.

func (*ConcurrentKVTest) Update

func (s *ConcurrentKVTest) Update(ents []sm.Entry) ([]sm.Entry, error)

Update updates the object using the specified committed raft entry.

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.

func (*ConcurrentSnapshot) Update

func (c *ConcurrentSnapshot) Update(entries []sm.Entry) ([]sm.Entry, error)

Update updates the state machine.

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.

func (*ConcurrentUpdate) Update

func (c *ConcurrentUpdate) Update(entries []sm.Entry) ([]sm.Entry, error)

Update updates the state machine.

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) Aborted

func (f *FakeDiskSM) Aborted() bool

Aborted ...

func (*FakeDiskSM) ClearAborted

func (f *FakeDiskSM) ClearAborted()

ClearAborted ...

func (*FakeDiskSM) Close

func (f *FakeDiskSM) Close() error

Close closes the state machine.

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, 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) Recovered

func (f *FakeDiskSM) Recovered() bool

Recovered ...

func (*FakeDiskSM) SaveSnapshot

func (f *FakeDiskSM) SaveSnapshot(ctx interface{},
	w io.Writer, stopc <-chan struct{}) error

SaveSnapshot saves the state to a snapshot.

func (*FakeDiskSM) SetAborted

func (f *FakeDiskSM) SetAborted()

SetAborted ...

func (*FakeDiskSM) Sync

func (f *FakeDiskSM) Sync() error

Sync synchronize all in-core state.

func (*FakeDiskSM) Update

func (f *FakeDiskSM) Update(ents []sm.Entry) ([]sm.Entry, error)

Update updates the state machine.

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) Close

func (s *KVTest) Close() error

Close closes the IStateMachine instance

func (*KVTest) DisableLargeDelay

func (s *KVTest) DisableLargeDelay()

DisableLargeDelay disables random large delays.

func (*KVTest) GetHash

func (s *KVTest) GetHash() (uint64, error)

GetHash returns a uint64 representing the current object state.

func (*KVTest) Lookup

func (s *KVTest) Lookup(key interface{}) (interface{}, error)

Lookup performances local looks up for the sepcified data.

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.

func (*KVTest) Update

func (s *KVTest) Update(data []byte) (sm.Result, error)

Update updates the object using the specified committed raft entry.

type NoOP

type NoOP struct {
	MillisecondToSleep uint64
	NoAlloc            bool
}

NoOP is a IStateMachine struct used for testing purpose.

func (*NoOP) Close

func (n *NoOP) Close() error

Close closes the NoOP IStateMachine.

func (*NoOP) GetHash

func (n *NoOP) GetHash() (uint64, error)

GetHash returns a uint64 value representing the current state of the object.

func (*NoOP) Lookup

func (n *NoOP) Lookup(key interface{}) (interface{}, error)

Lookup locally looks up the data.

func (*NoOP) NALookup

func (n *NoOP) NALookup(key []byte) ([]byte, error)

NALookup locally looks up the data.

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

func (n *NoOP) SetSleepTime(v uint64)

SetSleepTime sets the sleep time of the state machine.

func (*NoOP) Update

func (n *NoOP) Update(data []byte) (sm.Result, error)

Update updates the object.

type SimDiskSM

type SimDiskSM struct {
	// contains filtered or unexported fields
}

SimDiskSM is a fake disk based state machine used for testing purposes

func NewSimDiskSM

func NewSimDiskSM(applied uint64) *SimDiskSM

NewSimDiskSM ...

func (*SimDiskSM) Close

func (s *SimDiskSM) Close() error

Close ...

func (*SimDiskSM) GetApplied

func (s *SimDiskSM) GetApplied() uint64

GetApplied ...

func (*SimDiskSM) GetRecovered

func (s *SimDiskSM) GetRecovered() uint64

GetRecovered ...

func (*SimDiskSM) Lookup

func (s *SimDiskSM) Lookup(query interface{}) (interface{}, error)

Lookup ...

func (*SimDiskSM) Open

func (s *SimDiskSM) Open(stopc <-chan struct{}) (uint64, error)

Open ...

func (*SimDiskSM) PrepareSnapshot

func (s *SimDiskSM) PrepareSnapshot() (interface{}, error)

PrepareSnapshot ...

func (*SimDiskSM) RecoverFromSnapshot

func (s *SimDiskSM) RecoverFromSnapshot(r io.Reader,
	stopc <-chan struct{}) error

RecoverFromSnapshot ...

func (*SimDiskSM) SaveSnapshot

func (s *SimDiskSM) SaveSnapshot(ctx interface{},
	w io.Writer, stopc <-chan struct{}) error

SaveSnapshot ...

func (*SimDiskSM) Sync

func (s *SimDiskSM) Sync() error

Sync ...

func (*SimDiskSM) Update

func (s *SimDiskSM) Update(ents []sm.Entry) ([]sm.Entry, error)

Update ...

type TestSnapshot

type TestSnapshot struct {
	// contains filtered or unexported fields
}

TestSnapshot is a IConcurrentStateMachine used for testing purposes.

func (*TestSnapshot) Close

func (c *TestSnapshot) Close() error

Close closes the state machine.

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.

func (*TestSnapshot) Update

func (c *TestSnapshot) Update(data []byte) (sm.Result, error)

Update updates the state machine.

type TestUpdate

type TestUpdate struct {
	// contains filtered or unexported fields
}

TestUpdate is a IStateMachine used for testing purposes.

func (*TestUpdate) Close

func (c *TestUpdate) Close() error

Close closes the state machine.

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.

func (*TestUpdate) Update

func (c *TestUpdate) Update(data []byte) (sm.Result, error)

Update updates the state machine.

type VerboseSnapshotSM

type VerboseSnapshotSM struct {
	// contains filtered or unexported fields
}

VerboseSnapshotSM ...

func (*VerboseSnapshotSM) Close

func (v *VerboseSnapshotSM) Close() error

Close ...

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 ...

func (*VerboseSnapshotSM) Update

func (v *VerboseSnapshotSM) Update(data []byte) (sm.Result, error)

Update ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL