Documentation ¶
Overview ¶
Package testutil contains testing utilities for storage providers and backends.
Index ¶
- func MustAddObserver(ctx context.Context, t *testing.T, leader, observer storage.Provider)
- func MustAddVoter(ctx context.Context, t *testing.T, leader, voter storage.Provider)
- func MustBootstrapProvider(ctx context.Context, t *testing.T, provider storage.Provider)
- func MustStartProvider(ctx context.Context, t *testing.T, provider storage.Provider)
- func SkipOnCI(t *testing.T, reason string)
- func TestConsensusStorageConformance(ctx context.Context, t *testing.T, raftStorage storage.ConsensusStorage)
- func TestDualStorageConformance(ctx context.Context, t *testing.T, dualStorage storage.DualStorage)
- func TestMeshStorageConformance(ctx context.Context, t *testing.T, meshStorage storage.MeshStorage)
- func TestSingleNodeProviderConformance(ctx context.Context, t *testing.T, provider storage.Provider)
- func TestStorageProviderConformance(ctx context.Context, t *testing.T, newProviders NewProvidersFunc)
- type Condition
- type DropStorage
- type Eventually
- func (e Eventually[T]) Should(after time.Duration, tick time.Duration, condition func(T) bool) bool
- func (e Eventually[T]) ShouldEqual(after time.Duration, tick time.Duration, expected T) bool
- func (e Eventually[T]) ShouldError(after time.Duration, tick time.Duration) bool
- func (e Eventually[T]) ShouldErrorWith(after time.Duration, tick time.Duration, expected error) bool
- func (e Eventually[T]) ShouldNotEqual(after time.Duration, tick time.Duration, expected T) bool
- func (e Eventually[T]) ShouldNotError(after time.Duration, tick time.Duration) bool
- type NewProvidersFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustAddObserver ¶ added in v0.8.0
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
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
MustBootstrapProvider is a helper function that calls Bootstrap and fails the test if there is an error.
func MustStartProvider ¶ added in v0.8.4
MustStartProvider is a helper function that calls Start and fails the test if there is an error.
func SkipOnCI ¶ added in v0.8.0
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 ¶
TestDualStorageConformance tests that the DualStorage interface is implemented correctly.
func TestMeshStorageConformance ¶
TestMeshStorageConformance tests that the MeshStorage interface is implemented correctly.
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]) ShouldEqual ¶
ShouldEqual eventually should equal the given value.
func (Eventually[T]) ShouldError ¶
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 ¶
ShouldNotEqual eventually should not equal the given value.
func (Eventually[T]) ShouldNotError ¶
ShouldNotError eventually should not error.
type NewProvidersFunc ¶ added in v0.8.4
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.