util

package
v0.0.0-...-8d377ce Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

This file implements test helper functions that augment the way any given test is run.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Permanent

func Permanent(err error) error

Permanent wraps the given error into a PermanentError, which will cause TestEventual to immediately fail the test it's returned within.

func TestEventual

func TestEventual(t *testing.T, name string, ctx context.Context, timeout time.Duration, f func(context.Context) error)

TestEventual creates a new subtest looping the given function until it either doesn't return an error anymore or the timeout is exceeded. The last returned non-context-related error is being used as the test error.

Types

type EphemeralClusterCredentials

type EphemeralClusterCredentials struct {
	// Nodes are the node credentials for the cluster. Each contains a private
	// key and x509 certificate authenticating the bearer as a Metropolis node.
	Nodes []*identity.NodeCredentials
	// Manager TLS certificate for the cluster. Contains a private key and x509
	// certificate authenticating the bearer as a Metropolis manager.
	Manager tls.Certificate
	// CA is the x509 certificate of the CA certificate for the cluster. Manager and
	// Node certificates are signed by this CA.
	CA *x509.Certificate
}

EphemeralClusterCredentials are TLS/PKI credentials for use in a Metropolis test cluster.

func NewEphemeralClusterCredentials

func NewEphemeralClusterCredentials(t *testing.T, nodes int) *EphemeralClusterCredentials

NewEphemeralClusterCredentials creates a set of TLS certificates for use in a test Metropolis cluster. These are a CA certificate, a Manager certificate and an arbitrary amount of Node certificates (per the nodes argument).

All of these are ephemeral, ie. not stored anywhere - including the CA certificate. This function is for use by tests which want to bring up a minimum set of PKI credentials for a fake Metropolis cluster.

type PermanentError

type PermanentError struct {
	Err error
}

PermanentError can be returned inside TestEventual to indicate that the test is 'stuck', that it will not make progress anymore and that it should be failed immediately.

func (*PermanentError) Error

func (p *PermanentError) Error() string

func (*PermanentError) Is

func (p *PermanentError) Is(o error) bool

func (*PermanentError) Unwrap

func (p *PermanentError) Unwrap() error

type TestCurator

type TestCurator struct {
	apb.UnimplementedCuratorServer
	// contains filtered or unexported fields
}

TestCurator is a shim Curator implementation that serves pending Watch requests based on data submitted to a channel.

func MakeTestCurator

func MakeTestCurator(t *testing.T) (*TestCurator, *grpc.ClientConn)

MakeTestCurator returns a working TestCurator alongside a grpc connection to it.

func (*TestCurator) DeleteNode

func (t *TestCurator) DeleteNode(id string)

DeleteNode submits a given node for deletion to the Watch event channel.

func (*TestCurator) NodeWithPrefixes

func (t *TestCurator) NodeWithPrefixes(key wgtypes.Key, id, address string, prefixes ...string)

NodeWithPrefixes submits a given node/key/address with prefixes to the Watch event channel.

func (*TestCurator) Watch

Watch implements a minimum Watch which just returns all nodes at once.

Jump to

Keyboard shortcuts

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