Documentation ¶
Index ¶
- Variables
- type Cluster
- type Container
- func (c *Container) Addr(name nat.Port) *net.TCPAddr
- func (c *Container) GetJSON(port nat.Port, path string, v interface{}) error
- func (c *Container) Inspect() (types.ContainerJSON, error)
- func (c *Container) Kill() error
- func (c *Container) Logs(w io.Writer) error
- func (c Container) Name() string
- func (c *Container) PGAddr() *net.TCPAddr
- func (c *Container) Pause() error
- func (c *Container) Remove() error
- func (c *Container) Restart(timeoutSeconds int) error
- func (c *Container) Start() error
- func (c *Container) Stop(timeoutSeconds int) error
- func (c *Container) Unpause() error
- func (c *Container) Wait() error
- type Event
- type LocalCluster
- func (l *LocalCluster) Assert(t *testing.T)
- func (l *LocalCluster) AssertAndStop(t *testing.T)
- func (l *LocalCluster) ConnString(i int) string
- func (l *LocalCluster) Kill(i int) error
- func (l *LocalCluster) NumNodes() int
- func (l *LocalCluster) PGAddr(i int) *net.TCPAddr
- func (l *LocalCluster) PGUrl(i int) string
- func (l *LocalCluster) Restart(i int) error
- func (l *LocalCluster) Start()
- func (l *LocalCluster) URL(i int) string
Constants ¶
This section is empty.
Variables ¶
var HTTPClient = http.Client{ Timeout: base.NetworkTimeout, Transport: &http.Transport{ TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, }, }}
HTTPClient is an http.Client configured for querying a cluster. We need to run with "InsecureSkipVerify" (at least on Docker) due to the fact that we cannot use a fixed hostname to reach the cluster. This in turn means that we do not have a verified server name in the certs.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster interface { // NumNodes returns the number of nodes in the cluster, running or not. NumNodes() int // ConnString returns a connection string for the given node. ConnString(int) string // PGUrl returns a URL string for the given node postgres server. PGUrl(int) string // PGAddr returns the Postgres address for the given node. PGAddr(i int) *net.TCPAddr // 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. Assert(*testing.T) // AssertAndStop performs the same test as Assert but then proceeds to // dismantle the cluster. AssertAndStop(*testing.T) // Kill terminates the cockroach process running on the given node number. // The given integer must be in the range [0,NumNodes()-1]. Kill(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]. Restart(int) error // URL returns the HTTP(s) endpoint. URL(int) string }
A Cluster is an abstraction away from a concrete cluster deployment (i.e. a local docker cluster, or an AWS-provisioned one). It exposes a shared set of methods for test-related manipulation.
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container provides the programmatic interface for a single docker container.
func (*Container) GetJSON ¶
GetJSON retrieves the URL specified by https://Addr(<port>)<path> and unmarshals the result as JSON.
func (*Container) Inspect ¶
func (c *Container) Inspect() (types.ContainerJSON, error)
Inspect retrieves detailed info about a container.
func (*Container) Remove ¶
Remove removes the container from docker. It is an error to remove a running container.
func (*Container) Restart ¶
Restart restarts a running container. Container will be killed after 'timeout' seconds if it fails to stop.
func (*Container) Start ¶
Start starts a non-running container.
TODO(pmattis): Generalize the setting of parameters here.
type LocalCluster ¶
type LocalCluster struct { Nodes []*Container CertsDir string // contains filtered or unexported fields }
LocalCluster manages a local cockroach cluster running on docker. The cluster is composed of a "dns" container which automatically registers dns entries for the cockroach nodes, a "volumes" container which manages the persistent volumes used for certs and node data and N cockroach nodes.
func CreateLocal ¶
func CreateLocal(numLocal, numStores int, logDir string, stopper chan struct{}) *LocalCluster
CreateLocal creates a new local cockroach cluster. The stopper is used to gracefully shutdown the channel (e.g. when a signal arrives). The cluster must be started before being used.
func (*LocalCluster) Assert ¶
func (l *LocalCluster) Assert(t *testing.T)
Assert drains the Events channel and compares the actual events with those expected to have been generated by the operations performed on the nodes in the cluster (restart, kill, ...). In the event of a mismatch, the passed Tester receives a fatal error.
func (*LocalCluster) AssertAndStop ¶
func (l *LocalCluster) AssertAndStop(t *testing.T)
AssertAndStop calls Assert and then stops the cluster. It is safe to stop the cluster multiple times.
func (*LocalCluster) ConnString ¶
func (l *LocalCluster) ConnString(i int) string
ConnString creates a connections string.
func (*LocalCluster) NumNodes ¶
func (l *LocalCluster) NumNodes() int
NumNodes returns the number of nodes in the cluster.
func (*LocalCluster) PGAddr ¶
func (l *LocalCluster) PGAddr(i int) *net.TCPAddr
PGAddr returns the Postgres address for the given node.
func (*LocalCluster) PGUrl ¶
func (l *LocalCluster) PGUrl(i int) string
PGUrl returns a URL string for the given node postgres server.
func (*LocalCluster) Restart ¶
func (l *LocalCluster) Restart(i int) error
Restart restarts the given node. If the node isn't running, this starts it.