cockroach: Index | Files

package base

import ""


Package Files

constants.go context.go test_server_args.go testing_knobs.go


const (

    // From IANA Service Name and Transport Protocol Port Number Registry. See
    DefaultPort = "26257"

    // The default port for HTTP-for-humans.
    DefaultHTTPPort = "8080"

    // NetworkTimeout is the timeout used for network operations.
    NetworkTimeout = 3 * time.Second

    // DefaultRaftTickInterval is the default resolution of the Raft timer.
    DefaultRaftTickInterval = 100 * time.Millisecond

Base context defaults.

const (
    // DefaultHeartbeatInterval is how often heartbeats are sent from the
    // transaction coordinator to a live transaction. These keep it from
    // being preempted by other transactions writing the same keys. If a
    // transaction fails to be heartbeat within 2x the heartbeat interval,
    // it may be aborted by conflicting txns.
    DefaultHeartbeatInterval = 5 * time.Second

func DefaultRetryOptions Uses

func DefaultRetryOptions() retry.Options

DefaultRetryOptions should be used for retrying most network-dependent operations.

type Context Uses

type Context struct {
    // Insecure specifies whether to use SSL or not.
    // This is really not recommended.
    Insecure bool

    // SSLCA and others contain the paths to the ssl certificates and keys.
    SSLCA      string // CA certificate
    SSLCAKey   string // CA key (to sign only)
    SSLCert    string // Client/server certificate
    SSLCertKey string // Client/server key

    // User running this process. It could be the user under which
    // the server is running or the user passed in client calls.
    User string

    // Addr is the server's public address.
    Addr string

    // HTTPAddr is server's public HTTP address.
    // This is temporary, and will be removed when grpc.(*Server).ServeHTTP
    // performance problems are addressed upstream.
    // See
    HTTPAddr string
    // contains filtered or unexported fields

Context is embedded by server.Context. A base context is not meant to be used directly, but embedding contexts should call ctx.InitDefaults().

func (*Context) AdminURL Uses

func (ctx *Context) AdminURL() string

AdminURL returns the URL for the admin UI.

func (*Context) GetClientTLSConfig Uses

func (ctx *Context) GetClientTLSConfig() (*tls.Config, error)

GetClientTLSConfig returns the context client TLS config, initializing it if needed. If Insecure is true, return a nil config, otherwise load a config based on the SSLCert file. If SSLCert is empty, use a very permissive config. TODO(marc): empty SSLCert should fail when client certificates are required.

func (*Context) GetHTTPClient Uses

func (ctx *Context) GetHTTPClient() (http.Client, error)

GetHTTPClient returns the context http client, initializing it if needed. It uses the context client TLS config.

func (*Context) GetServerTLSConfig Uses

func (ctx *Context) GetServerTLSConfig() (*tls.Config, error)

GetServerTLSConfig returns the context server TLS config, initializing it if needed. If Insecure is true, return a nil config, otherwise load a config based on the SSLCert file. Fails if Insecure=false and SSLCert="".

func (*Context) HTTPRequestScheme Uses

func (ctx *Context) HTTPRequestScheme() string

HTTPRequestScheme returns "http" or "https" based on the value of Insecure.

func (*Context) InitDefaults Uses

func (ctx *Context) InitDefaults()

InitDefaults sets up the default values for a context.

func (*Context) PGURL Uses

func (ctx *Context) PGURL(user string) (*url.URL, error)

PGURL returns the URL for the postgres endpoint.

type ModuleTestingKnobs Uses

type ModuleTestingKnobs interface {
    // ModuleTestingKnobs is a dummy function.

ModuleTestingKnobs is an interface for testing knobs for a submodule.

type TestClusterArgs Uses

type TestClusterArgs struct {
    // ServerArgs will be copied to each constituent TestServer.
    ServerArgs TestServerArgs
    // ReplicationMode controls how replication is to be done in the cluster.
    ReplicationMode TestClusterReplicationMode
    // Stopper can be used to stop the cluster. If not set, a stopper will be
    // constructed and it can be gotten through TestCluster.Stopper().
    Stopper *stop.Stopper

TestClusterArgs contains the parameters one can set when creating a test cluster. It contains a TestServerArgs instance which will be copied over to every server.

The zero value means "full replication".

type TestClusterReplicationMode Uses

type TestClusterReplicationMode int

TestClusterReplicationMode represents the replication settings for a TestCluster.

const (
    // ReplicationAuto means that ranges are replicated according to the
    // production default zone config. Replication is performed as in
    // production, by the replication queue.
    // TestCluster.WaitForFullReplication() can be used to wait for
    // replication to be stable at any point in a test.
    ReplicationAuto TestClusterReplicationMode = iota
    // ReplicationManual means that the split and replication queues of all
    // servers are stopped, and the test must manually control splitting and
    // replication through the TestServer.

type TestServerArgs Uses

type TestServerArgs struct {
    // Knobs for the test server.
    Knobs TestingKnobs

    // PartOfCluster must be set if the TestServer is joining others in a cluster.
    // If not set (and hence the server is the only one in the cluster), the
    // default zone config will be overridden to disable all replication - so that
    // tests don't get log spam about ranges not being replicated enough.
    PartOfCluster bool

    // JoinAddr (if nonempty) is the address of a node we are joining.
    JoinAddr string

    StoresPerNode int

    // Fields copied to the server.Context.
    Insecure              bool
    MetricsSampleInterval time.Duration
    MaxOffset             time.Duration
    SocketFile            string
    ScanInterval          time.Duration
    ScanMaxIdleTime       time.Duration
    SSLCA                 string
    SSLCert               string
    SSLCertKey            string

    // If set, this will be appended to the Postgres URL by functions that
    // automatically open a connection to the server. That's equivalent to running
    // SET DATABASE=foo, which works even if the database doesn't (yet) exist.
    UseDatabase string

    // Stopper can be used to stop the server. If not set, a stopper will be
    // constructed and it can be gotten through TestServerInterface.Stopper().
    Stopper *stop.Stopper

TestServerArgs contains the parameters one can set when creating a test server. Notably, TestServerArgs are passed to serverutils.StartServer(). They're defined in base because they need to be shared between testutils/serverutils (test code) and server.TestServer (non-test code).

The zero value is suitable for most tests.

type TestingKnobs Uses

type TestingKnobs struct {
    Store                  ModuleTestingKnobs
    SQLExecutor            ModuleTestingKnobs
    SQLLeaseManager        ModuleTestingKnobs
    SQLSchemaChangeManager ModuleTestingKnobs

TestingKnobs contains facilities for controlling various parts of the system for testing.

Package base imports 14 packages (graph). Updated 2017-03-13. Refresh now. Tools for package owners. This is a dead-end fork (no commits since the fork).