sidecar

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2020 License: Apache-2.0, MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvRedisHost = "REDIS_HOST"
)

Variables

This section is empty.

Functions

func GetRunners

func GetRunners() []string

GetRunners lists the available sidecar environments.

func Run

func Run(runnerName string) error

Run runs the sidecar in the given runner environment.

Types

type DockerInstanceManager

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

func (*DockerInstanceManager) Close

func (d *DockerInstanceManager) Close() error

func (*DockerInstanceManager) Manage

func (d *DockerInstanceManager) Manage(
	ctx context.Context,
	worker func(ctx context.Context, inst *Instance) error,
) error

type DockerNetwork

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

func (*DockerNetwork) Close

func (dn *DockerNetwork) Close() error

func (*DockerNetwork) ConfigureNetwork

func (dn *DockerNetwork) ConfigureNetwork(ctx context.Context, cfg *sync.NetworkConfig) error

func (*DockerNetwork) ListActive

func (dn *DockerNetwork) ListActive() []string

func (*DockerNetwork) ListAvailable

func (dn *DockerNetwork) ListAvailable() []string

type Instance

type Instance struct {
	logging.Logging

	Hostname string
	Watcher  *sync.Watcher
	Writer   *sync.Writer
	RunEnv   *runtime.RunEnv
	Network  Network
}

Instance is a test instance as seen by the sidecar.

func NewInstance

func NewInstance(runenv *runtime.RunEnv, hostname string, network Network) (*Instance, error)

NewInstance constructs a new test instance handle.

func (*Instance) Close

func (inst *Instance) Close() error

Close closes the instance. It should not be used after closing.

type InstanceManager

type InstanceManager interface {
	io.Closer
	Manage(context.Context, func(context.Context, *Instance) error) error
}

func NewDockerManager

func NewDockerManager() (InstanceManager, error)

func NewK8sManager

func NewK8sManager() (InstanceManager, error)

type K8sInstanceManager

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

func (*K8sInstanceManager) Close

func (d *K8sInstanceManager) Close() error

func (*K8sInstanceManager) Manage

func (d *K8sInstanceManager) Manage(
	ctx context.Context,
	worker func(ctx context.Context, inst *Instance) error,
) error

type K8sNetwork

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

func (*K8sNetwork) Close

func (n *K8sNetwork) Close() error

func (*K8sNetwork) ConfigureNetwork

func (n *K8sNetwork) ConfigureNetwork(ctx context.Context, cfg *sync.NetworkConfig) error

func (*K8sNetwork) ListActive

func (n *K8sNetwork) ListActive() []string

type Logs

type Logs interface {
	io.Closer
	Stderr() io.Reader
	Stdout() io.Reader
}

Logs are logs from a test instance.

type NetlinkLink struct {
	netlink.Link
	// contains filtered or unexported fields
}

NetlinkLink abstracts operations over a network interface.

NetlinkLink shapes the egress traffic on the link using TC. To do so, it configures the following TC tree:

[________HTB Qdisc_________] - root
   0 |      1 |     n | ...  - queue; 0 is the default.
[HTB Class]                  - bandwidth (rate limiting)
     |
[Netem Qdisc]                - latency, jitter, etc. (per-packet attributes)

At the moment, only one queue is supported. When support for multiple subnets is added, additional classes/queues will be added per-subnet.

NetlinkLink also supports setting the network device up/down and changing the IP address.

NOTE: Not all run environments will react well to the IP address changing. Don't use this feature with docker.

func NewNetlinkLink(handle *netlink.Handle, link netlink.Link) (*NetlinkLink, error)

NewNetlinkLink constructs a new netlink link handle.

func (*NetlinkLink) AddrAdd

func (l *NetlinkLink) AddrAdd(ip *net.IPNet) error

AddrAdd adds an address to the link.

NOTE: This won't work in docker; use docker connect/disconnect.

func (*NetlinkLink) AddrDel

func (l *NetlinkLink) AddrDel(ip *net.IPNet) error

AddrDel removes an address from the link.

NOTE: This won't work in docker; use docker connect/disconnect.

func (*NetlinkLink) Down

func (l *NetlinkLink) Down() error

Down takes the link down.

func (*NetlinkLink) ListV4

func (l *NetlinkLink) ListV4() ([]*net.IPNet, error)

ListV4 lists all IPv4 addresses associated with the link.

func (*NetlinkLink) ListV6

func (l *NetlinkLink) ListV6() ([]*net.IPNet, error)

ListV6 lists all IPv6 addresses associated with the link.

func (*NetlinkLink) Shape

func (l *NetlinkLink) Shape(shape sync.LinkShape) error

Shape applies the link "shape" to the link, setting the bandwidth, latency, jitter, etc.

func (*NetlinkLink) Up

func (l *NetlinkLink) Up() error

Up sets the link up.

type Network

type Network interface {
	io.Closer
	ConfigureNetwork(ctx context.Context, cfg *sync.NetworkConfig) error
	ListActive() []string
}

Network is a test instance's network, as seen by the sidecar.

Sidecar runners must implement this interface.

Jump to

Keyboard shortcuts

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