tests

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2019 License: Apache-2.0 Imports: 16 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 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) 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 {
}

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.

Directories

Path Synopsis
charybdefs
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