Documentation ¶
Overview ¶
Package cluster is a generated protocol buffer package.
It is generated from these files:
cockroach/pkg/acceptance/cluster/testconfig.proto
It has these top-level messages:
StoreConfig NodeConfig TestConfig
Index ¶
- Constants
- Variables
- func Consistent(ctx context.Context, c Cluster, i int) error
- type Cluster
- type Container
- func (c *Container) Addr(ctx context.Context, port nat.Port) *net.TCPAddr
- func (c *Container) Inspect(ctx context.Context) (types.ContainerJSON, error)
- func (c *Container) Kill(ctx context.Context) error
- func (c *Container) Logs(ctx context.Context, w io.Writer) error
- func (c Container) Name() string
- func (c *Container) Pause(ctx context.Context) error
- func (c *Container) Remove(ctx context.Context) error
- func (c *Container) Restart(ctx context.Context, timeout *time.Duration) error
- func (c *Container) Start(ctx context.Context) error
- func (c *Container) Stop(ctx context.Context, timeout *time.Duration) error
- func (c *Container) Unpause(ctx context.Context) error
- func (c *Container) Wait(ctx context.Context) error
- type Event
- type LocalCluster
- func (l *LocalCluster) Addr(ctx context.Context, i int, port string) string
- func (l *LocalCluster) Assert(ctx context.Context, t testing.TB)
- func (l *LocalCluster) AssertAndStop(ctx context.Context, t testing.TB)
- func (l *LocalCluster) Cleanup(ctx context.Context)
- func (l *LocalCluster) ExecRoot(ctx context.Context, i int, cmd []string) error
- func (l *LocalCluster) Hostname(i int) string
- func (l *LocalCluster) InternalIP(ctx context.Context, i int) net.IP
- func (l *LocalCluster) Kill(ctx context.Context, i int) error
- func (l *LocalCluster) NewClient(ctx context.Context, i int) (*roachClient.DB, error)
- func (l *LocalCluster) NumNodes() int
- func (l *LocalCluster) OneShot(ctx context.Context, ref string, ipo types.ImagePullOptions, ...) error
- func (l *LocalCluster) PGUrl(ctx context.Context, i int) string
- func (l *LocalCluster) Restart(ctx context.Context, i int) error
- func (l *LocalCluster) Start(ctx context.Context)
- func (l *LocalCluster) URL(ctx context.Context, i int) string
- type NodeConfig
- func (*NodeConfig) Descriptor() ([]byte, []int)
- func (m *NodeConfig) Marshal() (dAtA []byte, err error)
- func (m *NodeConfig) MarshalTo(dAtA []byte) (int, error)
- func (*NodeConfig) ProtoMessage()
- func (m *NodeConfig) Reset()
- func (m *NodeConfig) Size() (n int)
- func (m *NodeConfig) String() string
- func (m *NodeConfig) Unmarshal(dAtA []byte) error
- type StoreConfig
- func (*StoreConfig) Descriptor() ([]byte, []int)
- func (m *StoreConfig) Marshal() (dAtA []byte, err error)
- func (m *StoreConfig) MarshalTo(dAtA []byte) (int, error)
- func (*StoreConfig) ProtoMessage()
- func (m *StoreConfig) Reset()
- func (m *StoreConfig) Size() (n int)
- func (m *StoreConfig) String() string
- func (m *StoreConfig) Unmarshal(dAtA []byte) error
- type TestConfig
- func (*TestConfig) Descriptor() ([]byte, []int)
- func (m *TestConfig) Marshal() (dAtA []byte, err error)
- func (m *TestConfig) MarshalTo(dAtA []byte) (int, error)
- func (*TestConfig) ProtoMessage()
- func (m *TestConfig) Reset()
- func (m *TestConfig) Size() (n int)
- func (m *TestConfig) String() string
- func (m *TestConfig) Unmarshal(dAtA []byte) error
Constants ¶
const CockroachBinaryInContainer = "/cockroach/cockroach"
CockroachBinaryInContainer is the container-side path to the CockroachDB binary.
const DefaultDuration = 5 * time.Second
DefaultDuration is the default duration for each individual test.
const DefaultTCP nat.Port = base.DefaultPort + "/tcp"
DefaultTCP is the default SQL/RPC port specification.
Variables ¶
var ( ErrInvalidLengthTestconfig = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowTestconfig = fmt.Errorf("proto: integer overflow") )
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 ¶
Types ¶
type Cluster ¶
type Cluster interface { // NumNodes returns the number of nodes in the cluster, running or not. NumNodes() int // NewClient returns a kv client for the given node. NewClient(context.Context, int) (*client.DB, error) // PGUrl returns a URL string for the given node postgres server. PGUrl(context.Context, int) string // InternalIP returns the address used for inter-node communication. InternalIP(ctx context.Context, i int) net.IP // 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(context.Context, testing.TB) // AssertAndStop performs the same test as Assert but then proceeds to // dismantle the cluster. AssertAndStop(context.Context, testing.TB) // ExecRoot executes the given command with super-user privileges. ExecRoot(ctx context.Context, i int, cmd []string) error // Kill terminates the cockroach process running on the given node number. // The given integer must be in the range [0,NumNodes()-1]. Kill(context.Context, 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(context.Context, int) error // URL returns the HTTP(s) endpoint. URL(context.Context, int) string // Addr returns the host and port from the node in the format HOST:PORT. Addr(ctx context.Context, i int, port string) string // Hostname returns a node's hostname. Hostname(i 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) 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 []*testNode CertsDir string // contains filtered or unexported fields }
LocalCluster manages a local cockroach cluster running on docker. The cluster is composed of a "volumes" container which manages the persistent volumes used for certs and node data and N cockroach nodes.
func CreateLocal ¶
func CreateLocal( ctx context.Context, cfg TestConfig, logDir string, privileged bool, stopper *stop.Stopper, ) *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 and keeps logs in the specified logDir, if supplied.
func (*LocalCluster) Assert ¶
func (l *LocalCluster) Assert(ctx context.Context, t testing.TB)
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(ctx context.Context, t testing.TB)
AssertAndStop calls Assert and then stops the cluster. It is safe to stop the cluster multiple times.
func (*LocalCluster) Cleanup ¶
func (l *LocalCluster) Cleanup(ctx context.Context)
Cleanup removes the log directory if it was initially created by this LocalCluster.
func (*LocalCluster) Hostname ¶
func (l *LocalCluster) Hostname(i int) string
Hostname implements the Cluster interface.
func (*LocalCluster) InternalIP ¶
InternalIP returns the IP address used for inter-node communication.
func (*LocalCluster) Kill ¶
func (l *LocalCluster) Kill(ctx context.Context, i int) error
Kill kills the i-th node.
func (*LocalCluster) NewClient ¶
func (l *LocalCluster) NewClient(ctx context.Context, i int) (*roachClient.DB, error)
NewClient implements the Cluster interface.
func (*LocalCluster) NumNodes ¶
func (l *LocalCluster) NumNodes() int
NumNodes returns the number of nodes in the cluster.
func (*LocalCluster) OneShot ¶
func (l *LocalCluster) OneShot( ctx context.Context, ref string, ipo types.ImagePullOptions, containerConfig container.Config, hostConfig container.HostConfig, name string, ) error
OneShot runs a container, expecting it to successfully run to completion and die, after which it is removed. Not goroutine safe: only one OneShot can be running at once. Adds the same binds as the cluster containers (certs, binary, etc).
func (*LocalCluster) PGUrl ¶
func (l *LocalCluster) PGUrl(ctx context.Context, i int) string
PGUrl returns a URL string for the given node postgres server.
func (*LocalCluster) Restart ¶
func (l *LocalCluster) Restart(ctx context.Context, i int) error
Restart restarts the given node. If the node isn't running, this starts it.
func (*LocalCluster) Start ¶
func (l *LocalCluster) Start(ctx context.Context)
Start starts the cluster.
type NodeConfig ¶
type NodeConfig struct { Count int32 `protobuf:"varint,1,opt,name=count" json:"count"` Stores []StoreConfig `protobuf:"bytes,2,rep,name=stores" json:"stores"` }
NodeConfig holds the configuration of a collection of similar nodes.
func (*NodeConfig) Descriptor ¶
func (*NodeConfig) Descriptor() ([]byte, []int)
func (*NodeConfig) Marshal ¶
func (m *NodeConfig) Marshal() (dAtA []byte, err error)
func (*NodeConfig) ProtoMessage ¶
func (*NodeConfig) ProtoMessage()
func (*NodeConfig) Reset ¶
func (m *NodeConfig) Reset()
func (*NodeConfig) Size ¶
func (m *NodeConfig) Size() (n int)
func (*NodeConfig) String ¶
func (m *NodeConfig) String() string
func (*NodeConfig) Unmarshal ¶
func (m *NodeConfig) Unmarshal(dAtA []byte) error
type StoreConfig ¶
type StoreConfig struct { Count int32 `protobuf:"varint,1,opt,name=count" json:"count"` MaxRanges int32 `protobuf:"varint,2,opt,name=max_ranges,json=maxRanges" json:"max_ranges"` }
StoreConfig holds the configuration of a collection of similar stores.
func (*StoreConfig) Descriptor ¶
func (*StoreConfig) Descriptor() ([]byte, []int)
func (*StoreConfig) Marshal ¶
func (m *StoreConfig) Marshal() (dAtA []byte, err error)
func (*StoreConfig) ProtoMessage ¶
func (*StoreConfig) ProtoMessage()
func (*StoreConfig) Reset ¶
func (m *StoreConfig) Reset()
func (*StoreConfig) Size ¶
func (m *StoreConfig) Size() (n int)
func (*StoreConfig) String ¶
func (m *StoreConfig) String() string
func (*StoreConfig) Unmarshal ¶
func (m *StoreConfig) Unmarshal(dAtA []byte) error
type TestConfig ¶
type TestConfig struct { Name string `protobuf:"bytes,1,opt,name=name" json:"name"` Nodes []NodeConfig `protobuf:"bytes,2,rep,name=nodes" json:"nodes"` // Duration is the total time that the test should run for. Important for // tests such as TestPut that will run indefinitely. Duration time.Duration `protobuf:"varint,3,opt,name=duration,casttype=time.Duration" json:"duration"` }
func DefaultConfigs ¶
func DefaultConfigs() []TestConfig
DefaultConfigs returns a list of standard tests to run against acceptance tests.
func (*TestConfig) Descriptor ¶
func (*TestConfig) Descriptor() ([]byte, []int)
func (*TestConfig) Marshal ¶
func (m *TestConfig) Marshal() (dAtA []byte, err error)
func (*TestConfig) ProtoMessage ¶
func (*TestConfig) ProtoMessage()
func (*TestConfig) Reset ¶
func (m *TestConfig) Reset()
func (*TestConfig) Size ¶
func (m *TestConfig) Size() (n int)
func (*TestConfig) String ¶
func (m *TestConfig) String() string
func (*TestConfig) Unmarshal ¶
func (m *TestConfig) Unmarshal(dAtA []byte) error