cockroach: github.com/sunya123/cockroach/acceptance/cluster Index | Files

package cluster

import "github.com/sunya123/cockroach/acceptance/cluster"

Package cluster is a generated protocol buffer package.

It is generated from these files:

cockroach/acceptance/cluster/testconfig.proto

It has these top-level messages:

StoreConfig
NodeConfig
TestConfig

Index

Package Files

cluster.go docker.go http.go localcluster.go stdcopy.go testconfig.go testconfig.pb.go

Constants

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.

func Consistent Uses

func Consistent(t *testing.T, c Cluster)

Consistent performs a replication consistency check on all the ranges in the cluster. It depends on a majority of the nodes being up.

func DefaultConfigs Uses

func DefaultConfigs() []TestConfig

DefaultConfigs returns a list of standard tests to run against acceptance tests.

func NewStdWriter Uses

func NewStdWriter(w io.Writer, t StdType) io.Writer

NewStdWriter instantiates a new Writer. Everything written to it will be encapsulated using a custom format, and written to the underlying `w` stream. This allows multiple write streams (e.g. stdout and stderr) to be muxed into a single connection. `t` indicates the id of the stream to encapsulate. It can be stdcopy.Stdin, stdcopy.Stdout, stdcopy.Stderr.

func StdCopy Uses

func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error)

StdCopy is a modified version of io.Copy.

StdCopy will demultiplex `src`, assuming that it contains two streams, previously multiplexed together using a StdWriter instance. As it reads from `src`, StdCopy will write to `dstout` and `dsterr`.

StdCopy will read until it hits EOF on `src`. It will then return a nil error. In other words: if `err` is non nil, it indicates a real underlying error.

`written` will hold the total number of bytes written to `dstout` and `dsterr`.

type Cluster Uses

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(*testing.T, int) (*client.DB, *stop.Stopper)
    // PGUrl returns a URL string for the given node postgres server.
    PGUrl(int) string
    // InternalIP returns the address used for inter-node communication.
    InternalIP(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(*testing.T)
    // AssertAndStop performs the same test as Assert but then proceeds to
    // dismantle the cluster.
    AssertAndStop(*testing.T)
    // ExecRoot executes the given command with super-user privileges.
    ExecRoot(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(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
    // Addr returns the host and port from the node in the format HOST:PORT.
    Addr(i int, port string) 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 Uses

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

Container provides the programmatic interface for a single docker container.

func (*Container) Addr Uses

func (c *Container) Addr(port nat.Port) *net.TCPAddr

Addr returns the TCP address to connect to.

func (*Container) Inspect Uses

func (c *Container) Inspect() (types.ContainerJSON, error)

Inspect retrieves detailed info about a container.

func (*Container) Kill Uses

func (c *Container) Kill() error

Kill stops a running container, without removing it.

func (*Container) Logs Uses

func (c *Container) Logs(w io.Writer) error

Logs outputs the containers logs to the given io.Writer.

func (Container) Name Uses

func (c Container) Name() string

Name returns the container's name.

func (*Container) Pause Uses

func (c *Container) Pause() error

Pause pauses a running container.

func (*Container) Remove Uses

func (c *Container) Remove() error

Remove removes the container from docker. It is an error to remove a running container.

func (*Container) Restart Uses

func (c *Container) Restart(timeout *time.Duration) error

Restart restarts a running container. Container will be killed after 'timeout' seconds if it fails to stop.

func (*Container) Start Uses

func (c *Container) Start() error

Start starts a non-running container.

TODO(pmattis): Generalize the setting of parameters here.

func (*Container) Stop Uses

func (c *Container) Stop(timeout *time.Duration) error

Stop a running container.

func (*Container) Unpause Uses

func (c *Container) Unpause() error

Unpause resumes a paused container.

func (*Container) Wait Uses

func (c *Container) Wait() error

Wait waits for a running container to exit.

type Event Uses

type Event struct {
    NodeIndex int
    Status    string
}

Event for a node containing a node index and the type of event.

type LocalCluster Uses

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 Uses

func CreateLocal(cfg TestConfig, logDir string, privileged bool, 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) Addr Uses

func (l *LocalCluster) Addr(i int, port string) string

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

func (*LocalCluster) Assert Uses

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 Uses

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) ExecRoot Uses

func (l *LocalCluster) ExecRoot(i int, cmd []string) error

ExecRoot runs a command as root.

func (*LocalCluster) InternalIP Uses

func (l *LocalCluster) InternalIP(i int) net.IP

InternalIP returns the IP address used for inter-node communication.

func (*LocalCluster) Kill Uses

func (l *LocalCluster) Kill(i int) error

Kill kills the i-th node.

func (*LocalCluster) NewClient Uses

func (l *LocalCluster) NewClient(t *testing.T, i int) (*roachClient.DB, *stop.Stopper)

NewClient implements the Cluster interface.

func (*LocalCluster) NumNodes Uses

func (l *LocalCluster) NumNodes() int

NumNodes returns the number of nodes in the cluster.

func (*LocalCluster) OneShot Uses

func (l *LocalCluster) OneShot(
    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 Uses

func (l *LocalCluster) PGUrl(i int) string

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

func (*LocalCluster) Restart Uses

func (l *LocalCluster) Restart(i int) error

Restart restarts the given node. If the node isn't running, this starts it.

func (*LocalCluster) Start Uses

func (l *LocalCluster) Start()

Start starts the cluster.

func (*LocalCluster) URL Uses

func (l *LocalCluster) URL(i int) string

URL returns the base url.

type NodeConfig Uses

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 Uses

func (*NodeConfig) Descriptor() ([]byte, []int)

func (*NodeConfig) Marshal Uses

func (m *NodeConfig) Marshal() (data []byte, err error)

func (*NodeConfig) MarshalTo Uses

func (m *NodeConfig) MarshalTo(data []byte) (int, error)

func (*NodeConfig) ProtoMessage Uses

func (*NodeConfig) ProtoMessage()

func (*NodeConfig) Reset Uses

func (m *NodeConfig) Reset()

func (*NodeConfig) Size Uses

func (m *NodeConfig) Size() (n int)

func (*NodeConfig) String Uses

func (m *NodeConfig) String() string

func (*NodeConfig) Unmarshal Uses

func (m *NodeConfig) Unmarshal(data []byte) error

type StdType Uses

type StdType byte

StdType is the type of standard stream a writer can multiplex to.

const (
    // Stdin represents standard input stream type.
    Stdin StdType = iota
    // Stdout represents standard output stream type.
    Stdout
    // Stderr represents standard error steam type.
    Stderr
)

type StoreConfig Uses

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 Uses

func (*StoreConfig) Descriptor() ([]byte, []int)

func (*StoreConfig) Marshal Uses

func (m *StoreConfig) Marshal() (data []byte, err error)

func (*StoreConfig) MarshalTo Uses

func (m *StoreConfig) MarshalTo(data []byte) (int, error)

func (*StoreConfig) ProtoMessage Uses

func (*StoreConfig) ProtoMessage()

func (*StoreConfig) Reset Uses

func (m *StoreConfig) Reset()

func (*StoreConfig) Size Uses

func (m *StoreConfig) Size() (n int)

func (*StoreConfig) String Uses

func (m *StoreConfig) String() string

func (*StoreConfig) Unmarshal Uses

func (m *StoreConfig) Unmarshal(data []byte) error

type TestConfig Uses

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 (*TestConfig) Descriptor Uses

func (*TestConfig) Descriptor() ([]byte, []int)

func (*TestConfig) Marshal Uses

func (m *TestConfig) Marshal() (data []byte, err error)

func (*TestConfig) MarshalTo Uses

func (m *TestConfig) MarshalTo(data []byte) (int, error)

func (*TestConfig) ProtoMessage Uses

func (*TestConfig) ProtoMessage()

func (*TestConfig) Reset Uses

func (m *TestConfig) Reset()

func (*TestConfig) Size Uses

func (m *TestConfig) Size() (n int)

func (*TestConfig) String Uses

func (m *TestConfig) String() string

func (*TestConfig) Unmarshal Uses

func (m *TestConfig) Unmarshal(data []byte) error

Package cluster imports 41 packages (graph). Updated 2017-07-07. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).