Version: v1.0.3 Latest Latest

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

Go to latest
Published: Jul 6, 2017 License: Apache-2.0 Imports: 22 Imported by: 0




View Source
const (
	// KeepClusterAlways lets Farmer always keep the test cluster.
	KeepClusterAlways = "always"
	// KeepClusterFailed lets Farmer keep only failed test clusters.
	KeepClusterFailed = "failed"
	// KeepClusterNever lets Farmer always destroy the test cluster.
	KeepClusterNever = "never"

The constants below are the possible values of the KeepCluster field.


This section is empty.


This section is empty.


type Farmer

type Farmer struct {
	Output      io.Writer
	Cwd, LogDir string
	KeyName     string
	Stores      string
	// Prefix will be prepended all names of resources created by Terraform.
	Prefix string
	// StateFile is the file (under `Cwd`) in which Terraform will stores its
	// state.
	StateFile string
	// AddVars are additional Terraform variables to be set during calls to Add.
	AddVars map[string]string
	// AddFlags are additional command-line flags to be passed to the cockroachdb
	// process.
	AddFlags    []string
	KeepCluster string

	// RPCContext is used to open an ExternalClient which provides a KV connection
	// to the cluster by gRPC.
	RPCContext *rpc.Context
	// contains filtered or unexported fields

A Farmer sets up and manipulates a test cluster via terraform.

func (*Farmer) AbsLogDir

func (f *Farmer) AbsLogDir() string

AbsLogDir returns the absolute log dir to which logs are written.

func (*Farmer) Add

func (f *Farmer) Add(nodes int) error

Add provisions the given number of nodes.

func (*Farmer) AddEnvVar

func (f *Farmer) AddEnvVar(key, value string)

AddEnvVar adds an environment variable to supervisord.conf when starting cockroach.

func (*Farmer) AddFlag

func (f *Farmer) AddFlag(flagVal string)

AddFlag add a command-line flag to include when starting cockroach.

func (*Farmer) Addr

func (f *Farmer) Addr(ctx context.Context, i int, port string) string

Addr returns the host and port from the node in the format HOST:PORT.

func (*Farmer) Assert

func (f *Farmer) Assert(ctx context.Context, t testing.TB)

Assert verifies that the cluster state is as expected (i.e. no unexpected restarts or node deaths occurred). Tests can call this periodically to ascertain cluster health. TODO(tschottdorf): unimplemented when nodes are expected down.

func (*Farmer) AssertAndStop

func (f *Farmer) AssertAndStop(ctx context.Context, t testing.TB)

AssertAndStop performs the same test as Assert but then proceeds to dismantle the cluster.

func (*Farmer) AssertState

func (f *Farmer) AssertState(ctx context.Context, t testing.TB, host, proc, expState string)

AssertState verifies that on the specified host, the given process (managed by supervisord) is in the expected state.

func (*Farmer) CollectLogs

func (f *Farmer) CollectLogs()

CollectLogs copies all possibly interesting files from all available peers if LogDir is not empty.

func (*Farmer) Destroy

func (f *Farmer) Destroy(t testing.TB) error

Destroy collects the logs and tears down the cluster.

func (*Farmer) Exec

func (f *Farmer) Exec(i int, cmd string) error

Exec executes the given command on the i-th node.

func (*Farmer) ExecRoot

func (f *Farmer) ExecRoot(ctx context.Context, i int, cmd []string) error

ExecRoot executes the given command with super-user privileges.

func (*Farmer) Hostname

func (f *Farmer) Hostname(i int) string

Hostname implements the Cluster interface.

func (*Farmer) InternalIP

func (f *Farmer) InternalIP(ctx context.Context, i int) net.IP

InternalIP returns the address used for inter-node communication.

func (*Farmer) Kill

func (f *Farmer) Kill(ctx context.Context, i int) error

Kill terminates the cockroach process running on the given node number. The given integer must be in the range [0,NumNodes()-1].

func (*Farmer) MustDestroy

func (f *Farmer) MustDestroy(t testing.TB)

MustDestroy calls Destroy(), fataling on error.

func (*Farmer) NewClient

func (f *Farmer) NewClient(ctx context.Context, i int) (*client.DB, error)

NewClient implements the Cluster interface.

func (*Farmer) NumNodes

func (f *Farmer) NumNodes() int

NumNodes returns the number of nodes.

func (*Farmer) PGUrl

func (f *Farmer) PGUrl(ctx context.Context, i int) string

PGUrl returns a URL string for the given node postgres server.

func (*Farmer) Resize

func (f *Farmer) Resize(nodes int) error

Resize is the counterpart to Add which resizes a cluster given the desired number of nodes.

func (*Farmer) Restart

func (f *Farmer) Restart(ctx context.Context, i int) error

Restart terminates the cockroach process running on the given node number, unless it is already stopped, and restarts it. The given integer must be in the range [0,NumNodes()-1].

func (*Farmer) Start

func (f *Farmer) Start(ctx context.Context, i int, process string) error

Start starts the given process on the ith node.

func (*Farmer) StartLoad

func (f *Farmer) StartLoad(ctx context.Context, loadGenerator string, n int) error

StartLoad starts n loadGenerator processes.

func (*Farmer) Stop

func (f *Farmer) Stop(ctx context.Context, i int, process string) error

Stop stops the given process on the ith node. This is useful for terminating a load generator cleanly to get stats outputted upon process termination.

func (*Farmer) URL

func (f *Farmer) URL(ctx context.Context, i int) string

URL returns the HTTP(s) endpoint.

func (*Farmer) WaitReady

func (f *Farmer) WaitReady(d time.Duration) error

WaitReady waits until the infrastructure is in a state that *should* allow for a healthy cluster. Currently, this means waiting for the load balancer to resolve from all nodes.

Jump to

Keyboard shortcuts

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