Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor,store: make leak test more stable #6196

Merged
merged 2 commits into from
Mar 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ type testSuite struct {
var mockTikv = flag.Bool("mockTikv", true, "use mock tikv store in executor test")

func (s *testSuite) SetUpSuite(c *C) {
testleak.BeforeTest()
s.autoIDStep = autoid.GetStep()
autoid.SetStep(5000)
s.Parser = parser.New()
Expand Down Expand Up @@ -112,10 +113,7 @@ func (s *testSuite) TearDownSuite(c *C) {
s.domain.Close()
s.store.Close()
autoid.SetStep(s.autoIDStep)
}

func (s *testSuite) SetUpTest(c *C) {
testleak.BeforeTest()
testleak.AfterTest(c)()
}

func (s *testSuite) TearDownTest(c *C) {
Expand All @@ -126,7 +124,6 @@ func (s *testSuite) TearDownTest(c *C) {
tableName := tb[0]
tk.MustExec(fmt.Sprintf("drop table %v", tableName))
}
testleak.AfterTest(c)()
}

func (s *testSuite) TestAdmin(c *C) {
Expand Down
18 changes: 2 additions & 16 deletions store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type testKVSuite struct {
}

func (s *testKVSuite) SetUpSuite(c *C) {
testleak.BeforeTest()
store, err := mockstore.NewMockTikvStore()
c.Assert(err, IsNil)
s.s = store
Expand All @@ -59,6 +60,7 @@ func (s *testKVSuite) SetUpSuite(c *C) {
func (s *testKVSuite) TearDownSuite(c *C) {
err := s.s.Close()
c.Assert(err, IsNil)
testleak.AfterTest(c)()
}

func insertData(c *C, txn kv.Transaction) {
Expand Down Expand Up @@ -155,7 +157,6 @@ func mustGet(c *C, txn kv.Transaction) {
}

func (s *testKVSuite) TestGetSet(c *C) {
defer testleak.AfterTest(c)()
txn, err := s.s.Begin()
c.Assert(err, IsNil)

Expand All @@ -176,7 +177,6 @@ func (s *testKVSuite) TestGetSet(c *C) {
}

func (s *testKVSuite) TestSeek(c *C) {
defer testleak.AfterTest(c)()
txn, err := s.s.Begin()
c.Assert(err, IsNil)

Expand All @@ -196,7 +196,6 @@ func (s *testKVSuite) TestSeek(c *C) {
}

func (s *testKVSuite) TestInc(c *C) {
defer testleak.AfterTest(c)()
txn, err := s.s.Begin()
c.Assert(err, IsNil)

Expand Down Expand Up @@ -231,7 +230,6 @@ func (s *testKVSuite) TestInc(c *C) {
}

func (s *testKVSuite) TestDelete(c *C) {
defer testleak.AfterTest(c)()
txn, err := s.s.Begin()
c.Assert(err, IsNil)

Expand Down Expand Up @@ -267,7 +265,6 @@ func (s *testKVSuite) TestDelete(c *C) {
}

func (s *testKVSuite) TestDelete2(c *C) {
defer testleak.AfterTest(c)()
txn, err := s.s.Begin()
c.Assert(err, IsNil)
val := []byte("test")
Expand Down Expand Up @@ -299,7 +296,6 @@ func (s *testKVSuite) TestDelete2(c *C) {
}

func (s *testKVSuite) TestSetNil(c *C) {
defer testleak.AfterTest(c)()
txn, err := s.s.Begin()
defer txn.Commit(context.Background())
c.Assert(err, IsNil)
Expand All @@ -308,7 +304,6 @@ func (s *testKVSuite) TestSetNil(c *C) {
}

func (s *testKVSuite) TestBasicSeek(c *C) {
defer testleak.AfterTest(c)()
txn, err := s.s.Begin()
c.Assert(err, IsNil)
txn.Set([]byte("1"), []byte("1"))
Expand All @@ -324,7 +319,6 @@ func (s *testKVSuite) TestBasicSeek(c *C) {
}

func (s *testKVSuite) TestBasicTable(c *C) {
defer testleak.AfterTest(c)()
txn, err := s.s.Begin()
c.Assert(err, IsNil)
for i := 1; i < 5; i++ {
Expand Down Expand Up @@ -372,7 +366,6 @@ func (s *testKVSuite) TestBasicTable(c *C) {
}

func (s *testKVSuite) TestRollback(c *C) {
defer testleak.AfterTest(c)()
txn, err := s.s.Begin()
c.Assert(err, IsNil)

Expand Down Expand Up @@ -400,7 +393,6 @@ func (s *testKVSuite) TestRollback(c *C) {
}

func (s *testKVSuite) TestSeekMin(c *C) {
defer testleak.AfterTest(c)()
rows := []struct {
key string
value string
Expand Down Expand Up @@ -435,7 +427,6 @@ func (s *testKVSuite) TestSeekMin(c *C) {
}

func (s *testKVSuite) TestConditionIfNotExist(c *C) {
defer testleak.AfterTest(c)()
var success int64
cnt := 100
b := []byte("1")
Expand Down Expand Up @@ -470,7 +461,6 @@ func (s *testKVSuite) TestConditionIfNotExist(c *C) {
}

func (s *testKVSuite) TestConditionIfEqual(c *C) {
defer testleak.AfterTest(c)()
var success int64
cnt := 100
b := []byte("1")
Expand Down Expand Up @@ -510,7 +500,6 @@ func (s *testKVSuite) TestConditionIfEqual(c *C) {
}

func (s *testKVSuite) TestConditionUpdate(c *C) {
defer testleak.AfterTest(c)()
txn, err := s.s.Begin()
c.Assert(err, IsNil)
txn.Delete([]byte("b"))
Expand All @@ -521,7 +510,6 @@ func (s *testKVSuite) TestConditionUpdate(c *C) {

func (s *testKVSuite) TestDBClose(c *C) {
c.Skip("don't know why it fails.")
defer testleak.AfterTest(c)()
store, err := mockstore.NewMockTikvStore()
c.Assert(err, IsNil)

Expand Down Expand Up @@ -564,7 +552,6 @@ func (s *testKVSuite) TestDBClose(c *C) {
}

func (s *testKVSuite) TestIsolationInc(c *C) {
defer testleak.AfterTest(c)()
threadCnt := 4

ids := make(map[int64]struct{}, threadCnt*100)
Expand Down Expand Up @@ -603,7 +590,6 @@ func (s *testKVSuite) TestIsolationInc(c *C) {
}

func (s *testKVSuite) TestIsolationMultiInc(c *C) {
defer testleak.AfterTest(c)()
threadCnt := 4
incCnt := 100
keyCnt := 4
Expand Down