sintegration

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package sintegration simplifies the creation of integration tests.

NOTE: this is a copy of github.com/scionproto/scion/go/lib/integration, with some omissions and modifications

Index

Constants

View Source
const (
	// StartServerTimeout is the timeout for starting a server.
	StartServerTimeout = 5 * time.Second
	// KillServerTimeout is the timeout for waiting for a server to finish
	KillServerTimeout = 5 * time.Second
	// SCIONDAddressesFile is the default file for SCIOND addresses in a topology created
	// with the topology generator.
	SCIONDAddressesFile = "sciond_addresses.json"
)

Variables

This section is empty.

Functions

func ExtractUniqueDsts

func ExtractUniqueDsts(pairs []IAPair) []*snet.UDPAddr

ExtractUniqueDsts returns all unique destinations in pairs.

func GenFile

func GenFile(file string) string

GenFile returns the path for the given file in the gen folder.

func GetSCIONDAddress

func GetSCIONDAddress(networksFile string, ia addr.IA) (string, error)

func GetSCIONDAddresses

func GetSCIONDAddresses(networksFile string) (map[string]string, error)

func Init

func Init(projectRoot string) error

Init initializes the integration test, it adds and validates the command line flags, and initializes logging.

func RunClient

func RunClient(in Integration, pair IAPair, timeout time.Duration) error

RunClient runs a client on the given IAPair. If the client does not finish until timeout it is killed.

func StartServer added in v0.5.0

func StartServer(in Integration, dst *snet.UDPAddr) (io.Closer, error)

StartServer runs a server. The server can be stopped by calling Close() on the returned Closer. To start a server with a custom context use in.StartServer directly.

Types

type HostAddr

type HostAddr func(ia addr.IA) *snet.UDPAddr

type IAPair

type IAPair struct {
	Src, Dst *snet.UDPAddr
}

IAPair is a source, destination pair. The client (Src) will dial the server (Dst).

func IAPairs

func IAPairs(hostAddr HostAddr) []IAPair

IAPairs returns all IAPairs that should be tested.

type Integration

type Integration interface {
	// StartServer should start the server listening on the address dst.
	// StartServer should return after it is ready to accept clients.
	// The context should be used to make the server cancellable.
	StartServer(ctx context.Context, dst *snet.UDPAddr) (Waiter, error)
	// StartClient should start the client on the src address connecting to the dst address.
	// StartClient should return immediately.
	// The context should be used to make the client cancellable.
	StartClient(ctx context.Context, src, dst *snet.UDPAddr) (Waiter, error)
}

Integration can be used to run integration tests.

type Waiter

type Waiter interface {
	// Wait should block until the underlying program is terminated.
	Wait() error
}

Waiter is a descriptor of a process running in the integration test. It should be used to wait on completion of the process.

Jump to

Keyboard shortcuts

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