cockroach: github.com/cockroachdb/cockroach/pkg/testutils/testcluster Index | Files

package testcluster

import "github.com/cockroachdb/cockroach/pkg/testutils/testcluster"

Index

Package Files

testcluster.go

Variables

var TestClusterFactory serverutils.TestClusterFactory = testClusterFactoryImpl{}

TestClusterFactory can be passed to serverutils.InitTestClusterFactory

type TestCluster Uses

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 Uses

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 Uses

func (tc *TestCluster) AddReplicas(
    startKey roachpb.Key, targets ...roachpb.ReplicationTarget,
) (roachpb.RangeDescriptor, error)

AddReplicas is part of TestClusterInterface.

func (*TestCluster) AddReplicasMulti Uses

func (tc *TestCluster) AddReplicasMulti(
    kts ...serverutils.KeyAndTargets,
) ([]roachpb.RangeDescriptor, []error)

AddReplicasMulti is part of TestClusterInterface.

func (*TestCluster) AddReplicasOrFatal Uses

func (tc *TestCluster) AddReplicasOrFatal(
    t testing.TB, startKey roachpb.Key, targets ...roachpb.ReplicationTarget,
) roachpb.RangeDescriptor

AddReplicasOrFatal is part of TestClusterInterface.

func (*TestCluster) AddServer Uses

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 Uses

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 Uses

func (tc *TestCluster) FindRangeLeaseHolder(
    rangeDesc roachpb.RangeDescriptor, hint *roachpb.ReplicationTarget,
) (roachpb.ReplicationTarget, error)

FindRangeLeaseHolder is part of TestClusterInterface.

func (*TestCluster) LookupRange Uses

func (tc *TestCluster) LookupRange(key roachpb.Key) (roachpb.RangeDescriptor, error)

LookupRange is part of TestClusterInterface.

func (*TestCluster) LookupRangeOrFatal Uses

func (tc *TestCluster) LookupRangeOrFatal(t testing.TB, key roachpb.Key) roachpb.RangeDescriptor

LookupRangeOrFatal is part of TestClusterInterface.

func (*TestCluster) NumServers Uses

func (tc *TestCluster) NumServers() int

NumServers is part of TestClusterInterface.

func (*TestCluster) RemoveReplicas Uses

func (tc *TestCluster) RemoveReplicas(
    startKey roachpb.Key, targets ...roachpb.ReplicationTarget,
) (roachpb.RangeDescriptor, error)

RemoveReplicas is part of the TestServerInterface.

func (*TestCluster) RemoveReplicasOrFatal Uses

func (tc *TestCluster) RemoveReplicasOrFatal(
    t testing.TB, startKey roachpb.Key, targets ...roachpb.ReplicationTarget,
) roachpb.RangeDescriptor

RemoveReplicasOrFatal is part of TestClusterInterface.

func (*TestCluster) ReplicationMode Uses

func (tc *TestCluster) ReplicationMode() base.TestClusterReplicationMode

ReplicationMode implements TestClusterInterface.

func (*TestCluster) ScratchRange Uses

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 Uses

func (tc *TestCluster) Server(idx int) serverutils.TestServerInterface

Server is part of TestClusterInterface.

func (*TestCluster) ServerConn Uses

func (tc *TestCluster) ServerConn(idx int) *gosql.DB

ServerConn is part of TestClusterInterface.

func (*TestCluster) SplitRange Uses

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 Uses

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 Uses

func (tc *TestCluster) StopServer(idx int)

StopServer stops an individual server in the cluster.

func (*TestCluster) Stopper Uses

func (tc *TestCluster) Stopper() *stop.Stopper

Stopper returns the stopper for this testcluster.

func (*TestCluster) Target Uses

func (tc *TestCluster) Target(serverIdx int) roachpb.ReplicationTarget

Target returns a ReplicationTarget for the specified server.

func (*TestCluster) TransferRangeLease Uses

func (tc *TestCluster) TransferRangeLease(
    rangeDesc roachpb.RangeDescriptor, dest roachpb.ReplicationTarget,
) error

TransferRangeLease is part of the TestServerInterface.

func (*TestCluster) WaitForFullReplication Uses

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 Uses

func (tc *TestCluster) WaitForNodeLiveness(t testing.TB)

WaitForNodeLiveness waits until a liveness record is persisted for every node in the cluster.

func (*TestCluster) WaitForNodeStatuses Uses

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 Uses

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 Uses

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.

Package testcluster imports 25 packages (graph) and is imported by 2 packages. Updated 2019-09-19. Refresh now. Tools for package owners.