test

package
v0.0.0-...-173cbd8 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2016 License: MIT Imports: 16 Imported by: 1

README

# Cluster test utils

This package provides a runner to run tests within a docker cluster. It currently works on OSX and Linux. Windows still has a few issues.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Address

func Address() string

Address gets the local address

Types

type Node

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

Node is a docker node

func NewClusterNode

func NewClusterNode(options ...Option) *Node

NewClusterNode creates a new node

func NewClusterNodeFromOptions

func NewClusterNodeFromOptions(options *Options) *Node

NewClusterNodeFromOptions creates a new node

func NewTestNode

func NewTestNode(options ...Option) *Node

NewTestNode creates a test runner node

func NewTestNodeFromOptions

func NewTestNodeFromOptions(options *Options) *Node

NewTestNodeFromOptions creates a test runner node

func (*Node) ID

func (n *Node) ID() string

ID gets the container id

func (*Node) Kill

func (n *Node) Kill() error

Kill node

func (*Node) Logs

func (n *Node) Logs() (io.ReadCloser, error)

Logs gets a log reader

func (*Node) Output

func (n *Node) Output() error

Output logs to stdout

func (*Node) Start

func (n *Node) Start(hooks ...StartHook) error

Start node

func (*Node) Wait

func (n *Node) Wait() (int, error)

Wait for node to exit

func (*Node) WriteToFile

func (n *Node) WriteToFile() error

WriteToFile writes logs to file

type Option

type Option func(*Options)

Option is a test runner option

func Env

func Env(key string, value string) Option

Env sets an enviroment var

func Image

func Image(image string) Option

Image sets the image to use

func Mount

func Mount(host string, container string) Option

Mount adds a mount

func RunTestsCommand

func RunTestsCommand(command ...string) Option

RunTestsCommand sets the command to run on the test comtainer

func Size

func Size(size int) Option

Size sets the cluster size

func StartNodeCommand

func StartNodeCommand(command ...string) Option

StartNodeCommand sets the command to run per cluster node

func WorkingDirectory

func WorkingDirectory(dir string) Option

WorkingDirectory sets the working dir in the container

func WriteToFile

func WriteToFile(enabled bool) Option

WriteToFile ensures container logs are written to a file

type Options

type Options struct {
	Image            string
	Size             int
	Mount            map[string]string
	Env              map[string]string
	WorkingDirectory string
	NodeCommand      []string
	TestCommand      []string
	WriteToFile      bool
}

Options contains the runnner options

func DefaultOptions

func DefaultOptions() *Options

DefaultOptions returns the default options

type Runner

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

Runner is a cluster test runner

func NewRunner

func NewRunner(options ...Option) *Runner

NewRunner creates a new runner

func NewRunnerFromOptions

func NewRunnerFromOptions(options *Options) *Runner

NewRunnerFromOptions creates a new runner from options struct

func (*Runner) Kill

func (r *Runner) Kill() error

Kill cluster

func (*Runner) Start

func (r *Runner) Start() error

Start cluster

func (*Runner) StartAndTest

func (r *Runner) StartAndTest()

StartAndTest starts and runs test, exiting on completion

func (*Runner) Test

func (r *Runner) Test() (int, error)

Test runs tests and returns exit code

type StartHook

type StartHook func(client *client.Client, id string) error

StartHook is run after create and before start

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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