Documentation ¶
Index ¶
- Constants
- func Caller(depth ...int) string
- func FillCerts(cfg *base.Config)
- func IsError(err error, re string) bool
- func IsPError(pErr *roachpb.Error, re string) bool
- func IsSQLRetryableError(err error) bool
- func MakeCaller(depth ...int) func() string
- func MakeKey(keys ...[]byte) []byte
- func NewNodeTestBaseContext() *base.Config
- func NewTestBaseContext(user string) *base.Config
- func SortStructs(s interface{}, fieldNames ...string)
- func Stress() bool
- func SucceedsSoon(t testing.TB, fn func() error)
- func SucceedsSoonDepth(depth int, t testing.TB, fn func() error)
- func TempDir(t testing.TB) (string, func())
- type PartitionableConn
- func (c *PartitionableConn) Finish()
- func (c *PartitionableConn) PartitionC2S()
- func (c *PartitionableConn) PartitionS2C()
- func (c *PartitionableConn) Read(b []byte) (n int, err error)
- func (c *PartitionableConn) UnpartitionC2S()
- func (c *PartitionableConn) UnpartitionS2C()
- func (c *PartitionableConn) Write(b []byte) (n int, err error)
Constants ¶
const DefaultSucceedsSoonDuration = 45 * time.Second
DefaultSucceedsSoonDuration is the maximum amount of time unittests will wait for a condition to become true. See SucceedsSoon().
Variables ¶
This section is empty.
Functions ¶
func Caller ¶
Caller returns filename and line number info for the specified stack depths. The info is formated as <file>:<line> and each entry is separated for a space.
func IsError ¶
IsError returns true if the error string matches the supplied regex. An empty regex is interpreted to mean that a nil error is expected.
func IsPError ¶
IsPError returns true if pErr's message matches the supplied regex. An empty regex is interpreted to mean that a nil error is expected.
func IsSQLRetryableError ¶
IsSQLRetryableError returns true if err is retryable. This is true for errors that show a connection issue or an issue with the node itself. This can occur when a node is restarting or is unstable in some other way. Note that retryable errors may occur event in cases where the SQL execution ran to completion.
func MakeCaller ¶
MakeCaller returns a function which will invoke Caller with the specified arguments.
func NewNodeTestBaseContext ¶
NewNodeTestBaseContext creates a base context for testing. This uses embedded certs and the default node user. The default node user has both server and client certificates.
func NewTestBaseContext ¶
NewTestBaseContext creates a secure base context for user.
func SortStructs ¶
func SortStructs(s interface{}, fieldNames ...string)
SortStructs sorts the given slice of structs using the given fields as the ordered sort keys.
func Stress ¶
func Stress() bool
Stress returns true iff the process is running as part of CockroachDB's nightly stress tests.
func SucceedsSoon ¶
SucceedsSoon fails the test (with t.Fatal) unless the supplied function runs without error within a preset maximum duration. The function is invoked immediately at first and then successively with an exponential backoff starting at 1ns and ending at the maximum duration (currently 15s).
func SucceedsSoonDepth ¶
SucceedsSoonDepth is like SucceedsSoon() but with an additional stack depth offset.
Types ¶
type PartitionableConn ¶
type PartitionableConn struct { // We embed a net.Conn so that we inherit the interface. Note that we override // Read() and Write(). // // This embedded Conn is half of a net.Pipe(). The other half is clientConn. net.Conn // contains filtered or unexported fields }
PartitionableConn is an implementation of net.Conn that allows the client->server and/or the server->client directions to be temporarily partitioned.
A PartitionableConn wraps a provided net.Conn (the serverConn member) and forwards every read and write to it. It interposes an arbiter in front of it that's used to block reads/writes while the PartitionableConn is in the partitioned mode.
While a direction is partitioned, data sent in that direction doesn't flow. A write while partitioned will block after an internal buffer gets filled. Data written to the conn after the partition has been established is not delivered to the remote party until the partition is lifted. At that time, all the buffered data is delivered. Since data is delivered async, data written before the partition is established may or may not be blocked by the partition; use application-level ACKs if that's important.
func NewPartitionableConn ¶
func NewPartitionableConn(serverConn net.Conn) *PartitionableConn
NewPartitionableConn wraps serverConn in a PartitionableConn.
func (*PartitionableConn) Finish ¶
func (c *PartitionableConn) Finish()
Finish removes any partitions that may exist so that blocked goroutines can finish. Finish() must be called if a connection may have been left in a partitioned state.
func (*PartitionableConn) PartitionC2S ¶
func (c *PartitionableConn) PartitionC2S()
PartitionC2S partitions the client-to-server direction. If UnpartitionC2S() is not called, Finish() must be called.
func (*PartitionableConn) PartitionS2C ¶
func (c *PartitionableConn) PartitionS2C()
PartitionS2C partitions the server-to-client direction. If UnpartitionS2C() is not called, Finish() must be called.
func (*PartitionableConn) Read ¶
func (c *PartitionableConn) Read(b []byte) (n int, err error)
Read is part of the net.Conn interface.
func (*PartitionableConn) UnpartitionC2S ¶
func (c *PartitionableConn) UnpartitionC2S()
UnpartitionC2S lifts an existing client-to-server partition.
func (*PartitionableConn) UnpartitionS2C ¶
func (c *PartitionableConn) UnpartitionS2C()
UnpartitionS2C lifts an existing server-to-client partition.