Skip to content

Commit

Permalink
kvencoder: accelerate kvencoder test executing time (#8595)
Browse files Browse the repository at this point in the history
  • Loading branch information
winkyao authored Dec 12, 2018
1 parent 0a8c2f9 commit 9bd1fb8
Showing 1 changed file with 11 additions and 35 deletions.
46 changes: 11 additions & 35 deletions util/kvencoder/kv_encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,9 @@ func (s *testKvEncoderSuite) runTestSQL(c *C, tkExpect *testkit.TestKit, encoder
}

func (s *testKvEncoderSuite) TestCustomDatabaseHandle(c *C) {
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
defer store.Close()
defer dom.Close()

dbname := "tidb"

tkExpect := testkit.NewTestKit(c, store)
tkExpect := testkit.NewTestKit(c, s.store)
tkExpect.MustExec("create database if not exists " + dbname)
tkExpect.MustExec("use " + dbname)

Expand All @@ -171,18 +166,14 @@ func (s *testKvEncoderSuite) TestCustomDatabaseHandle(c *C) {
}

func (s *testKvEncoderSuite) TestInsertPkIsHandle(c *C) {
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
defer store.Close()
defer dom.Close()

tkExpect := testkit.NewTestKit(c, store)
tkExpect := testkit.NewTestKit(c, s.store)
tkExpect.MustExec("use test")
var tableID int64 = 1
encoder, err := New("test", nil)
c.Assert(err, IsNil)
defer encoder.Close()

tkExpect.MustExec("drop table if exists t")
schemaSQL := "create table t(id int auto_increment, a char(10), primary key(id))"
tkExpect.MustExec(schemaSQL)
err = encoder.ExecDDLSQL(schemaSQL)
Expand All @@ -200,6 +191,7 @@ func (s *testKvEncoderSuite) TestInsertPkIsHandle(c *C) {

s.runTestSQL(c, tkExpect, encoder, sqls, tableID)

tkExpect.MustExec("drop table if exists t1")
schemaSQL = "create table t1(id int auto_increment, a char(10), primary key(id), key a_idx(a))"
tkExpect.MustExec(schemaSQL)
err = encoder.ExecDDLSQL(schemaSQL)
Expand Down Expand Up @@ -227,6 +219,7 @@ func (s *testKvEncoderSuite) TestInsertPkIsHandle(c *C) {
`

tableID = 3
tkExpect.MustExec("drop table if exists t2")
tkExpect.MustExec(schemaSQL)
err = encoder.ExecDDLSQL(schemaSQL)
c.Assert(err, IsNil)
Expand All @@ -250,11 +243,6 @@ func makePrepareTestCase(sql, formatSQL string, param ...interface{}) prepareTes
}

func (s *testKvEncoderSuite) TestPrepareEncode(c *C) {
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
defer store.Close()
defer dom.Close()

alloc := NewAllocator()
encoder, err := New("test", alloc)
c.Assert(err, IsNil)
Expand Down Expand Up @@ -299,19 +287,15 @@ func (s *testKvEncoderSuite) comparePrepareAndNormalEncode(c *C, alloc autoid.Al
}

func (s *testKvEncoderSuite) TestInsertPkIsNotHandle(c *C) {
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
defer store.Close()
defer dom.Close()

tkExpect := testkit.NewTestKit(c, store)
tkExpect := testkit.NewTestKit(c, s.store)
tkExpect.MustExec("use test")

var tableID int64 = 1
encoder, err := New("test", nil)
c.Assert(err, IsNil)
defer encoder.Close()

tkExpect.MustExec("drop table if exists t")
schemaSQL := `create table t(
id varchar(20),
a char(10),
Expand All @@ -333,12 +317,7 @@ func (s *testKvEncoderSuite) TestInsertPkIsNotHandle(c *C) {
}

func (s *testKvEncoderSuite) TestRetryWithAllocator(c *C) {
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
defer store.Close()
defer dom.Close()

tk := testkit.NewTestKit(c, store)
tk := testkit.NewTestKit(c, s.store)

tk.MustExec("use test")
alloc := NewAllocator()
Expand All @@ -347,6 +326,7 @@ func (s *testKvEncoderSuite) TestRetryWithAllocator(c *C) {
c.Assert(err, IsNil)
defer encoder.Close()

tk.MustExec("drop table if exists t")
schemaSQL := `create table t(
id int auto_increment,
a char(10),
Expand Down Expand Up @@ -388,6 +368,7 @@ func (s *testKvEncoderSuite) TestRetryWithAllocator(c *C) {
c.Assert(bytes.Compare(row.Val, retryKvPairs[i].Val), Equals, 0, Commentf(sql))
}

tk.MustExec("drop table if exists t1")
schemaSQL = `create table t1(
id int auto_increment,
a char(10),
Expand Down Expand Up @@ -424,12 +405,7 @@ func (s *testKvEncoderSuite) TestRetryWithAllocator(c *C) {
}

func (s *testKvEncoderSuite) TestAllocatorRebase(c *C) {
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
defer store.Close()
defer dom.Close()

tk := testkit.NewTestKit(c, store)
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
alloc := NewAllocator()
var tableID int64 = 1
Expand Down

0 comments on commit 9bd1fb8

Please sign in to comment.