session

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: AGPL-3.0 Imports: 35 Imported by: 0

Documentation

Overview

Package session defines types for doing system tests.

It facilitates launching a network of nodes each in a separate process and run tests against them via the API.

Index

Constants

View Source
const NumSeeds = 5

NumSeeds is the number of seeds in a bootstrap list.

Variables

This section is empty.

Functions

func BenchmarkCfg

func BenchmarkCfg() cfg.ConfigSet

BenchmarkCfg returns a base configuration for benchmarking.

func NewMultiErr

func NewMultiErr(errs []error) error

NewMultiErr creates a multierror from a slice of errors.

Only non-nil error will be added. If there are no non-nil errors, it returns nil.

func PerCPU

func PerCPU(fn func(int), n int)

PerCPU executes a function concurrently with one goroutine per cpu.

func Run

func Run(ctx context.Context, dir string, numNodes int, config cfg.ConfigSet, fn Tester) error

Run launches a test network and calls a user defined function that can interact with the nodes via API clients.

The configuration files, data files, and logs will be saved in a directory within the given directory.

func RunWithConfigs

func RunWithConfigs(ctx context.Context, dir string, numNodes int, configs []cfg.ConfigSet, fn Tester) error

RunWithConfigs launches a test network and calls a user defined function that can interact with the nodes via API clients. Each node has a specific config.

The configuration files, data files, and logs will be saved in a directory within the given directory.

func SystemCfg

func SystemCfg() cfg.ConfigSet

SystemCfg returns a base configuration for system testing.

func WithServices

func WithServices(config cfg.ConfigSet, services ...string) cfg.ConfigSet

WithServices takes a configuration and returns a new one with the same settings except that it changes the boot service.

It will also start the signal service so that exit signals are handled properly.

Types

type MultiErr

type MultiErr []error

MultiErr represents multiple errors as a single error.

func (MultiErr) Error

func (e MultiErr) Error() string

Error returns the errors messages joined by semicolons.

func (MultiErr) Format

func (e MultiErr) Format(s fmt.State, verb rune)

Format formats each error individually.

type TestNode

type TestNode struct {
	// contains filtered or unexported fields
}

TestNode represents a test node.

func NewTestNode

func NewTestNode(dir string, config cfg.ConfigSet) (*TestNode, error)

NewTestNode creates a new test node.

func (*TestNode) Connect

func (h *TestNode) Connect(ctx context.Context) (*grpc.ClientConn, error)

Connect returns an API client connected to the node.

func (*TestNode) FullAddress

func (h *TestNode) FullAddress() string

FullAddress returns the full address to connect to the node.

func (*TestNode) PeerID

func (h *TestNode) PeerID() peer.ID

PeerID returns the peer ID of the node.

func (*TestNode) Up

func (h *TestNode) Up(ctx context.Context) error

Up launches the node. It blocks until the process exits or the context is done.

func (*TestNode) WaitForAPI

func (h *TestNode) WaitForAPI(ctx context.Context) (*grpc.ClientConn, error)

WaitForAPI waits for the API to be available.

type TestNodeSet

type TestNodeSet []*TestNode

TestNodeSet represents a set of test nodes.

func NewTestNodeSet

func NewTestNodeSet(dir string, n int, config cfg.ConfigSet) (TestNodeSet, error)

NewTestNodeSet creates a new set of test nodes.

func NewTestNodeSetWithConfigs

func NewTestNodeSetWithConfigs(dir string, n int, configs []cfg.ConfigSet) (TestNodeSet, error)

NewTestNodeSetWithConfigs creates a new set of test nodes with different configs.

func (TestNodeSet) Connect

func (s TestNodeSet) Connect(ctx context.Context) ([]*grpc.ClientConn, error)

Connect returns an API client for each node in the set.

func (TestNodeSet) Up

func (s TestNodeSet) Up(ctx context.Context) error

Up launches the set of nodes.

type Tester

type Tester func(context.Context, TestNodeSet, []*grpc.ClientConn)

Tester represents a function used to interact with a test network during a session.

Jump to

Keyboard shortcuts

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