Documentation
¶
Index ¶
- Constants
- func DefaultRetryOptions() retry.Options
- type Context
- func (ctx *Context) AdminURL() string
- func (ctx *Context) GetClientTLSConfig() (*tls.Config, error)
- func (ctx *Context) GetHTTPClient() (http.Client, error)
- func (ctx *Context) GetServerTLSConfig() (*tls.Config, error)
- func (ctx *Context) HTTPRequestScheme() string
- func (ctx *Context) InitDefaults()
- func (ctx *Context) PGURL(user string) (*url.URL, error)
- type ModuleTestingKnobs
- type TestClusterArgs
- type TestClusterReplicationMode
- type TestServerArgs
- type TestingKnobs
Constants ¶
const ( // From IANA Service Name and Transport Protocol Port Number Registry. See // https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=cockroachdb 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 = 200 * 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 )
Variables ¶
This section is empty.
Functions ¶
func DefaultRetryOptions ¶
DefaultRetryOptions should be used for retrying most network-dependent operations.
Types ¶
type Context ¶
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 https://github.com/grpc/grpc-go/issues/586. 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) GetClientTLSConfig ¶
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 ¶
GetHTTPClient returns the context http client, initializing it if needed. It uses the context client TLS config.
func (*Context) GetServerTLSConfig ¶
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 ¶
HTTPRequestScheme returns "http" or "https" based on the value of Insecure.
func (*Context) InitDefaults ¶
func (ctx *Context) InitDefaults()
InitDefaults sets up the default values for a context.
type ModuleTestingKnobs ¶
type ModuleTestingKnobs interface {
// ModuleTestingKnobs is a dummy function.
ModuleTestingKnobs()
}
ModuleTestingKnobs is an interface for testing knobs for a submodule.
type TestClusterArgs ¶
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 }
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 ¶
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. ReplicationManual )
type TestServerArgs ¶
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 // If set, the recording of events to the event log tables is disabled. DisableEventLog bool }
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 ¶
type TestingKnobs struct { Store ModuleTestingKnobs SQLExecutor ModuleTestingKnobs SQLLeaseManager ModuleTestingKnobs SQLSchemaChangeManager ModuleTestingKnobs }
TestingKnobs contains facilities for controlling various parts of the system for testing.