Documentation ¶
Index ¶
- Variables
- func CreateMockStore(t testing.TB, opts ...mockstore.MockTiKVStoreOption) kv.Storage
- func CreateMockStoreAndDomain(t testing.TB, opts ...mockstore.MockTiKVStoreOption) (kv.Storage, *domain.Domain)
- func CreateMockStoreAndDomainWithSchemaLease(t testing.TB, lease time.Duration, opts ...mockstore.MockTiKVStoreOption) (kv.Storage, *domain.Domain)
- func CreateMockStoreWithSchemaLease(t testing.TB, lease time.Duration, opts ...mockstore.MockTiKVStoreOption) kv.Storage
- func GetStack() []byte
- func Rows(args ...string) [][]interface{}
- func RowsWithSep(sep string, args ...string) [][]interface{}
- func TryRetrieveSession(ctx context.Context) session.Session
- func WithPruneMode(tk *TestKit, mode variable.PartitionPruneMode, f func())
- type AsyncTestKit
- func (tk *AsyncTestKit) CloseSession(ctx context.Context)
- func (tk *AsyncTestKit) ConcurrentRun(concurrent int, loops int, ...)
- func (tk *AsyncTestKit) Exec(ctx context.Context, sql string, args ...interface{}) (sqlexec.RecordSet, error)
- func (tk *AsyncTestKit) ExecToErr(ctx context.Context, sql string, args ...interface{}) error
- func (tk *AsyncTestKit) MustExec(ctx context.Context, sql string, args ...interface{})
- func (tk *AsyncTestKit) MustGetErrMsg(ctx context.Context, sql string, errStr string)
- func (tk *AsyncTestKit) MustQuery(ctx context.Context, sql string, args ...interface{}) *Result
- func (tk *AsyncTestKit) OpenSession(ctx context.Context, db string) context.Context
- type DBTestKit
- func (tk *DBTestKit) GetDB() *sql.DB
- func (tk *DBTestKit) MustExec(sql string, args ...interface{}) sql.Result
- func (tk *DBTestKit) MustExecPrepared(stmt *sql.Stmt, args ...interface{}) sql.Result
- func (tk *DBTestKit) MustPrepare(query string) *sql.Stmt
- func (tk *DBTestKit) MustQuery(sql string, args ...interface{}) *sql.Rows
- func (tk *DBTestKit) MustQueryPrepared(stmt *sql.Stmt, args ...interface{}) *sql.Rows
- func (tk *DBTestKit) MustQueryRows(query string, args ...interface{})
- type MockSessionManager
- func (msm *MockSessionManager) CheckOldRunningTxn(job2ver map[int64]int64, job2ids map[int64]string)
- func (*MockSessionManager) DeleteInternalSession(interface{})
- func (*MockSessionManager) GetInternalSessionStartTSList() []uint64
- func (msm *MockSessionManager) GetMinStartTS(lowerBound uint64) (ts uint64)
- func (msm *MockSessionManager) GetProcessInfo(id uint64) (*util.ProcessInfo, bool)
- func (*MockSessionManager) Kill(uint64, bool)
- func (*MockSessionManager) KillAllConnections()
- func (msm *MockSessionManager) KillNonFlashbackClusterConn()
- func (msm *MockSessionManager) ServerID() uint64
- func (msm *MockSessionManager) ShowProcessList() map[uint64]*util.ProcessInfo
- func (msm *MockSessionManager) ShowTxnList() []*txninfo.TxnInfo
- func (*MockSessionManager) StoreInternalSession(interface{})
- func (*MockSessionManager) UpdateTLSConfig(*tls.Config)
- type RegionProperityClient
- type Result
- func (res *Result) AddComment(c string)
- func (res *Result) Check(expected [][]interface{})
- func (res *Result) CheckAt(cols []int, expected [][]interface{})
- func (res *Result) CheckWithFunc(expected [][]interface{}, f func([]string, []interface{}) bool)
- func (res *Result) Rows() [][]interface{}
- func (res *Result) Sort() *Result
- type SteppedTestKit
- func (tk *SteppedTestKit) Continue() *SteppedTestKit
- func (tk *SteppedTestKit) ExpectIdle()
- func (tk *SteppedTestKit) ExpectStopOnAnyBreakPoint()
- func (tk *SteppedTestKit) ExpectStopOnBreakPoint(breakPoint string)
- func (tk *SteppedTestKit) GetQueryResult() *Result
- func (tk *SteppedTestKit) GetResult() any
- func (tk *SteppedTestKit) MustExec(sql string, args ...interface{})
- func (tk *SteppedTestKit) MustQuery(sql string, args ...interface{}) *Result
- func (tk *SteppedTestKit) SetBreakPoints(breakPoints ...string)
- func (tk *SteppedTestKit) SteppedMustExec(sql string, args ...interface{}) *SteppedTestKit
- func (tk *SteppedTestKit) SteppedMustQuery(sql string, args ...interface{}) *SteppedTestKit
- type TestKit
- func (tk *TestKit) CheckExecResult(affectedRows, insertID int64)
- func (tk *TestKit) CheckLastMessage(msg string)
- func (tk *TestKit) Exec(sql string, args ...interface{}) (sqlexec.RecordSet, error)
- func (tk *TestKit) ExecToErr(sql string, args ...interface{}) error
- func (tk *TestKit) ExecWithContext(ctx context.Context, sql string, args ...interface{}) (rs sqlexec.RecordSet, err error)
- func (tk *TestKit) HasKeywordInOperatorInfo(sql string, keyword string, args ...interface{}) bool
- func (tk *TestKit) HasPlan(sql string, plan string, args ...interface{}) bool
- func (tk *TestKit) HasPlan4ExplainFor(result *Result, plan string) bool
- func (tk *TestKit) HasPlanForLastExecution(plan string) bool
- func (tk *TestKit) HasTiFlashPlan(sql string, args ...interface{}) bool
- func (tk *TestKit) MustContainErrMsg(sql string, errStr interface{})
- func (tk *TestKit) MustExec(sql string, args ...interface{})
- func (tk *TestKit) MustExecToErr(sql string, args ...interface{})
- func (tk *TestKit) MustExecWithContext(ctx context.Context, sql string, args ...interface{})
- func (tk *TestKit) MustGetDBError(sql string, dberr *terror.Error)
- func (tk *TestKit) MustGetErrCode(sql string, errCode int)
- func (tk *TestKit) MustGetErrMsg(sql string, errStr string)
- func (tk *TestKit) MustIndexLookup(sql string, args ...interface{}) *Result
- func (tk *TestKit) MustMatchErrMsg(sql string, errRx interface{})
- func (tk *TestKit) MustNoGlobalStats(table string) bool
- func (tk *TestKit) MustPartition(sql string, partitions string, args ...interface{}) *Result
- func (tk *TestKit) MustPartitionByList(sql string, partitions []string, args ...interface{}) *Result
- func (tk *TestKit) MustPointGet(sql string, args ...interface{}) *Result
- func (tk *TestKit) MustQuery(sql string, args ...interface{}) *Result
- func (tk *TestKit) MustQueryWithContext(ctx context.Context, sql string, args ...interface{}) *Result
- func (tk *TestKit) MustUseIndex(sql string, index string, args ...interface{}) bool
- func (tk *TestKit) MustUseIndex4ExplainFor(result *Result, index string) bool
- func (tk *TestKit) NotHasKeywordInOperatorInfo(sql string, keyword string, args ...interface{}) bool
- func (tk *TestKit) QueryToErr(sql string, args ...interface{}) error
- func (tk *TestKit) RefreshConnectionID()
- func (tk *TestKit) RefreshSession()
- func (tk *TestKit) ResultSetToResult(rs sqlexec.RecordSet, comment string) *Result
- func (tk *TestKit) ResultSetToResultWithCtx(ctx context.Context, rs sqlexec.RecordSet, comment string) *Result
- func (tk *TestKit) Session() session.Session
- func (tk *TestKit) SetSession(session session.Session)
- func (tk *TestKit) UsedPartitions(sql string, args ...interface{}) *Result
Constants ¶
This section is empty.
Variables ¶
var WithTiKV = flag.String("with-tikv", "", "address of tikv cluster, if set, running test with real tikv cluster")
WithTiKV flag is only used for debugging locally with real tikv cluster.
Functions ¶
func CreateMockStore ¶
CreateMockStore return a new mock kv.Storage.
func CreateMockStoreAndDomain ¶
func CreateMockStoreAndDomain(t testing.TB, opts ...mockstore.MockTiKVStoreOption) (kv.Storage, *domain.Domain)
CreateMockStoreAndDomain return a new mock kv.Storage and *domain.Domain.
func CreateMockStoreAndDomainWithSchemaLease ¶
func CreateMockStoreAndDomainWithSchemaLease(t testing.TB, lease time.Duration, opts ...mockstore.MockTiKVStoreOption) (kv.Storage, *domain.Domain)
CreateMockStoreAndDomainWithSchemaLease return a new mock kv.Storage and *domain.Domain.
func CreateMockStoreWithSchemaLease ¶
func CreateMockStoreWithSchemaLease(t testing.TB, lease time.Duration, opts ...mockstore.MockTiKVStoreOption) kv.Storage
CreateMockStoreWithSchemaLease return a new mock kv.Storage.
func Rows ¶
func Rows(args ...string) [][]interface{}
Rows is similar to RowsWithSep, use white space as separator string.
func RowsWithSep ¶
RowsWithSep is a convenient function to wrap args to a slice of []interface. The arg represents a row, split by sep.
func TryRetrieveSession ¶
TryRetrieveSession tries retrieve session from context.
func WithPruneMode ¶
func WithPruneMode(tk *TestKit, mode variable.PartitionPruneMode, f func())
WithPruneMode run test case under prune mode.
Types ¶
type AsyncTestKit ¶
type AsyncTestKit struct {
// contains filtered or unexported fields
}
AsyncTestKit is a utility to run sql concurrently.
func NewAsyncTestKit ¶
func NewAsyncTestKit(t *testing.T, store kv.Storage) *AsyncTestKit
NewAsyncTestKit returns a new *AsyncTestKit.
func (*AsyncTestKit) CloseSession ¶
func (tk *AsyncTestKit) CloseSession(ctx context.Context)
CloseSession closes exists session from ctx.
func (*AsyncTestKit) ConcurrentRun ¶
func (tk *AsyncTestKit) ConcurrentRun( concurrent int, loops int, prepareFunc func(ctx context.Context, tk *AsyncTestKit, concurrent int, currentLoop int) [][][]interface{}, writeFunc func(ctx context.Context, tk *AsyncTestKit, input [][]interface{}), checkFunc func(ctx context.Context, tk *AsyncTestKit), )
ConcurrentRun run test in current. - concurrent: controls the concurrent worker count. - loops: controls run test how much times. - prepareFunc: provide test data and will be called for every loop. - checkFunc: used to do some check after all workers done. works like create table better be put in front of this method calling. see more example at TestBatchInsertWithOnDuplicate
func (*AsyncTestKit) Exec ¶
func (tk *AsyncTestKit) Exec(ctx context.Context, sql string, args ...interface{}) (sqlexec.RecordSet, error)
Exec executes a sql statement.
func (*AsyncTestKit) ExecToErr ¶
func (tk *AsyncTestKit) ExecToErr(ctx context.Context, sql string, args ...interface{}) error
ExecToErr executes a sql statement and discard results.
func (*AsyncTestKit) MustExec ¶
func (tk *AsyncTestKit) MustExec(ctx context.Context, sql string, args ...interface{})
MustExec executes a sql statement and asserts nil error.
func (*AsyncTestKit) MustGetErrMsg ¶
func (tk *AsyncTestKit) MustGetErrMsg(ctx context.Context, sql string, errStr string)
MustGetErrMsg executes a sql statement and assert its error message.
func (*AsyncTestKit) MustQuery ¶
func (tk *AsyncTestKit) MustQuery(ctx context.Context, sql string, args ...interface{}) *Result
MustQuery query the statements and returns result rows. If expected result is set it asserts the query result equals expected result.
func (*AsyncTestKit) OpenSession ¶
OpenSession opens new session ctx if no exists one and use db.
type DBTestKit ¶
type DBTestKit struct {
// contains filtered or unexported fields
}
DBTestKit is a utility to run sql with a db connection.
func NewDBTestKit ¶
NewDBTestKit returns a new *DBTestKit.
func (*DBTestKit) MustExecPrepared ¶
MustExecPrepared executes a prepared statement with the given arguments and returns a Result summarizing the effect of the statement.
func (*DBTestKit) MustPrepare ¶
MustPrepare creates a prepared statement for later queries or executions.
func (*DBTestKit) MustQueryPrepared ¶
MustQueryPrepared executes a prepared query statement with the given arguments and returns the query results as a *Rows.
func (*DBTestKit) MustQueryRows ¶
MustQueryRows query the statements
type MockSessionManager ¶
type MockSessionManager struct { PS []*util.ProcessInfo PSMu sync.RWMutex SerID uint64 TxnInfo []*txninfo.TxnInfo Dom *domain.Domain // contains filtered or unexported fields }
MockSessionManager is a mocked session manager which is used for test.
func (*MockSessionManager) CheckOldRunningTxn ¶
func (msm *MockSessionManager) CheckOldRunningTxn(job2ver map[int64]int64, job2ids map[int64]string)
CheckOldRunningTxn implement SessionManager interface.
func (*MockSessionManager) DeleteInternalSession ¶
func (*MockSessionManager) DeleteInternalSession(interface{})
DeleteInternalSession is to delete the internal session pointer from the map in the SessionManager
func (*MockSessionManager) GetInternalSessionStartTSList ¶
func (*MockSessionManager) GetInternalSessionStartTSList() []uint64
GetInternalSessionStartTSList is to get all startTS of every transactions running in the current internal sessions
func (*MockSessionManager) GetMinStartTS ¶
func (msm *MockSessionManager) GetMinStartTS(lowerBound uint64) (ts uint64)
GetMinStartTS implements SessionManager interface.
func (*MockSessionManager) GetProcessInfo ¶
func (msm *MockSessionManager) GetProcessInfo(id uint64) (*util.ProcessInfo, bool)
GetProcessInfo implements the SessionManager.GetProcessInfo interface.
func (*MockSessionManager) Kill ¶
func (*MockSessionManager) Kill(uint64, bool)
Kill implements the SessionManager.Kill interface.
func (*MockSessionManager) KillAllConnections ¶
func (*MockSessionManager) KillAllConnections()
KillAllConnections implements the SessionManager.KillAllConections interface.
func (*MockSessionManager) KillNonFlashbackClusterConn ¶
func (msm *MockSessionManager) KillNonFlashbackClusterConn()
KillNonFlashbackClusterConn implement SessionManager interface.
func (*MockSessionManager) ServerID ¶
func (msm *MockSessionManager) ServerID() uint64
ServerID get server id.
func (*MockSessionManager) ShowProcessList ¶
func (msm *MockSessionManager) ShowProcessList() map[uint64]*util.ProcessInfo
ShowProcessList implements the SessionManager.ShowProcessList interface.
func (*MockSessionManager) ShowTxnList ¶
func (msm *MockSessionManager) ShowTxnList() []*txninfo.TxnInfo
ShowTxnList is to show txn list.
func (*MockSessionManager) StoreInternalSession ¶
func (*MockSessionManager) StoreInternalSession(interface{})
StoreInternalSession is to store internal session.
func (*MockSessionManager) UpdateTLSConfig ¶
func (*MockSessionManager) UpdateTLSConfig(*tls.Config)
UpdateTLSConfig implements the SessionManager.UpdateTLSConfig interface.
type RegionProperityClient ¶
RegionProperityClient is to get region properties.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result is the result returned by MustQuery.
func (*Result) AddComment ¶
AddComment adds the extra comment for the Result's output.
func (*Result) Check ¶
func (res *Result) Check(expected [][]interface{})
Check asserts the result equals the expected results.
func (*Result) CheckAt ¶
CheckAt asserts the result of selected columns equals the expected results.
func (*Result) CheckWithFunc ¶
CheckWithFunc asserts the result match the expected results in the way `f` specifies.
type SteppedTestKit ¶
type SteppedTestKit struct {
// contains filtered or unexported fields
}
SteppedTestKit is the testkit that can run stepped command
func NewSteppedTestKit ¶
func NewSteppedTestKit(t testing.TB, store kv.Storage) *SteppedTestKit
NewSteppedTestKit creates a new SteppedTestKit
func (*SteppedTestKit) Continue ¶
func (tk *SteppedTestKit) Continue() *SteppedTestKit
Continue continues current command
func (*SteppedTestKit) ExpectIdle ¶
func (tk *SteppedTestKit) ExpectIdle()
ExpectIdle checks no command is running
func (*SteppedTestKit) ExpectStopOnAnyBreakPoint ¶
func (tk *SteppedTestKit) ExpectStopOnAnyBreakPoint()
ExpectStopOnAnyBreakPoint checks stopped on any break point
func (*SteppedTestKit) ExpectStopOnBreakPoint ¶
func (tk *SteppedTestKit) ExpectStopOnBreakPoint(breakPoint string)
ExpectStopOnBreakPoint checks stopped on the specified break point
func (*SteppedTestKit) GetQueryResult ¶
func (tk *SteppedTestKit) GetQueryResult() *Result
GetQueryResult returns the query result of the latest command
func (*SteppedTestKit) GetResult ¶
func (tk *SteppedTestKit) GetResult() any
GetResult returns the result of the latest command
func (*SteppedTestKit) MustExec ¶
func (tk *SteppedTestKit) MustExec(sql string, args ...interface{})
MustExec executes a sql statement and asserts nil error.
func (*SteppedTestKit) MustQuery ¶
func (tk *SteppedTestKit) MustQuery(sql string, args ...interface{}) *Result
MustQuery query the statements and returns result rows. If expected result is set it asserts the query result equals expected result.
func (*SteppedTestKit) SetBreakPoints ¶
func (tk *SteppedTestKit) SetBreakPoints(breakPoints ...string)
SetBreakPoints sets the break points we want to stop at
func (*SteppedTestKit) SteppedMustExec ¶
func (tk *SteppedTestKit) SteppedMustExec(sql string, args ...interface{}) *SteppedTestKit
SteppedMustExec creates a new stepped task for MustExec
func (*SteppedTestKit) SteppedMustQuery ¶
func (tk *SteppedTestKit) SteppedMustQuery(sql string, args ...interface{}) *SteppedTestKit
SteppedMustQuery creates a new stepped task for MustQuery
type TestKit ¶
type TestKit struct {
// contains filtered or unexported fields
}
TestKit is a utility to run sql test.
func NewTestKit ¶
NewTestKit returns a new *TestKit.
func NewTestKitWithSession ¶
NewTestKitWithSession returns a new *TestKit.
func (*TestKit) CheckExecResult ¶
CheckExecResult checks the affected rows and the insert id after executing MustExec.
func (*TestKit) CheckLastMessage ¶
CheckLastMessage checks last message after executing MustExec
func (*TestKit) ExecWithContext ¶
func (tk *TestKit) ExecWithContext(ctx context.Context, sql string, args ...interface{}) (rs sqlexec.RecordSet, err error)
ExecWithContext executes a sql statement using the prepared stmt API
func (*TestKit) HasKeywordInOperatorInfo ¶
HasKeywordInOperatorInfo checks if the result execution plan contains specific keyword in the operator info.
func (*TestKit) HasPlan4ExplainFor ¶
HasPlan4ExplainFor checks if the result execution plan contains specific plan.
func (*TestKit) HasPlanForLastExecution ¶
HasPlanForLastExecution checks if the execution plan of the last execution contains specific plan.
func (*TestKit) HasTiFlashPlan ¶
HasTiFlashPlan checks if the result execution plan contains TiFlash plan.
func (*TestKit) MustContainErrMsg ¶
MustContainErrMsg executes a sql statement and assert its error message containing errStr.
func (*TestKit) MustExecToErr ¶
MustExecToErr executes a sql statement and must return Error.
func (*TestKit) MustExecWithContext ¶
MustExecWithContext executes a sql statement and asserts nil error.
func (*TestKit) MustGetDBError ¶
MustGetDBError executes a sql statement and assert its terror.
func (*TestKit) MustGetErrCode ¶
MustGetErrCode executes a sql statement and assert it's error code.
func (*TestKit) MustGetErrMsg ¶
MustGetErrMsg executes a sql statement and assert its error message.
func (*TestKit) MustIndexLookup ¶
MustIndexLookup checks whether the plan for the sql is IndexLookUp.
func (*TestKit) MustMatchErrMsg ¶
MustMatchErrMsg executes a sql statement and assert its error message matching errRx.
func (*TestKit) MustNoGlobalStats ¶
MustNoGlobalStats checks if there is no global stats.
func (*TestKit) MustPartition ¶
MustPartition checks if the result execution plan must read specific partitions.
func (*TestKit) MustPartitionByList ¶
func (tk *TestKit) MustPartitionByList(sql string, partitions []string, args ...interface{}) *Result
MustPartitionByList checks if the result execution plan must read specific partitions by list.
func (*TestKit) MustPointGet ¶
MustPointGet checks whether the plan for the sql is Point_Get.
func (*TestKit) MustQuery ¶
MustQuery query the statements and returns result rows. If expected result is set it asserts the query result equals expected result.
func (*TestKit) MustQueryWithContext ¶
func (tk *TestKit) MustQueryWithContext(ctx context.Context, sql string, args ...interface{}) *Result
MustQueryWithContext query the statements and returns result rows.
func (*TestKit) MustUseIndex ¶
MustUseIndex checks if the result execution plan contains specific index(es).
func (*TestKit) MustUseIndex4ExplainFor ¶
MustUseIndex4ExplainFor checks if the result execution plan contains specific index(es).
func (*TestKit) NotHasKeywordInOperatorInfo ¶
func (tk *TestKit) NotHasKeywordInOperatorInfo(sql string, keyword string, args ...interface{}) bool
NotHasKeywordInOperatorInfo checks if the result execution plan doesn't contain specific keyword in the operator info.
func (*TestKit) QueryToErr ¶
QueryToErr executes a sql statement and discard results.
func (*TestKit) RefreshConnectionID ¶
func (tk *TestKit) RefreshConnectionID()
RefreshConnectionID refresh the connection ID for session of the testkit
func (*TestKit) RefreshSession ¶
func (tk *TestKit) RefreshSession()
RefreshSession set a new session for the testkit
func (*TestKit) ResultSetToResult ¶
ResultSetToResult converts sqlexec.RecordSet to testkit.Result. It is used to check results of execute statement in binary mode.
func (*TestKit) ResultSetToResultWithCtx ¶
func (tk *TestKit) ResultSetToResultWithCtx(ctx context.Context, rs sqlexec.RecordSet, comment string) *Result
ResultSetToResultWithCtx converts sqlexec.RecordSet to testkit.Result.
func (*TestKit) SetSession ¶
SetSession set the session of testkit
func (*TestKit) UsedPartitions ¶
UsedPartitions returns the partition names that will be used or all/dual.