tests

package
v0.0.0-...-bb37015 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2019 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 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) statemachine.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()

Close closes the IStateMachine instance

func (*ConcurrentKVTest) GetHash

func (s *ConcurrentKVTest) GetHash() uint64

GetHash returns a uint64 representing the current object state.

func (*ConcurrentKVTest) Lookup

func (s *ConcurrentKVTest) Lookup(key []byte) ([]byte, 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{}) (uint64, 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

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

Close closes the state machine.

func (*ConcurrentSnapshot) GetHash

func (c *ConcurrentSnapshot) GetHash() uint64

GetHash returns the uint64 hash value representing the state of a state machine.

func (*ConcurrentSnapshot) Lookup

func (c *ConcurrentSnapshot) Lookup(query []byte) ([]byte, 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{}) (uint64, error)

SaveSnapshot saves the snapshot.

func (*ConcurrentSnapshot) Update

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

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

Close closes the state machine.

func (*ConcurrentUpdate) GetHash

func (c *ConcurrentUpdate) GetHash() uint64

GetHash returns the uint64 hash value representing the state of a state machine.

func (*ConcurrentUpdate) Lookup

func (c *ConcurrentUpdate) Lookup(query []byte) ([]byte, 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{}) (uint64, error)

SaveSnapshot saves the snapshot.

func (*ConcurrentUpdate) Update

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

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

Close closes the IStateMachine instance

func (*KVTest) GetHash

func (s *KVTest) GetHash() uint64

GetHash returns a uint64 representing the current object state.

func (*KVTest) Lookup

func (s *KVTest) Lookup(key []byte) []byte

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.

func (*KVTest) Update

func (s *KVTest) Update(data []byte) uint64

Update updates the object using the specified committed raft entry.

type NoOP

type NoOP struct {
	MillisecondToSleep uint64
}

NoOP is a IStateMachine struct used for testing purpose.

func (*NoOP) Close

func (n *NoOP) Close()

Close closes the NoOP IStateMachine.

func (*NoOP) GetHash

func (n *NoOP) GetHash() uint64

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

func (*NoOP) Lookup

func (n *NoOP) Lookup(key []byte) []byte

Lookup locally looks up the data.

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.

func (*NoOP) Update

func (n *NoOP) Update(data []byte) uint64

Update updates the object.

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

Close closes the state machine.

func (*TestSnapshot) GetHash

func (c *TestSnapshot) GetHash() uint64

GetHash returns the uint64 hash value representing the state of a state machine.

func (*TestSnapshot) Lookup

func (c *TestSnapshot) Lookup(query []byte) []byte

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{}) (uint64, error)

SaveSnapshot saves the snapshot.

func (*TestSnapshot) Update

func (c *TestSnapshot) Update(data []byte) uint64

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

Close closes the state machine.

func (*TestUpdate) GetHash

func (c *TestUpdate) GetHash() uint64

GetHash returns the uint64 hash value representing the state of a state machine.

func (*TestUpdate) Lookup

func (c *TestUpdate) Lookup(query []byte) []byte

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{}) (uint64, error)

SaveSnapshot saves the snapshot.

func (*TestUpdate) Update

func (c *TestUpdate) Update(data []byte) uint64

Update updates the state machine.

Directories

Path Synopsis
charybdefs
concurrentkv is IConcurrentStateMachine plugin used in various tests.
concurrentkv is IConcurrentStateMachine plugin used in various tests.
kvtest is IStateMachine plugin used in various tests.
kvtest is IStateMachine plugin used in various tests.
lcm
Package lcm is a linearizable checker manager.
Package lcm is a linearizable checker manager.

Jump to

Keyboard shortcuts

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