Documentation ¶
Index ¶
- Constants
- type Farmer
- func (f *Farmer) AbsLogDir() string
- func (f *Farmer) Addr(ctx context.Context, i int, port string) string
- func (f *Farmer) Assert(ctx context.Context, t testing.TB)
- func (f *Farmer) AssertAndStop(ctx context.Context, t testing.TB)
- func (f *Farmer) CollectLogs() error
- func (f *Farmer) Destroy(t testing.TB) error
- func (f *Farmer) Exec(i int, cmd string) error
- func (f *Farmer) ExecCLI(ctx context.Context, i int, cmd []string) (string, string, error)
- func (f *Farmer) GetProcDone(i int, name string) <-chan error
- func (f *Farmer) Hostname(i int) string
- func (f *Farmer) InternalIP(ctx context.Context, i int) net.IP
- func (f *Farmer) Kill(ctx context.Context, i int) error
- func (f *Farmer) MustDestroy(t testing.TB)
- func (f *Farmer) NewClient(ctx context.Context, i int) (*client.DB, error)
- func (f *Farmer) NumNodes() int
- func (f *Farmer) PGUrl(ctx context.Context, i int) string
- func (f *Farmer) Resize(nodes int) error
- func (f *Farmer) Restart(ctx context.Context, i int) error
- func (f *Farmer) Start(ctx context.Context, i int, name string) error
- func (f *Farmer) StartLoad(ctx context.Context, loadGenerator string) error
- func (f *Farmer) Stop(ctx context.Context, i int, name string) error
- func (f *Farmer) URL(ctx context.Context, i int) string
- func (f *Farmer) WaitReady(d time.Duration) error
Constants ¶
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.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Farmer ¶
type Farmer struct { Output io.Writer Cwd, LogDir string KeyName string // SkipClusterInit controls the --join flags for the nodes. If false (the // default), then the first node will be empty and thus init the cluster, // and each node will have the previous node as its join flag. If true, // then all nodes will have all nodes in their join flags. // // Allows tests to work around https://github.com/cockroachdb/cockroach/issues/13027. SkipClusterInit bool CockroachBinary string CockroachFlags string // NB: CockroachEnv might look like it wants to be a map, but we never use // the environment as key-value pairs in Go, we just pass this straight // through to the shell when we start cockroach on the remote hosts. The // reason for doing it this way rather than using // `(*golang.org/x/crypto/ssh.Session).SetEnv` is that setting the // session's environment requires server permission, and the default is to // allow nothing. CockroachEnv string BenchmarkName string // TerraformArgs are appended to every Terraform command invocation. TerraformArgs []string // Prefix will be prepended all names of resources created by Terraform. Prefix string // StateFile is the file (under `Cwd`) in which Terraform will store its // state. StateFile 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) Assert ¶
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 ¶
AssertAndStop performs the same test as Assert but then proceeds to dismantle the cluster.
func (*Farmer) CollectLogs ¶
CollectLogs copies all possibly interesting files from all available peers if LogDir is not empty.
func (*Farmer) GetProcDone ¶
GetProcDone returns a channel which will receive the named process' exit status.
func (*Farmer) InternalIP ¶
InternalIP returns the address used for inter-node communication.
func (*Farmer) Kill ¶
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 ¶
MustDestroy calls Destroy(), fataling on error.
func (*Farmer) Restart ¶
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) Stop ¶
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.