Documentation ¶
Index ¶
- Variables
- type TestCluster
- func (tc *TestCluster) AddReplicas(startKey roachpb.Key, targets ...roachpb.ReplicationTarget) (roachpb.RangeDescriptor, error)
- 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) NumServers() int
- func (tc *TestCluster) RemoveReplicas(startKey roachpb.Key, targets ...roachpb.ReplicationTarget) (roachpb.RangeDescriptor, error)
- 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) StopServer(idx int)
- func (tc *TestCluster) Stopper() *stop.Stopper
- func (tc *TestCluster) Target(serverIdx int) roachpb.ReplicationTarget
- func (tc *TestCluster) TransferRangeLease(rangeDesc roachpb.RangeDescriptor, dest roachpb.ReplicationTarget) error
- func (tc *TestCluster) WaitForFullReplication() error
- func (tc *TestCluster) WaitForSplitAndReplication(startKey roachpb.Key) error
- func (tc *TestCluster) WaitForStores(t testing.TB, g *gossip.Gossip)
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 cluster.Stop().
func (*TestCluster) AddReplicas ¶
func (tc *TestCluster) AddReplicas( startKey roachpb.Key, targets ...roachpb.ReplicationTarget, ) (roachpb.RangeDescriptor, error)
AddReplicas 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) 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) 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) 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) 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.
func (*TestCluster) WaitForSplitAndReplication ¶
func (tc *TestCluster) WaitForSplitAndReplication(startKey roachpb.Key) error
WaitForSplitAndReplication waits for a range which starts with startKey and then verifies that each replica in the range descriptor has been created.
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.