Documentation ¶
Index ¶
- Variables
- type TestCluster
- func (tc *TestCluster) AddReplicas(startKey roachpb.Key, targets ...roachpb.ReplicationTarget) (roachpb.RangeDescriptor, error)
- func (tc *TestCluster) AddReplicasMulti(kts ...serverutils.KeyAndTargets) ([]roachpb.RangeDescriptor, []error)
- func (tc *TestCluster) AddReplicasOrFatal(t testing.TB, startKey roachpb.Key, targets ...roachpb.ReplicationTarget) roachpb.RangeDescriptor
- func (tc *TestCluster) AddServer(t testing.TB, serverArgs base.TestServerArgs)
- func (tc *TestCluster) FindRangeLease(rangeDesc roachpb.RangeDescriptor, hint *roachpb.ReplicationTarget) (_ roachpb.Lease, now hlc.Timestamp, _ error)
- func (tc *TestCluster) FindRangeLeaseHolder(rangeDesc roachpb.RangeDescriptor, hint *roachpb.ReplicationTarget) (roachpb.ReplicationTarget, error)
- func (tc *TestCluster) LookupRange(key roachpb.Key) (roachpb.RangeDescriptor, error)
- func (tc *TestCluster) LookupRangeOrFatal(t testing.TB, key roachpb.Key) roachpb.RangeDescriptor
- func (tc *TestCluster) NumServers() int
- func (tc *TestCluster) RemoveReplicas(startKey roachpb.Key, targets ...roachpb.ReplicationTarget) (roachpb.RangeDescriptor, error)
- func (tc *TestCluster) RemoveReplicasOrFatal(t testing.TB, startKey roachpb.Key, targets ...roachpb.ReplicationTarget) roachpb.RangeDescriptor
- func (tc *TestCluster) ReplicationMode() base.TestClusterReplicationMode
- func (tc *TestCluster) ScratchRange(t testing.TB) roachpb.Key
- func (tc *TestCluster) Server(idx int) serverutils.TestServerInterface
- func (tc *TestCluster) ServerConn(idx int) *gosql.DB
- func (tc *TestCluster) SplitRange(splitKey roachpb.Key) (roachpb.RangeDescriptor, roachpb.RangeDescriptor, error)
- func (tc *TestCluster) SplitRangeOrFatal(t testing.TB, splitKey roachpb.Key) (roachpb.RangeDescriptor, roachpb.RangeDescriptor)
- func (tc *TestCluster) StopServer(idx int)
- func (tc *TestCluster) Stopper() *stop.Stopper
- func (tc *TestCluster) Target(serverIdx int) roachpb.ReplicationTarget
- func (tc *TestCluster) Targets(serverIdxs ...int) []roachpb.ReplicationTarget
- func (tc *TestCluster) ToggleReplicateQueues(active bool)
- func (tc *TestCluster) TransferRangeLease(rangeDesc roachpb.RangeDescriptor, dest roachpb.ReplicationTarget) error
- func (tc *TestCluster) WaitForFullReplication() error
- func (tc *TestCluster) WaitForNodeLiveness(t testing.TB)
- func (tc *TestCluster) WaitForNodeStatuses(t testing.TB)
- func (tc *TestCluster) WaitForSplitAndInitialization(startKey roachpb.Key) error
- func (tc *TestCluster) WaitForStores(t testing.TB, g *gossip.Gossip)
- func (tc *TestCluster) WaitForVoters(startKey roachpb.Key, targets ...roachpb.ReplicationTarget) error
Constants ¶
This section is empty.
Variables ¶
var TestClusterFactory serverutils.TestClusterFactory = testClusterFactoryImpl{}
TestClusterFactory can be passed to serverutils.InitTestClusterFactory
Functions ¶
This section is empty.
Types ¶
type TestCluster ¶
type TestCluster struct { Servers []*server.TestServer Conns []*gosql.DB // contains filtered or unexported fields }
TestCluster represents a set of TestServers. The hope is that it can be used analoguous to TestServer, but with control over range replication.
func StartTestCluster ¶
func StartTestCluster(t testing.TB, nodes int, args base.TestClusterArgs) *TestCluster
StartTestCluster starts up a TestCluster made up of `nodes` in-memory testing servers. The cluster should be stopped using TestCluster.Stopper().Stop().
func (*TestCluster) AddReplicas ¶
func (tc *TestCluster) AddReplicas( startKey roachpb.Key, targets ...roachpb.ReplicationTarget, ) (roachpb.RangeDescriptor, error)
AddReplicas is part of TestClusterInterface.
func (*TestCluster) AddReplicasMulti ¶
func (tc *TestCluster) AddReplicasMulti( kts ...serverutils.KeyAndTargets, ) ([]roachpb.RangeDescriptor, []error)
AddReplicasMulti is part of TestClusterInterface.
func (*TestCluster) AddReplicasOrFatal ¶
func (tc *TestCluster) AddReplicasOrFatal( t testing.TB, startKey roachpb.Key, targets ...roachpb.ReplicationTarget, ) roachpb.RangeDescriptor
AddReplicasOrFatal is part of TestClusterInterface.
func (*TestCluster) AddServer ¶
func (tc *TestCluster) AddServer(t testing.TB, serverArgs base.TestServerArgs)
AddServer creates a server with the specified arguments and appends it to the TestCluster.
The new Server's copy of serverArgs might be changed according to the cluster's ReplicationMode.
func (*TestCluster) FindRangeLease ¶
func (tc *TestCluster) FindRangeLease( rangeDesc roachpb.RangeDescriptor, hint *roachpb.ReplicationTarget, ) (_ roachpb.Lease, now hlc.Timestamp, _ error)
FindRangeLease is similar to FindRangeLeaseHolder but returns a Lease proto without verifying if the lease is still active. Instead, it returns a time- stamp taken off the queried node's clock.
func (*TestCluster) FindRangeLeaseHolder ¶
func (tc *TestCluster) FindRangeLeaseHolder( rangeDesc roachpb.RangeDescriptor, hint *roachpb.ReplicationTarget, ) (roachpb.ReplicationTarget, error)
FindRangeLeaseHolder is part of TestClusterInterface.
func (*TestCluster) LookupRange ¶
func (tc *TestCluster) LookupRange(key roachpb.Key) (roachpb.RangeDescriptor, error)
LookupRange is part of TestClusterInterface.
func (*TestCluster) LookupRangeOrFatal ¶
func (tc *TestCluster) LookupRangeOrFatal(t testing.TB, key roachpb.Key) roachpb.RangeDescriptor
LookupRangeOrFatal is part of TestClusterInterface.
func (*TestCluster) NumServers ¶
func (tc *TestCluster) NumServers() int
NumServers is part of TestClusterInterface.
func (*TestCluster) RemoveReplicas ¶
func (tc *TestCluster) RemoveReplicas( startKey roachpb.Key, targets ...roachpb.ReplicationTarget, ) (roachpb.RangeDescriptor, error)
RemoveReplicas is part of the TestServerInterface.
func (*TestCluster) RemoveReplicasOrFatal ¶
func (tc *TestCluster) RemoveReplicasOrFatal( t testing.TB, startKey roachpb.Key, targets ...roachpb.ReplicationTarget, ) roachpb.RangeDescriptor
RemoveReplicasOrFatal is part of TestClusterInterface.
func (*TestCluster) ReplicationMode ¶
func (tc *TestCluster) ReplicationMode() base.TestClusterReplicationMode
ReplicationMode implements TestClusterInterface.
func (*TestCluster) ScratchRange ¶
func (tc *TestCluster) ScratchRange(t testing.TB) roachpb.Key
ScratchRange returns the start key of a span of keyspace suitable for use as kv scratch space (it doesn't overlap system spans or SQL tables). The range is lazily split off on the first call to ScratchRange.
func (*TestCluster) Server ¶
func (tc *TestCluster) Server(idx int) serverutils.TestServerInterface
Server is part of TestClusterInterface.
func (*TestCluster) ServerConn ¶
func (tc *TestCluster) ServerConn(idx int) *gosql.DB
ServerConn is part of TestClusterInterface.
func (*TestCluster) SplitRange ¶
func (tc *TestCluster) SplitRange( splitKey roachpb.Key, ) (roachpb.RangeDescriptor, roachpb.RangeDescriptor, error)
SplitRange splits the range containing splitKey. The right range created by the split starts at the split key and extends to the original range's end key. Returns the new descriptors of the left and right ranges.
splitKey must correspond to a SQL table key (it must end with a family ID / col ID).
func (*TestCluster) SplitRangeOrFatal ¶
func (tc *TestCluster) SplitRangeOrFatal( t testing.TB, splitKey roachpb.Key, ) (roachpb.RangeDescriptor, roachpb.RangeDescriptor)
SplitRangeOrFatal is the same as SplitRange but will Fatal the test on error.
func (*TestCluster) StopServer ¶
func (tc *TestCluster) StopServer(idx int)
StopServer stops an individual server in the cluster.
func (*TestCluster) Stopper ¶
func (tc *TestCluster) Stopper() *stop.Stopper
Stopper returns the stopper for this testcluster.
func (*TestCluster) Target ¶
func (tc *TestCluster) Target(serverIdx int) roachpb.ReplicationTarget
Target returns a ReplicationTarget for the specified server.
func (*TestCluster) Targets ¶
func (tc *TestCluster) Targets(serverIdxs ...int) []roachpb.ReplicationTarget
Targets creates a slice of ReplicationTarget where each entry corresponds to a call to tc.Target() for serverIdx in serverIdxs.
func (*TestCluster) ToggleReplicateQueues ¶
func (tc *TestCluster) ToggleReplicateQueues(active bool)
ToggleReplicateQueues activates or deactivates the replication queues on all the stores on all the nodes.
func (*TestCluster) TransferRangeLease ¶
func (tc *TestCluster) TransferRangeLease( rangeDesc roachpb.RangeDescriptor, dest roachpb.ReplicationTarget, ) error
TransferRangeLease is part of the TestServerInterface.
func (*TestCluster) WaitForFullReplication ¶
func (tc *TestCluster) WaitForFullReplication() error
WaitForFullReplication waits until all stores in the cluster have no ranges with replication pending.
TODO(andrei): This method takes inexplicably long. I think it shouldn't need any retries. See #38565.
func (*TestCluster) WaitForNodeLiveness ¶
func (tc *TestCluster) WaitForNodeLiveness(t testing.TB)
WaitForNodeLiveness waits until a liveness record is persisted for every node in the cluster.
func (*TestCluster) WaitForNodeStatuses ¶
func (tc *TestCluster) WaitForNodeStatuses(t testing.TB)
WaitForNodeStatuses waits until a NodeStatus is persisted for every node and store in the cluster.
func (*TestCluster) WaitForSplitAndInitialization ¶
func (tc *TestCluster) WaitForSplitAndInitialization(startKey roachpb.Key) error
WaitForSplitAndInitialization waits for a range which starts with startKey and then verifies that each replica in the range descriptor has been created.
NB: This doesn't actually wait for full upreplication to whatever the zone config specifies.
func (*TestCluster) WaitForStores ¶
func (tc *TestCluster) WaitForStores(t testing.TB, g *gossip.Gossip)
WaitForStores waits for all of the store descriptors to be gossiped. Servers other than the first "bootstrap" their stores asynchronously, but we'd like to wait for all of the stores to be initialized before returning the TestCluster.
func (*TestCluster) WaitForVoters ¶
func (tc *TestCluster) WaitForVoters( startKey roachpb.Key, targets ...roachpb.ReplicationTarget, ) error
WaitForVoters waits for the targets to be voters in the range indicated by startKey.