mock

package
v7.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package mock is just for test only.

Index

Constants

This section is empty.

Variables

View Source
var MockInfoschema func(tbList []*model.TableInfo) sessionctx.InfoschemaMetaVersion

MockInfoschema only serves for test.

Functions

This section is empty.

Types

type Client

type Client struct {
	kv.RequestTypeSupportedChecker
	MockResponse kv.Response
}

Client implement kv.Client interface, mocked from "CopClient" defined in "store/tikv/copprocessor.go".

func (*Client) Send

func (c *Client) Send(_ context.Context, _ *kv.Request, _ interface{}, _ *kv.ClientSendOption) kv.Response

Send implement kv.Client interface.

type Context

type Context struct {
	Store kv.Storage // mock global variable
	// contains filtered or unexported fields
}

Context represents mocked sessionctx.Context.

func NewContext

func NewContext() *Context

NewContext creates a new mocked sessionctx.Context.

func (*Context) AddTableLock

func (*Context) AddTableLock(_ []model.TableLockTpInfo)

AddTableLock implements the sessionctx.Context interface.

func (*Context) BuiltinFunctionUsageInc

func (*Context) BuiltinFunctionUsageInc(_ string)

BuiltinFunctionUsageInc implements sessionctx.Context.

func (*Context) Cancel

func (c *Context) Cancel()

Cancel implements the Session interface.

func (*Context) CheckTableLocked

func (*Context) CheckTableLocked(_ int64) (bool, model.TableLockType)

CheckTableLocked implements the sessionctx.Context interface.

func (*Context) ClearDiskFullOpt

func (c *Context) ClearDiskFullOpt()

ClearDiskFullOpt clears allowed options of current operation in each TiKV disk usage level.

func (*Context) ClearValue

func (c *Context) ClearValue(key fmt.Stringer)

ClearValue implements sessionctx.Context ClearValue interface.

func (*Context) Close

func (*Context) Close()

Close implements the sessionctx.Context interface.

func (*Context) CommitTxn

func (c *Context) CommitTxn(ctx context.Context) error

CommitTxn indicates an expected call of CommitTxn.

func (*Context) DecodeSessionStates

DecodeSessionStates implements sessionctx.Context DecodeSessionStates interface.

func (*Context) DisableSandBoxMode

func (c *Context) DisableSandBoxMode()

DisableSandBoxMode enable the sandbox mode.

func (*Context) EnableSandBoxMode

func (c *Context) EnableSandBoxMode()

EnableSandBoxMode enable the sandbox mode.

func (*Context) EncodeSessionStates

EncodeSessionStates implements sessionctx.Context EncodeSessionStates interface.

func (*Context) Execute

func (*Context) Execute(_ context.Context, _ string) ([]sqlexec.RecordSet, error)

Execute implements sqlexec.SQLExecutor Execute interface.

func (*Context) ExecuteInternal

func (*Context) ExecuteInternal(_ context.Context, _ string, _ ...interface{}) (sqlexec.RecordSet, error)

ExecuteInternal implements sqlexec.SQLExecutor ExecuteInternal interface.

func (*Context) ExecuteStmt

func (*Context) ExecuteStmt(_ context.Context, _ ast.StmtNode) (sqlexec.RecordSet, error)

ExecuteStmt implements sqlexec.SQLExecutor ExecuteStmt interface.

func (*Context) GetAdvisoryLock

func (*Context) GetAdvisoryLock(_ string, _ int64) error

GetAdvisoryLock acquires an advisory lock

func (*Context) GetAllTableLocks

func (*Context) GetAllTableLocks() []model.TableLockTpInfo

GetAllTableLocks implements the sessionctx.Context interface.

func (*Context) GetBuiltinFunctionUsage

func (*Context) GetBuiltinFunctionUsage() map[string]uint32

GetBuiltinFunctionUsage implements sessionctx.Context GetBuiltinFunctionUsage interface.

func (*Context) GetClient

func (c *Context) GetClient() kv.Client

GetClient implements sessionctx.Context GetClient interface.

func (*Context) GetDomainInfoSchema

func (c *Context) GetDomainInfoSchema() sessionctx.InfoschemaMetaVersion

GetDomainInfoSchema returns the latest information schema in domain

func (*Context) GetExtensions

func (*Context) GetExtensions() *extension.SessionExtensions

GetExtensions returns the `*extension.SessionExtensions` object

func (*Context) GetGlobalSysVar

func (*Context) GetGlobalSysVar(_ sessionctx.Context, name string) (string, error)

GetGlobalSysVar implements GlobalVarAccessor GetGlobalSysVar interface.

func (*Context) GetInfoSchema

func (c *Context) GetInfoSchema() sessionctx.InfoschemaMetaVersion

GetInfoSchema implements sessionctx.Context GetInfoSchema interface.

func (*Context) GetMPPClient

func (c *Context) GetMPPClient() kv.MPPClient

GetMPPClient implements sessionctx.Context GetMPPClient interface.

func (*Context) GetPlanCache

func (c *Context) GetPlanCache(_ bool) sessionctx.PlanCache

GetPlanCache implements the sessionctx.Context interface.

func (*Context) GetPreparedTxnFuture

func (c *Context) GetPreparedTxnFuture() sessionctx.TxnFuture

GetPreparedTxnFuture returns the TxnFuture if it is prepared. It returns nil otherwise.

func (*Context) GetSessionManager

func (c *Context) GetSessionManager() util.SessionManager

GetSessionManager implements the sessionctx.Context interface.

func (*Context) GetSessionVars

func (c *Context) GetSessionVars() *variable.SessionVars

GetSessionVars implements the sessionctx.Context GetSessionVars interface.

func (*Context) GetStmtStats

func (*Context) GetStmtStats() *stmtstats.StatementStats

GetStmtStats implements the sessionctx.Context interface.

func (*Context) GetStore

func (c *Context) GetStore() kv.Storage

GetStore gets the store of session.

func (*Context) GetTxnWriteThroughputSLI

func (*Context) GetTxnWriteThroughputSLI() *sli.TxnWriteThroughputSLI

GetTxnWriteThroughputSLI implements the sessionctx.Context interface.

func (*Context) GoCtx

func (c *Context) GoCtx() context.Context

GoCtx returns standard sessionctx.Context that bind with current transaction.

func (*Context) HasDirtyContent

func (*Context) HasDirtyContent(_ int64) bool

HasDirtyContent implements sessionctx.Context ClearValue interface.

func (*Context) HasLockedTables

func (*Context) HasLockedTables() bool

HasLockedTables implements the sessionctx.Context interface.

func (*Context) InSandBoxMode

func (c *Context) InSandBoxMode() bool

InSandBoxMode indicates that this Session is in sandbox mode

func (*Context) IsDDLOwner

func (*Context) IsDDLOwner() bool

IsDDLOwner checks whether this session is DDL owner.

func (*Context) NewStaleTxnWithStartTS

func (c *Context) NewStaleTxnWithStartTS(ctx context.Context, _ uint64) error

NewStaleTxnWithStartTS implements the sessionctx.Context interface.

func (*Context) NewTxn

func (c *Context) NewTxn(context.Context) error

NewTxn implements the sessionctx.Context interface.

func (*Context) PrepareTSFuture

func (c *Context) PrepareTSFuture(_ context.Context, future oracle.Future, _ string) error

PrepareTSFuture implements the sessionctx.Context interface.

func (*Context) RefreshTxnCtx

func (c *Context) RefreshTxnCtx(ctx context.Context) error

RefreshTxnCtx implements the sessionctx.Context interface.

func (*Context) RefreshVars

func (*Context) RefreshVars(_ context.Context) error

RefreshVars implements the sessionctx.Context interface.

func (*Context) ReleaseAdvisoryLock

func (*Context) ReleaseAdvisoryLock(_ string) bool

ReleaseAdvisoryLock releases an advisory lock

func (*Context) ReleaseAllAdvisoryLocks

func (*Context) ReleaseAllAdvisoryLocks() int

ReleaseAllAdvisoryLocks releases all advisory locks

func (*Context) ReleaseAllTableLocks

func (*Context) ReleaseAllTableLocks()

ReleaseAllTableLocks implements the sessionctx.Context interface.

func (*Context) ReleaseTableLockByTableIDs

func (*Context) ReleaseTableLockByTableIDs(_ []int64)

ReleaseTableLockByTableIDs implements the sessionctx.Context interface.

func (*Context) ReleaseTableLocks

func (*Context) ReleaseTableLocks(_ []model.TableLockTpInfo)

ReleaseTableLocks implements the sessionctx.Context interface.

func (*Context) RollbackTxn

func (c *Context) RollbackTxn(_ context.Context)

RollbackTxn indicates an expected call of RollbackTxn.

func (*Context) SetDiskFullOpt

func (c *Context) SetDiskFullOpt(level kvrpcpb.DiskFullOpt)

SetDiskFullOpt sets allowed options of current operation in each TiKV disk usage level.

func (*Context) SetGlobalSysVar

func (*Context) SetGlobalSysVar(_ sessionctx.Context, name string, value string) error

SetGlobalSysVar implements GlobalVarAccessor SetGlobalSysVar interface.

func (*Context) SetSessionManager

func (c *Context) SetSessionManager(sm util.SessionManager)

SetSessionManager set the session manager.

func (*Context) SetValue

func (c *Context) SetValue(key fmt.Stringer, value interface{})

SetValue implements sessionctx.Context SetValue interface.

func (*Context) ShowProcess

func (*Context) ShowProcess() *util.ProcessInfo

ShowProcess implements sessionctx.Context ShowProcess interface.

func (*Context) StmtCommit

func (*Context) StmtCommit(context.Context)

StmtCommit implements the sessionctx.Context interface.

func (*Context) StmtGetMutation

func (*Context) StmtGetMutation(_ int64) *binlog.TableMutation

StmtGetMutation implements the sessionctx.Context interface.

func (*Context) StmtRollback

func (*Context) StmtRollback(context.Context, bool)

StmtRollback implements the sessionctx.Context interface.

func (*Context) StoreIndexUsage

func (*Context) StoreIndexUsage(_ int64, _ int64, _ int64)

StoreIndexUsage strores the index usage information.

func (*Context) StoreQueryFeedback

func (*Context) StoreQueryFeedback(_ interface{})

StoreQueryFeedback stores the query feedback.

func (*Context) Txn

func (c *Context) Txn(bool) (kv.Transaction, error)

Txn implements sessionctx.Context Txn interface.

func (*Context) UpdateColStatsUsage

func (*Context) UpdateColStatsUsage(_ []model.TableItemID)

UpdateColStatsUsage updates the column stats usage.

func (*Context) Value

func (c *Context) Value(key fmt.Stringer) interface{}

Value implements sessionctx.Context Value interface.

type HookKeyForTest

type HookKeyForTest string

HookKeyForTest is as alias, used by context.WithValue. golint forbits using string type as key in context.WithValue.

type MockedIter

type MockedIter struct {
	kv.Iterator
	// contains filtered or unexported fields
}

MockedIter is a mocked iter for test

func NewMockIterFromRecords

func NewMockIterFromRecords(t *testing.T, records []*kv.Entry, failOnMultiClose bool) *MockedIter

NewMockIterFromRecords creates a new MockedIter

func (*MockedIter) Close

func (i *MockedIter) Close()

Close implements kv.Iterator.Close

func (*MockedIter) Closed

func (i *MockedIter) Closed() bool

Closed returns if the iter is closed

func (*MockedIter) FailOnMultiClose

func (i *MockedIter) FailOnMultiClose(fail bool)

FailOnMultiClose set if should fail when Close is invoked more than once

func (*MockedIter) GetInjectedNextError

func (i *MockedIter) GetInjectedNextError() error

GetInjectedNextError get the injected error

func (*MockedIter) InjectNextError

func (i *MockedIter) InjectNextError(err error)

InjectNextError injects error to its Next

func (*MockedIter) Next

func (i *MockedIter) Next() error

Next implements kv.Iterator.Next

type SliceIter

type SliceIter struct {
	// contains filtered or unexported fields
}

SliceIter is used to iterate slice

func NewSliceIter

func NewSliceIter(data []*kv.Entry) *SliceIter

NewSliceIter creates a new SliceIter

func (*SliceIter) Close

func (i *SliceIter) Close()

Close closes the iterator.

func (*SliceIter) GetSlice

func (i *SliceIter) GetSlice() []*kv.Entry

GetSlice returns the inner slice

func (*SliceIter) Key

func (i *SliceIter) Key() kv.Key

Key returns the current key.

func (*SliceIter) Next

func (i *SliceIter) Next() error

Next goes the next position. Always return error for this iterator

func (*SliceIter) Valid

func (i *SliceIter) Valid() bool

Valid returns true if the current iterator is valid.

func (*SliceIter) Value

func (i *SliceIter) Value() []byte

Value returns the current value.

type Store

type Store struct {
	Client kv.Client
}

Store implements kv.Storage interface.

func (*Store) Begin

func (*Store) Begin(_ ...tikv.TxnOption) (kv.Transaction, error)

Begin implements kv.Storage interface.

func (*Store) Close

func (*Store) Close() error

Close implements kv.Storage interface.

func (*Store) CurrentVersion

func (*Store) CurrentVersion(_ string) (kv.Version, error)

CurrentVersion implements kv.Storage interface.

func (*Store) Describe

func (*Store) Describe() string

Describe implements kv.Storage interface.

func (*Store) GetClient

func (s *Store) GetClient() kv.Client

GetClient implements kv.Storage interface.

func (*Store) GetCodec

func (*Store) GetCodec() tikv.Codec

GetCodec implements kv.Storage interface.

func (*Store) GetLockWaits

func (*Store) GetLockWaits() ([]*deadlockpb.WaitForEntry, error)

GetLockWaits implements kv.Storage interface.

func (*Store) GetMPPClient

func (*Store) GetMPPClient() kv.MPPClient

GetMPPClient implements kv.Storage interface.

func (*Store) GetMemCache

func (*Store) GetMemCache() kv.MemManager

GetMemCache implements kv.Storage interface

func (*Store) GetMinSafeTS

func (*Store) GetMinSafeTS(_ string) uint64

GetMinSafeTS implements kv.Storage interface.

func (*Store) GetOracle

func (*Store) GetOracle() oracle.Oracle

GetOracle implements kv.Storage interface.

func (*Store) GetSnapshot

func (*Store) GetSnapshot(_ kv.Version) kv.Snapshot

GetSnapshot implements kv.Storage interface.

func (*Store) Name

func (*Store) Name() string

Name implements kv.Storage interface.

func (*Store) ShowStatus

func (*Store) ShowStatus(_ context.Context, _ string) (interface{}, error)

ShowStatus implements kv.Storage interface.

func (*Store) SupportDeleteRange

func (*Store) SupportDeleteRange() bool

SupportDeleteRange implements kv.Storage interface.

func (*Store) UUID

func (*Store) UUID() string

UUID implements kv.Storage interface.

Jump to

Keyboard shortcuts

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