Documentation ¶
Index ¶
- Variables
- type ReplicationTarget
- type TestCluster
- func (tc *TestCluster) AddReplicas(startKey roachpb.Key, targets ...ReplicationTarget) (*roachpb.RangeDescriptor, error)
- func (tc *TestCluster) FindRangeLeaseHolder(rangeDesc *roachpb.RangeDescriptor, hint *ReplicationTarget) (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 ...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) ReplicationTarget
- func (tc *TestCluster) TransferRangeLease(rangeDesc *roachpb.RangeDescriptor, dest ReplicationTarget) error
- func (tc *TestCluster) WaitForFullReplication() 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 ReplicationTarget ¶
ReplicationTarget identifies a node/store pair.
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 ...ReplicationTarget, ) (*roachpb.RangeDescriptor, error)
AddReplicas adds replicas for a range on a set of stores. It's illegal to have multiple replicas of the same range on stores of a single node. The method blocks until a snapshot of the range has been copied to all the new replicas and the new replicas become part of the Raft group.
func (*TestCluster) FindRangeLeaseHolder ¶
func (tc *TestCluster) FindRangeLeaseHolder( rangeDesc *roachpb.RangeDescriptor, hint *ReplicationTarget, ) (ReplicationTarget, error)
FindRangeLeaseHolder returns the current lease holder for the given range. In particular, it returns one particular node's (the hint, if specified) view of the current lease. An error is returned if there's no active lease.
Note that not all nodes have necessarily applied the latest lease, particularly immediately after a TransferRangeLease() call. So specifying different hints can yield different results. The one server that's guaranteed to have applied the transfer is the previous lease holder.
func (*TestCluster) LookupRange ¶
func (tc *TestCluster) LookupRange(key roachpb.Key) (roachpb.RangeDescriptor, error)
LookupRange returns the descriptor of the range containing key.
func (*TestCluster) NumServers ¶
func (tc *TestCluster) NumServers() int
NumServers is part of TestClusterInterface.
func (*TestCluster) RemoveReplicas ¶
func (tc *TestCluster) RemoveReplicas( startKey roachpb.Key, targets ...ReplicationTarget, ) (*roachpb.RangeDescriptor, error)
RemoveReplicas removes one or more replicas from a range.
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) ReplicationTarget
Target returns a ReplicationTarget for the specified server.
func (*TestCluster) TransferRangeLease ¶
func (tc *TestCluster) TransferRangeLease( rangeDesc *roachpb.RangeDescriptor, dest ReplicationTarget, ) error
TransferRangeLease transfers the lease for a range from whoever has it to a particular store. That store must already have a replica of the range. If that replica already has the (active) lease, this method is a no-op.
When this method returns, it's guaranteed that the old lease holder has applied the new lease, but that's about it. It's not guaranteed that the new lease holder has applied it (so it might not know immediately that it is the new lease holder).
func (*TestCluster) WaitForFullReplication ¶
func (tc *TestCluster) WaitForFullReplication() error
WaitForFullReplication waits until all stores in the cluster have no ranges with replication pending.