testcluster

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2017 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL