tidb: github.com/pingcap/tidb/util/testkit Index | Files

package testkit

import "github.com/pingcap/tidb/util/testkit"

Index

Package Files

ctestkit.go testkit.go

func Rows Uses

func Rows(args ...string) [][]interface{}

Rows is similar to RowsWithSep, use white space as separator string.

type CTestKit Uses

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

CTestKit is a utility to run sql test with concurrent execution support.

func NewCTestKit Uses

func NewCTestKit(c *check.C, store kv.Storage) *CTestKit

NewCTestKit returns a new *CTestKit.

func (*CTestKit) CheckExecResult Uses

func (tk *CTestKit) CheckExecResult(ctx context.Context, affectedRows, insertID int64)

CheckExecResult checks the affected rows and the insert id after executing MustExec.

func (*CTestKit) CloseSession Uses

func (tk *CTestKit) CloseSession(ctx context.Context)

CloseSession closes exists session from ctx.

func (*CTestKit) ConcurrentRun Uses

func (tk *CTestKit) ConcurrentRun(c *check.C, concurrent int, loops int,
    prepareFunc func(ctx context.Context, tk *CTestKit, concurrent int, currentLoop int) [][][]interface{},
    writeFunc func(ctx context.Context, tk *CTestKit, input [][]interface{}),
    checkFunc func(ctx context.Context, tk *CTestKit))

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 (*CTestKit) Exec Uses

func (tk *CTestKit) Exec(ctx context.Context, sql string, args ...interface{}) (sqlexec.RecordSet, error)

Exec executes a sql statement.

func (*CTestKit) IgnoreError Uses

func (tk *CTestKit) IgnoreError(_ error)

IgnoreError ignores error and make errcheck tool happy. Deprecated: it's normal to ignore some error in concurrent test, but please don't use this method in other place.

func (*CTestKit) MustExec Uses

func (tk *CTestKit) MustExec(ctx context.Context, sql string, args ...interface{})

MustExec executes a sql statement and asserts nil error.

func (*CTestKit) MustQuery Uses

func (tk *CTestKit) 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 (*CTestKit) OpenSession Uses

func (tk *CTestKit) OpenSession(ctx context.Context) context.Context

OpenSession opens new session ctx if no exists one.

func (*CTestKit) OpenSessionWithDB Uses

func (tk *CTestKit) OpenSessionWithDB(ctx context.Context, db string) context.Context

OpenSessionWithDB opens new session ctx if no exists one and use db.

func (*CTestKit) PermInt Uses

func (tk *CTestKit) PermInt(n int) []interface{}

PermInt returns, as a slice of n ints, a pseudo-random permutation of the integers [0,n).

type Result Uses

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

Result is the result returned by MustQuery.

func (*Result) Check Uses

func (res *Result) Check(expected [][]interface{})

Check asserts the result equals the expected results.

func (*Result) CheckAt Uses

func (res *Result) CheckAt(cols []int, expected [][]interface{})

CheckAt asserts the result of selected columns equals the expected results.

func (*Result) Rows Uses

func (res *Result) Rows() [][]interface{}

Rows returns the result data.

func (*Result) Sort Uses

func (res *Result) Sort() *Result

Sort sorts and return the result.

type TestKit Uses

type TestKit struct {
    Se session.Session
    // contains filtered or unexported fields
}

TestKit is a utility to run sql test.

func NewTestKit Uses

func NewTestKit(c *check.C, store kv.Storage) *TestKit

NewTestKit returns a new *TestKit.

func NewTestKitWithInit Uses

func NewTestKitWithInit(c *check.C, store kv.Storage) *TestKit

NewTestKitWithInit returns a new *TestKit and creates a session.

func (*TestKit) CheckExecResult Uses

func (tk *TestKit) CheckExecResult(affectedRows, insertID int64)

CheckExecResult checks the affected rows and the insert id after executing MustExec.

func (*TestKit) CheckLastMessage Uses

func (tk *TestKit) CheckLastMessage(msg string)

CheckLastMessage checks last message after executing MustExec

func (*TestKit) Exec Uses

func (tk *TestKit) Exec(sql string, args ...interface{}) (sqlexec.RecordSet, error)

Exec executes a sql statement.

func (*TestKit) ExecToErr Uses

func (tk *TestKit) ExecToErr(sql string, args ...interface{}) error

ExecToErr executes a sql statement and discard results.

func (*TestKit) GetTableID Uses

func (tk *TestKit) GetTableID(tableName string) int64

GetTableID gets table ID by name.

func (*TestKit) MustExec Uses

func (tk *TestKit) MustExec(sql string, args ...interface{})

MustExec executes a sql statement and asserts nil error.

func (*TestKit) MustGetErrCode Uses

func (tk *TestKit) MustGetErrCode(sql string, errCode int)

MustGetErrCode executes a sql statement and assert it's error code.

func (*TestKit) MustIndexLookup Uses

func (tk *TestKit) MustIndexLookup(sql string, args ...interface{}) *Result

MustIndexLookup checks whether the plan for the sql is Point_Get.

func (*TestKit) MustPointGet Uses

func (tk *TestKit) MustPointGet(sql string, args ...interface{}) *Result

MustPointGet checks whether the plan for the sql is Point_Get.

func (*TestKit) MustQuery Uses

func (tk *TestKit) 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 (*TestKit) MustTableDual Uses

func (tk *TestKit) MustTableDual(sql string, args ...interface{}) *Result

MustTableDual checks whether the plan for the sql is TableDual.

func (*TestKit) QueryToErr Uses

func (tk *TestKit) QueryToErr(sql string, args ...interface{}) error

QueryToErr executes a sql statement and discard results.

func (*TestKit) ResultSetToResult Uses

func (tk *TestKit) ResultSetToResult(rs sqlexec.RecordSet, comment check.CommentInterface) *Result

ResultSetToResult converts sqlexec.RecordSet to testkit.Result. It is used to check results of execute statement in binary mode.

func (*TestKit) ResultSetToResultWithCtx Uses

func (tk *TestKit) ResultSetToResultWithCtx(ctx context.Context, rs sqlexec.RecordSet, comment check.CommentInterface) *Result

ResultSetToResultWithCtx converts sqlexec.RecordSet to testkit.Result.

Package testkit imports 18 packages (graph). Updated 2019-09-16. Refresh now. Tools for package owners.