cockroach: Index | Files

package localtestcluster

import ""


Package Files


type InitFactoryFn Uses

type InitFactoryFn func(
    st *cluster.Settings,
    nodeDesc *roachpb.NodeDescriptor,
    tracer opentracing.Tracer,
    clock *hlc.Clock,
    latency time.Duration,
    stores kv.Sender,
    stopper *stop.Stopper,
    gossip *gossip.Gossip,
) kv.TxnSenderFactory

InitFactoryFn is a callback used to initiate the txn coordinator sender factory (we don't do it directly from this package to avoid a dependency on kv).

type LocalTestCluster Uses

type LocalTestCluster struct {
    Cfg               kvserver.StoreConfig
    Manual            *hlc.ManualClock
    Clock             *hlc.Clock
    Gossip            *gossip.Gossip
    Eng               storage.Engine
    Store             *kvserver.Store
    StoreTestingKnobs *kvserver.StoreTestingKnobs

    DB     *kv.DB
    Stores *kvserver.Stores

    Latency time.Duration // sleep for each RPC sent

    // DisableLivenessHeartbeat, if set, inhibits the heartbeat loop. Some tests
    // need this because, for example, the heartbeat loop increments some
    // transaction metrics.
    // However, note that without heartbeats, ranges with epoch-based leases
    // cannot be accessed because the leases cannot be granted.
    // See also DontCreateSystemRanges.
    DisableLivenessHeartbeat bool

    // DontCreateSystemRanges, if set, makes the cluster start with a single
    // range, not with all the system ranges (as regular cluster start).
    // If DisableLivenessHeartbeat is set, you probably want to also set this so
    // that ranges requiring epoch-based leases are not created automatically.
    DontCreateSystemRanges bool
    // contains filtered or unexported fields

A LocalTestCluster encapsulates an in-memory instantiation of a cockroach node with a single store using a local sender. Example usage of a LocalTestCluster follows:

s := &LocalTestCluster{}
s.Start(t, testutils.NewNodeTestBaseContext(),
defer s.Stop()

Note that the LocalTestCluster is different from server.TestCluster in that although it uses a distributed sender, there is no RPC traffic.

func (*LocalTestCluster) Start Uses

func (ltc *LocalTestCluster) Start(t testing.TB, baseCtx *base.Config, initFactory InitFactoryFn)

Start starts the test cluster by bootstrapping an in-memory store (defaults to maximum of 50M). The server is started, launching the node RPC server and all HTTP endpoints. Use the value of TestServer.Addr after Start() for client connections. Use Stop() to shutdown the server after the test completes.

func (*LocalTestCluster) Stop Uses

func (ltc *LocalTestCluster) Stop()

Stop stops the cluster.

func (*LocalTestCluster) Stopper Uses

func (ltc *LocalTestCluster) Stopper() *stop.Stopper

Stopper returns the Stopper.

Package localtestcluster imports 23 packages (graph). Updated 2020-08-13. Refresh now. Tools for package owners.