testutil

package
v0.14.5 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package testutil contains testing utilities for storage providers and backends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustAddObserver added in v0.8.0

func MustAddObserver(ctx context.Context, t *testing.T, leader, observer storage.Provider)

MustAddObserver is a helper function that adds an observer to the consensus group and fails the test if there is an error.

func MustAddVoter added in v0.8.0

func MustAddVoter(ctx context.Context, t *testing.T, leader, voter storage.Provider)

MustAddVoter is a helper function that adds a voter to the consensus group and fails the test if there is an error.

func MustBootstrapProvider added in v0.8.4

func MustBootstrapProvider(ctx context.Context, t *testing.T, provider storage.Provider)

MustBootstrapProvider is a helper function that calls Bootstrap and fails the test if there is an error.

func MustStartProvider added in v0.8.4

func MustStartProvider(ctx context.Context, t *testing.T, provider storage.Provider)

MustStartProvider is a helper function that calls Start and fails the test if there is an error.

func SkipOnCI added in v0.8.0

func SkipOnCI(t *testing.T, reason string)

SkipOnCI skips the test if the CI environment variable is set for the given reason.

func TestConsensusStorageConformance

func TestConsensusStorageConformance(ctx context.Context, t *testing.T, raftStorage storage.ConsensusStorage)

TestConsensusStorageConformance tests that the ConsensusStorage interface is implemented correctly.

func TestDualStorageConformance

func TestDualStorageConformance(ctx context.Context, t *testing.T, dualStorage storage.DualStorage)

TestDualStorageConformance tests that the DualStorage interface is implemented correctly.

func TestMeshDataStoreConformance added in v0.11.0

func TestMeshDataStoreConformance(t *testing.T, builder NewMeshDataStoreFunc)

TestMeshDataStoreConformance is a helper for running all database conformance tests against a MeshDataStore implementation.

func TestMeshStateStorageConformance added in v0.9.0

func TestMeshStateStorageConformance(t *testing.T, builder NewMeshStateFunc)

TestMeshStateStorageConformance tests that a MeshState implementation conforms to the interface.

func TestMeshStorageConformance

func TestMeshStorageConformance(ctx context.Context, t *testing.T, meshStorage storage.MeshStorage)

TestMeshStorageConformance tests that the MeshStorage interface is implemented correctly.

func TestNetworkingStorageConformance added in v0.9.0

func TestNetworkingStorageConformance(t *testing.T, builder NewNetworkingFunc)

TestNetworkingStorageConformance tests that a Networking implementation conforms to the interface.

func TestPeerGraphstoreConformance added in v0.9.0

func TestPeerGraphstoreConformance(t *testing.T, builder NewGraphStoreFunc)

TestPeerGraphstoreConformance tests that a PeerGraphStore implementation conforms to the interface.

func TestPeerStorageConformance added in v0.9.0

func TestPeerStorageConformance(t *testing.T, builder NewPeersFunc)

TestPeerStorageConformance tests that a Peers implementation conforms to the interface.

func TestRBACStorageConformance added in v0.9.0

func TestRBACStorageConformance(t *testing.T, builder NewRBACFunc)

TestRBACStorageConformance tests that an RBAC implementation conforms to the interface.

func TestSingleNodeProviderConformance added in v0.8.4

func TestSingleNodeProviderConformance(ctx context.Context, t *testing.T, provider storage.Provider)

TestSingleNodeProviderConformance is a helper for testing a single node provider.

func TestStorageProviderConformance

func TestStorageProviderConformance(ctx context.Context, t *testing.T, newProviders NewProvidersFunc)

TestStorageProviderConformance tests that the storage provider conforms to the storage provider interface.

Types

type Condition

type Condition[T comparable] func(T) bool

Condition is a function that returns true if the condition is met.

type DropStorage

type DropStorage interface {
	// DropAll drops all data from the storage. This is primarily used
	// for testing.
	DropAll(ctx context.Context) error
}

DropStorage is a storage interface that can be dropped entirely. This is primarily used for testing.

type Eventually

type Eventually[T comparable] func() T

Eventually is a function that should eventually meet the given condition.

func (Eventually[T]) Should

func (e Eventually[T]) Should(after time.Duration, tick time.Duration, condition func(T) bool) bool

Should eventually meet the given condition.

func (Eventually[T]) ShouldEqual

func (e Eventually[T]) ShouldEqual(after time.Duration, tick time.Duration, expected T) bool

ShouldEqual eventually should equal the given value.

func (Eventually[T]) ShouldError

func (e Eventually[T]) ShouldError(after time.Duration, tick time.Duration) bool

ShouldError eventually should error.

func (Eventually[T]) ShouldErrorWith

func (e Eventually[T]) ShouldErrorWith(after time.Duration, tick time.Duration, expected error) bool

ShouldErrorWith eventually should error with the given error.

func (Eventually[T]) ShouldNotEqual

func (e Eventually[T]) ShouldNotEqual(after time.Duration, tick time.Duration, expected T) bool

ShouldNotEqual eventually should not equal the given value.

func (Eventually[T]) ShouldNotError

func (e Eventually[T]) ShouldNotError(after time.Duration, tick time.Duration) bool

ShouldNotError eventually should not error.

type NewGraphStoreFunc added in v0.9.7

type NewGraphStoreFunc func(t *testing.T) types.PeerGraphStore

NewGraphStoreFunc is a function that creates a new PeerGraphStore implementation.

type NewMeshDataStoreFunc added in v0.11.0

type NewMeshDataStoreFunc func(t *testing.T) storage.MeshDataStore

NewMeshDataStoreFunc is a function that creates a new MeshDataStore implementation.

type NewMeshStateFunc added in v0.9.0

type NewMeshStateFunc func(t *testing.T) storage.MeshState

NewMeshStateFunc is a function that creates a new MeshState implementation.

type NewNetworkingFunc added in v0.9.0

type NewNetworkingFunc func(t *testing.T) storage.Networking

NewNetworkingFunc is a function that creates a new Networking implementation.

type NewPeersFunc added in v0.9.0

type NewPeersFunc func(t *testing.T) storage.Peers

NewPeersFunc is a function that creates a new Peers implementation.

type NewProvidersFunc added in v0.8.4

type NewProvidersFunc func(t *testing.T, count int) []storage.Provider

NewProvidersFunc is a function that returns new storage providers. Each should have unique identifying properties for and not be started or bootstrapped. The providers listen port must be available on localhost if applicable to the storage provider. It must at least not be zero.

type NewRBACFunc added in v0.9.0

type NewRBACFunc func(t *testing.T) storage.RBAC

NewRBACFunc is a function that creates a new RBAC implementation.

Jump to

Keyboard shortcuts

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