本文整理汇总了Golang中github.com/pingcap/tidb/util/testleak.AfterTest函数的典型用法代码示例。如果您正苦于以下问题:Golang AfterTest函数的具体用法?Golang AfterTest怎么用?Golang AfterTest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AfterTest函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestSeekMin
func (s *testKVSuite) TestSeekMin(c *C) {
defer testleak.AfterTest(c)()
kvs := []struct {
key string
value string
}{
{"DATA_test_main_db_tbl_tbl_test_record__00000000000000000001", "lock-version"},
{"DATA_test_main_db_tbl_tbl_test_record__00000000000000000001_0002", "1"},
{"DATA_test_main_db_tbl_tbl_test_record__00000000000000000001_0003", "hello"},
{"DATA_test_main_db_tbl_tbl_test_record__00000000000000000002", "lock-version"},
{"DATA_test_main_db_tbl_tbl_test_record__00000000000000000002_0002", "2"},
{"DATA_test_main_db_tbl_tbl_test_record__00000000000000000002_0003", "hello"},
}
txn, err := s.s.Begin()
c.Assert(err, IsNil)
for _, kv := range kvs {
txn.Set([]byte(kv.key), []byte(kv.value))
}
it, err := txn.Seek(nil)
for it.Valid() {
fmt.Printf("%s, %s\n", it.Key(), it.Value())
it.Next()
}
it, err = txn.Seek([]byte("DATA_test_main_db_tbl_tbl_test_record__00000000000000000000"))
c.Assert(err, IsNil)
c.Assert(string(it.Key()), Equals, "DATA_test_main_db_tbl_tbl_test_record__00000000000000000001")
for _, kv := range kvs {
txn.Delete([]byte(kv.key))
}
}
开发者ID:yangxuanjia,项目名称:tidb,代码行数:34,代码来源:store_test.go
示例2: TestGetDDLInfo
func (s *testSuite) TestGetDDLInfo(c *C) {
defer testleak.AfterTest(c)()
txn, err := s.store.Begin()
c.Assert(err, IsNil)
t := meta.NewMeta(txn)
owner := &model.Owner{OwnerID: "owner"}
err = t.SetDDLJobOwner(owner)
c.Assert(err, IsNil)
dbInfo2 := &model.DBInfo{
ID: 2,
Name: model.NewCIStr("b"),
State: model.StateNone,
}
job := &model.Job{
SchemaID: dbInfo2.ID,
Type: model.ActionCreateSchema,
}
err = t.EnQueueDDLJob(job)
c.Assert(err, IsNil)
info, err := GetDDLInfo(txn)
c.Assert(err, IsNil)
c.Assert(info.Owner, DeepEquals, owner)
c.Assert(info.Job, DeepEquals, job)
c.Assert(info.ReorgHandle, Equals, int64(0))
err = txn.Commit()
c.Assert(err, IsNil)
}
开发者ID:tangfeixiong,项目名称:tidb,代码行数:28,代码来源:inspectkv_test.go
示例3: TestNullRejectFinder
func (s *testPlanSuite) TestNullRejectFinder(c *C) {
defer testleak.AfterTest(c)()
cases := []struct {
expr string
notNull bool
}{
{"a = 1", true},
{"a != 100 and a > 0", true},
{"a is null", false},
{"a is not null", true},
{"a is true", true},
{"a is not true", false},
{"a is false", true},
{"a is not false", false},
{"a != 0 and a is not false", true},
{"a > 0 or true", false},
}
for _, ca := range cases {
sql := "select * from t where " + ca.expr
comment := Commentf("for expr %s", ca.expr)
s, err := s.ParseOneStmt(sql, "", "")
c.Assert(err, IsNil, comment)
finder := &nullRejectFinder{nullRejectTables: map[*ast.TableName]bool{}}
stmt := s.(*ast.SelectStmt)
mockResolve(stmt)
stmt.Where.Accept(finder)
if ca.notNull {
c.Assert(finder.nullRejectTables, HasLen, 1, comment)
} else {
c.Assert(finder.nullRejectTables, HasLen, 0, comment)
}
}
}
开发者ID:yubobo,项目名称:tidb,代码行数:33,代码来源:plan_test.go
示例4: TestDate
func (s *testTimeSuite) TestDate(c *C) {
defer testleak.AfterTest(c)()
table := []struct {
Input string
Expect string
}{
{"2012-12-31", "2012-12-31"},
{"00-12-31", "2000-12-31"},
{"20121231", "2012-12-31"},
{"121231", "2012-12-31"},
{"2015-06-01 12:12:12", "2015-06-01"},
{"0001-01-01 00:00:00", "0001-01-01"},
{"0001-01-01", "0001-01-01"},
}
for _, test := range table {
t, err := ParseDate(test.Input)
c.Assert(err, IsNil)
c.Assert(t.String(), Equals, test.Expect)
}
errTable := []string{
"0121231",
}
for _, test := range errTable {
_, err := ParseDate(test)
c.Assert(err, NotNil)
}
}
开发者ID:XuHuaiyu,项目名称:tidb,代码行数:30,代码来源:time_test.go
示例5: TestTimestamp
func (s *testTimeSuite) TestTimestamp(c *C) {
defer testleak.AfterTest(c)()
table := []struct {
Input string
Expect string
}{
{"2012-12-31 11:30:45", "2012-12-31 11:30:45"},
}
for _, test := range table {
t, err := ParseTimestamp(test.Input)
c.Assert(err, IsNil)
c.Assert(t.String(), Equals, test.Expect)
}
errTable := []string{
"2048-12-31 11:30:45",
"1969-12-31 11:30:45",
}
for _, test := range errTable {
_, err := ParseTimestamp(test)
c.Assert(err, NotNil)
}
}
开发者ID:XuHuaiyu,项目名称:tidb,代码行数:25,代码来源:time_test.go
示例6: TestHexFunc
func (s *testEvaluatorSuite) TestHexFunc(c *C) {
defer testleak.AfterTest(c)()
tbl := []struct {
Input interface{}
Expect string
}{
{12, "C"},
{12.3, "C"},
{12.5, "D"},
{-12.3, "FFFFFFFFFFFFFFF4"},
{-12.5, "FFFFFFFFFFFFFFF3"},
{"12", "3132"},
{0x12, "12"},
{"", ""},
}
dtbl := tblToDtbl(tbl)
for _, t := range dtbl {
d, err := builtinHex(t["Input"], nil)
c.Assert(err, IsNil)
c.Assert(d, testutil.DatumEquals, t["Expect"][0])
}
}
开发者ID:XuHuaiyu,项目名称:tidb,代码行数:26,代码来源:builtin_string_test.go
示例7: TestInsert
func (p *testPerfSchemaSuit) TestInsert(c *C) {
defer testleak.AfterTest(c)()
store, err := tidb.NewStore(tidb.EngineGoLevelDBMemory)
c.Assert(err, IsNil)
defer store.Close()
se := newSession(c, store, "")
defer se.Close()
mustExec(c, se, `insert into performance_schema.setup_actors values("localhost", "nieyy", "contributor", "NO", "NO");`)
checkResult(c, se, 0, 0)
cnt := mustQuery(c, se, "select * from performance_schema.setup_actors")
c.Assert(cnt, Equals, 2)
mustExec(c, se, `insert into performance_schema.setup_actors (host, user, role) values ("localhost", "lijian", "contributor");`)
checkResult(c, se, 0, 0)
cnt = mustQuery(c, se, "select * from performance_schema.setup_actors")
c.Assert(cnt, Equals, 3)
mustExec(c, se, `insert into performance_schema.setup_objects values("EVENT", "test", "%", "NO", "NO")`)
checkResult(c, se, 0, 0)
cnt = mustQuery(c, se, "select * from performance_schema.setup_objects")
c.Assert(cnt, Equals, 13)
mustExec(c, se, `insert into performance_schema.setup_objects (object_schema, object_name) values ("test1", "%")`)
checkResult(c, se, 0, 0)
cnt = mustQuery(c, se, "select * from performance_schema.setup_objects")
c.Assert(cnt, Equals, 14)
mustFailExec(c, se, `insert into performance_schema.setup_actors (host) values (null);`)
mustFailExec(c, se, `insert into performance_schema.setup_objects (object_type) values (null);`)
mustFailExec(c, se, `insert into performance_schema.setup_instruments values("select", "N/A", "N/A");`)
mustFailExec(c, se, `insert into performance_schema.setup_consumers values("events_stages_current", "N/A");`)
mustFailExec(c, se, `insert into performance_schema.setup_timers values("timer1", "XXXSECOND");`)
}
开发者ID:pingcap,项目名称:tidb,代码行数:34,代码来源:perfschema_test.go
示例8: TestSetVar
func (s *testSuite) TestSetVar(c *C) {
plan.UseNewPlanner = true
defer testleak.AfterTest(c)()
tk := testkit.NewTestKit(c, s.store)
testSQL := "SET @a = 1;"
tk.MustExec(testSQL)
testSQL = `SET @a = "1";`
tk.MustExec(testSQL)
testSQL = "SET @a = null;"
tk.MustExec(testSQL)
testSQL = "SET @@global.autocommit = 1;"
tk.MustExec(testSQL)
// TODO: this test case should returns error.
// testSQL = "SET @@global.autocommit = null;"
// _, err := tk.Exec(testSQL)
// c.Assert(err, NotNil)
testSQL = "SET @@autocommit = 1;"
tk.MustExec(testSQL)
testSQL = "SET @@autocommit = null;"
_, err := tk.Exec(testSQL)
c.Assert(err, NotNil)
errTestSql := "SET @@date_format = 1;"
_, err = tk.Exec(errTestSql)
c.Assert(err, NotNil)
errTestSql = "SET @@rewriter_enabled = 1;"
_, err = tk.Exec(errTestSql)
c.Assert(err, NotNil)
errTestSql = "SET xxx = abcd;"
_, err = tk.Exec(errTestSql)
c.Assert(err, NotNil)
errTestSql = "SET @@global.a = 1;"
_, err = tk.Exec(errTestSql)
c.Assert(err, NotNil)
errTestSql = "SET @@global.timestamp = 1;"
_, err = tk.Exec(errTestSql)
c.Assert(err, NotNil)
// For issue 998
testSQL = "SET @issue998a=1, @issue998b=5;"
tk.MustExec(testSQL)
tk.MustQuery(`select @issue998a, @issue998b;`).Check(testkit.Rows("1 5"))
testSQL = "SET @@autocommit=0, @issue998a=2;"
tk.MustExec(testSQL)
tk.MustQuery(`select @issue998a, @@autocommit;`).Check(testkit.Rows("2 0"))
testSQL = "SET @@global.autocommit=1, @issue998b=6;"
tk.MustExec(testSQL)
tk.MustQuery(`select @issue998b, @@global.autocommit;`).Check(testkit.Rows("6 1"))
plan.UseNewPlanner = false
}
开发者ID:duzhanyuan,项目名称:tidb,代码行数:60,代码来源:executor_simple_test.go
示例9: TestTableScanWithOrder
func (s *testPlanSuite) TestTableScanWithOrder(c *C) {
defer testleak.AfterTest(c)()
// Sort result by scanning PKHandle column.
sql := "select * from t order by a limit 1;"
stmt, err := s.ParseOneStmt(sql, "", "")
c.Assert(err, IsNil)
ast.SetFlag(stmt)
err = newMockResolve(stmt)
c.Assert(err, IsNil)
builder := &planBuilder{
allocator: new(idAllocator),
ctx: mock.NewContext(),
colMapper: make(map[*ast.ColumnNameExpr]int),
}
p := builder.build(stmt)
c.Assert(builder.err, IsNil)
logic, ok := p.(LogicalPlan)
c.Assert(ok, IsTrue)
// Get physical plan.
_, pp, _, err := logic.convert2PhysicalPlan(nil)
c.Assert(err, IsNil)
// Limit->Projection->PhysicalTableScan
// Get PhysicalTableScan plan.
cpp, ok := pp.p.GetChildByIndex(0).GetChildByIndex(0).(*PhysicalTableScan)
c.Assert(cpp, NotNil)
c.Assert(ok, IsTrue)
// Make sure KeepOrder is true.
c.Assert(cpp.KeepOrder, IsTrue)
}
开发者ID:c4pt0r,项目名称:tidb,代码行数:31,代码来源:plan_test.go
示例10: TestSchemaResume
func (s *testSchemaSuite) TestSchemaResume(c *C) {
defer testleak.AfterTest(c)()
store := testCreateStore(c, "test_schema_resume")
defer store.Close()
d1 := newDDL(store, nil, nil, testLease)
defer d1.close()
testCheckOwner(c, d1, true, ddlJobFlag)
dbInfo := testSchemaInfo(c, d1, "test")
job := &model.Job{
SchemaID: dbInfo.ID,
Type: model.ActionCreateSchema,
Args: []interface{}{dbInfo},
}
testRunInterruptedJob(c, d1, job)
testCheckSchemaState(c, d1, dbInfo, model.StatePublic)
job = &model.Job{
SchemaID: dbInfo.ID,
Type: model.ActionDropSchema,
}
testRunInterruptedJob(c, d1, job)
testCheckSchemaState(c, d1, dbInfo, model.StateNone)
}
开发者ID:yangxuanjia,项目名称:tidb,代码行数:28,代码来源:schema_test.go
示例11: TestCallback
func (s *testDDLSuite) TestCallback(c *C) {
defer testleak.AfterTest(c)()
cb := &BaseCallback{}
c.Assert(cb.OnChanged(nil), IsNil)
cb.OnJobRunBefore(nil)
cb.OnJobUpdated(nil)
}
开发者ID:XuHuaiyu,项目名称:tidb,代码行数:7,代码来源:callback_test.go
示例12: TestSchema
func (s *testSchemaSuite) TestSchema(c *C) {
defer testleak.AfterTest(c)()
store := testCreateStore(c, "test_schema")
defer store.Close()
d1 := newDDL(store, nil, nil, testLease)
defer d1.close()
ctx := mock.NewContext()
dbInfo := testSchemaInfo(c, d1, "test")
job := testCreateSchema(c, ctx, d1, dbInfo)
testCheckSchemaState(c, d1, dbInfo, model.StatePublic)
testCheckJobDone(c, d1, job, true)
job = testDropSchema(c, ctx, d1, dbInfo)
testCheckSchemaState(c, d1, dbInfo, model.StateNone)
testCheckJobDone(c, d1, job, false)
job = &model.Job{
SchemaID: dbInfo.ID,
Type: model.ActionDropSchema,
}
err := d1.doDDLJob(ctx, job)
c.Assert(terror.ErrorEqual(err, infoschema.ErrDatabaseDropExists), IsTrue)
}
开发者ID:yangxuanjia,项目名称:tidb,代码行数:28,代码来源:schema_test.go
示例13: TestDropTableError
func (s *testDDLSuite) TestDropTableError(c *C) {
defer testleak.AfterTest(c)()
store := testCreateStore(c, "test_drop_table")
defer store.Close()
lease := 50 * time.Millisecond
d := newDDL(store, nil, nil, lease)
defer d.close()
dbInfo := testSchemaInfo(c, d, "test")
testCreateSchema(c, mock.NewContext(), d, dbInfo)
job := &model.Job{
SchemaID: dbInfo.ID,
Type: model.ActionDropTable,
Args: []interface{}{&model.TableInfo{
ID: 1,
Name: model.CIStr{O: "t"},
}},
}
d.prepareBgJob(job)
d.startBgJob(job.Type)
time.Sleep(lease)
verifyBgJobState(c, d, job, model.JobDone)
}
开发者ID:anywhy,项目名称:tidb,代码行数:26,代码来源:bg_worker_test.go
示例14: TestConditionIfNotExist
func (s *testKVSuite) TestConditionIfNotExist(c *C) {
defer testleak.AfterTest(c)()
var success int64
cnt := 100
b := []byte("1")
var wg sync.WaitGroup
wg.Add(cnt)
for i := 0; i < cnt; i++ {
go func() {
defer wg.Done()
txn, err := s.s.Begin()
c.Assert(err, IsNil)
err = txn.Set(b, b)
if err != nil {
return
}
err = txn.Commit()
if err == nil {
atomic.AddInt64(&success, 1)
}
}()
}
wg.Wait()
// At least one txn can success.
c.Assert(success, Greater, int64(0))
// Clean up
txn, err := s.s.Begin()
c.Assert(err, IsNil)
err = txn.Delete(b)
c.Assert(err, IsNil)
err = txn.Commit()
c.Assert(err, IsNil)
}
开发者ID:yangxuanjia,项目名称:tidb,代码行数:34,代码来源:store_test.go
示例15: TestLength
func (s *testEvaluatorSuite) TestLength(c *C) {
defer testleak.AfterTest(c)()
d, err := builtinLength(types.MakeDatums([]interface{}{nil}...), nil)
c.Assert(err, IsNil)
c.Assert(d.Kind(), Equals, types.KindNull)
tbl := []struct {
Input interface{}
Expected int64
}{
{"abc", 3},
{1, 1},
{3.14, 4},
{mysql.Time{Time: time.Now(), Fsp: 6, Type: mysql.TypeDatetime}, 26},
{mysql.Bit{Value: 1, Width: 8}, 1},
{mysql.Hex{Value: 1}, 1},
{mysql.Set{Value: 1, Name: "abc"}, 3},
}
dtbl := tblToDtbl(tbl)
for _, t := range dtbl {
d, err = builtinLength(t["Input"], nil)
c.Assert(err, IsNil)
c.Assert(d, testutil.DatumEquals, t["Expected"][0])
}
}
开发者ID:XuHuaiyu,项目名称:tidb,代码行数:27,代码来源:builtin_string_test.go
示例16: TestSegment
func (s *testSegmentMapSuite) TestSegment(c *C) {
defer testleak.AfterTest(c)()
segs := int64(2)
m, err := NewSegmentMap(segs)
c.Assert(err, IsNil)
c.Assert(m.SegmentCount(), Equals, segs)
k := []byte("k")
v := []byte("v")
val, exist := m.Get(k)
c.Assert(exist, IsFalse)
exist = m.Set(k, v, false)
c.Assert(exist, IsFalse)
val, exist = m.Get(k)
c.Assert(v, DeepEquals, val.([]byte))
c.Assert(exist, IsTrue)
m0, err := m.GetSegment(0)
c.Assert(err, IsNil)
m1, err := m.GetSegment(1)
c.Assert(err, IsNil)
c.Assert(len(m0)+len(m1), Equals, 1)
_, err = m.GetSegment(3)
c.Assert(err, NotNil)
}
开发者ID:XuHuaiyu,项目名称:tidb,代码行数:29,代码来源:segmentmap_test.go
示例17: TestASCII
func (s *testEvaluatorSuite) TestASCII(c *C) {
defer testleak.AfterTest(c)()
v, err := builtinASCII(types.MakeDatums([]interface{}{nil}...), nil)
c.Assert(err, IsNil)
c.Assert(v.Kind(), Equals, types.KindNull)
for _, t := range []struct {
Input interface{}
Expected int64
}{
{"", 0},
{"A", 65},
{"你好", 228},
{1, 49},
{1.2, 49},
{true, 49},
{false, 48},
} {
v, err = builtinASCII(types.MakeDatums(t.Input), nil)
c.Assert(err, IsNil)
c.Assert(v.GetInt64(), Equals, t.Expected)
}
v, err = builtinASCII(types.MakeDatums([]interface{}{errors.New("must error")}...), nil)
c.Assert(err, NotNil)
}
开发者ID:XuHuaiyu,项目名称:tidb,代码行数:26,代码来源:builtin_string_test.go
示例18: TestCompareDatum
func (s *testCompareSuite) TestCompareDatum(c *C) {
defer testleak.AfterTest(c)()
cmpTbl := []struct {
lhs Datum
rhs Datum
ret int // 0, 1, -1
}{
{MaxValueDatum(), NewDatum("00:00:00"), 1},
{MinNotNullDatum(), NewDatum("00:00:00"), -1},
{Datum{}, NewDatum("00:00:00"), -1},
{Datum{}, Datum{}, 0},
{MinNotNullDatum(), MinNotNullDatum(), 0},
{MaxValueDatum(), MaxValueDatum(), 0},
{Datum{}, MinNotNullDatum(), -1},
{MinNotNullDatum(), MaxValueDatum(), -1},
}
for i, t := range cmpTbl {
comment := Commentf("%d %v %v", i, t.lhs, t.rhs)
ret, err := t.lhs.CompareDatum(t.rhs)
c.Assert(err, IsNil)
c.Assert(ret, Equals, t.ret, comment)
ret, err = t.rhs.CompareDatum(t.lhs)
c.Assert(err, IsNil)
c.Assert(ret, Equals, -t.ret, comment)
}
}
开发者ID:yangxuanjia,项目名称:tidb,代码行数:27,代码来源:compare_test.go
示例19: TestConcurrentStatement
func (p *testPerfSchemaSuit) TestConcurrentStatement(c *C) {
defer testleak.AfterTest(c)()
store, err := tidb.NewStore(tidb.EngineGoLevelDBMemory + "/test_con_stmt")
c.Assert(err, IsNil)
defer store.Close()
se := newSession(c, store, "test_con_stmt")
mustExec(c, se, "drop table if exists test")
mustExec(c, se, "create table test (a int, b int)")
var wg sync.WaitGroup
iFunc := func(a, b int) {
defer wg.Done()
sess := newSession(c, store, "test_con_stmt")
mustExec(c, sess, fmt.Sprintf(`INSERT INTO test VALUES (%d, %d);`, a, b))
}
sFunc := func() {
defer wg.Done()
sess := newSession(c, store, "test_con_stmt")
mustQuery(c, sess, "select * from performance_schema.events_statements_current")
mustQuery(c, sess, "select * from performance_schema.events_statements_history")
}
cnt := 10
for i := 0; i < cnt; i++ {
wg.Add(2)
go iFunc(i, i)
go sFunc()
}
wg.Wait()
}
开发者ID:pingcap,项目名称:tidb,代码行数:31,代码来源:perfschema_test.go
示例20: TestCurrentTime
func (s *testEvaluatorSuite) TestCurrentTime(c *C) {
defer testleak.AfterTest(c)()
tfStr := "15:04:05"
last := time.Now()
v, err := builtinCurrentTime(types.MakeDatums(nil), nil)
c.Assert(err, IsNil)
n := v.GetMysqlDuration()
c.Assert(n.String(), HasLen, 8)
c.Assert(n.String(), GreaterEqual, last.Format(tfStr))
v, err = builtinCurrentTime(types.MakeDatums(3), nil)
c.Assert(err, IsNil)
n = v.GetMysqlDuration()
c.Assert(n.String(), HasLen, 12)
c.Assert(n.String(), GreaterEqual, last.Format(tfStr))
v, err = builtinCurrentTime(types.MakeDatums(6), nil)
c.Assert(err, IsNil)
n = v.GetMysqlDuration()
c.Assert(n.String(), HasLen, 15)
c.Assert(n.String(), GreaterEqual, last.Format(tfStr))
v, err = builtinCurrentTime(types.MakeDatums(-1), nil)
c.Assert(err, NotNil)
v, err = builtinCurrentTime(types.MakeDatums(7), nil)
c.Assert(err, NotNil)
}
开发者ID:XuHuaiyu,项目名称:tidb,代码行数:29,代码来源:builtin_time_test.go
注:本文中的github.com/pingcap/tidb/util/testleak.AfterTest函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论