mockstore

package
v1.1.0-beta.0...-8832684 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const ImageFilePath = "/tmp/tidb-unistore-bootstraped-image/"

ImageFilePath is used by testing, it's the file path for the bootstraped store image.

Variables

View Source
var DDLCheckerInjector func(kv.Storage) kv.Storage

DDLCheckerInjector is used to break import cycle.

Functions

func BootstrapWithMultiRegions

func BootstrapWithMultiRegions(cluster testutils.Cluster, splitKeys ...[]byte) (storeID uint64, regionIDs, peerIDs []uint64)

BootstrapWithMultiRegions initializes a Cluster with multiple Regions and 1 Store. The number of Regions will be len(splitKeys) + 1.

func BootstrapWithMultiStores

func BootstrapWithMultiStores(cluster testutils.Cluster, n int) (storeIDs, peerIDs []uint64, regionID uint64, leaderPeer uint64)

BootstrapWithMultiStores initializes a Cluster with 1 Region and n Stores.

func BootstrapWithSingleStore

func BootstrapWithSingleStore(cluster testutils.Cluster) (storeID, peerID, regionID uint64)

BootstrapWithSingleStore initializes a Cluster with 1 Region and 1 Store.

func ImageAvailable

func ImageAvailable() bool

ImageAvailable checks whether the store image file is available.

func NewMockStore

func NewMockStore(options ...MockTiKVStoreOption) (kv.Storage, error)

NewMockStore creates a mocked tikv store, the path is the file path to store the data. If path is an empty string, a memory storage will be created.

Types

type EmbedUnistoreDriver

type EmbedUnistoreDriver struct{}

EmbedUnistoreDriver is in embedded unistore driver.

func (EmbedUnistoreDriver) Open

func (d EmbedUnistoreDriver) Open(path string) (kv.Storage, error)

Open creates a EmbedUnistore storage.

type MockTiKVDriver

type MockTiKVDriver struct{}

MockTiKVDriver is in memory mock TiKV driver.

func (MockTiKVDriver) Open

func (d MockTiKVDriver) Open(path string) (kv.Storage, error)

Open creates a MockTiKV storage.

type MockTiKVStoreOption

type MockTiKVStoreOption func(*mockOptions)

MockTiKVStoreOption is used to control some behavior of mock tikv.

func WithClientHijacker

func WithClientHijacker(hijacker func(tikv.Client) tikv.Client) MockTiKVStoreOption

WithClientHijacker hijacks KV client's behavior, makes it easy to simulate the network problem between TiDB and TiKV.

func WithClusterInspector

func WithClusterInspector(inspector func(testutils.Cluster)) MockTiKVStoreOption

WithClusterInspector lets user to inspect the mock cluster handler.

func WithDDLChecker

func WithDDLChecker() MockTiKVStoreOption

WithDDLChecker prepare injected DDL implementation for the domain of this store. It must be done before bootstrap to avoid data race with dom.ddl.

func WithMockTiFlash

func WithMockTiFlash(nodes int) MockTiKVStoreOption

WithMockTiFlash sets the mockStore to have N TiFlash stores (naming as tiflash0, tiflash1, ...).

func WithMultipleOptions

func WithMultipleOptions(opts ...MockTiKVStoreOption) MockTiKVStoreOption

WithMultipleOptions merges multiple options into one option.

func WithPDAddr

func WithPDAddr(addr []string) MockTiKVStoreOption

WithPDAddr set pd address for pd service discovery in mock PD client.

func WithPDClientHijacker

func WithPDClientHijacker(hijacker func(pd.Client) pd.Client) MockTiKVStoreOption

WithPDClientHijacker hijacks PD client's behavior, makes it easy to simulate the network problem between TiDB and PD.

func WithPath

func WithPath(path string) MockTiKVStoreOption

WithPath specifies the mocktikv path.

func WithStoreType

func WithStoreType(tp StoreType) MockTiKVStoreOption

WithStoreType lets user choose the backend storage's type.

func WithTiKVOptions

func WithTiKVOptions(opts ...tikv.Option) MockTiKVStoreOption

WithTiKVOptions sets KV options.

func WithTxnLocalLatches

func WithTxnLocalLatches(capacity uint) MockTiKVStoreOption

WithTxnLocalLatches enable txnLocalLatches, when capacity > 0.

type StoreType

type StoreType uint8

StoreType is the type of backend mock storage.

const (
	// MockTiKV is the mock storage based on goleveldb.
	MockTiKV StoreType = iota
	// EmbedUnistore is the mock storage based on unistore.
	EmbedUnistore
)

Jump to

Keyboard shortcuts

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