Skip to content

Commit

Permalink
executor: migrate goroutine leak tests to goleak
Browse files Browse the repository at this point in the history
Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun committed Aug 19, 2021
1 parent dfe9acf commit bb6bc87
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (s *testPrepareSuite) TearDownSuite(c *C) {

func (s *baseTestSuite) TearDownSuite(c *C) {
s.domain.Close()
s.store.Close()
c.Assert(s.store.Close(), IsNil)
}

func (s *globalIndexSuite) SetUpSuite(c *C) {
Expand Down Expand Up @@ -8569,7 +8569,7 @@ func (s testSerialSuite) assertTemporaryTableNoNetwork(c *C, temporaryTableType
// With that failpoint, all requests to the TiKV is discard.
rs, err := tk1.Exec("select * from normal")
c.Assert(err, IsNil)
blocked := make(chan struct{})
blocked := make(chan struct{}, 1)
ctx, cancelFunc := context.WithCancel(context.Background())
go func() {
_, err := session.ResultSetToStringSlice(ctx, tk1.Se, rs)
Expand Down
9 changes: 7 additions & 2 deletions executor/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@
package executor

import (
"os"
"testing"

"github.com/pingcap/tidb/util/testbridge"
"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
testbridge.WorkaroundGoCheckFlags()
os.Exit(m.Run())
opts := []goleak.Option{
goleak.IgnoreTopFunction("go.etcd.io/etcd/pkg/logutil.(*MergeLogger).outputLoop"),
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
goleak.IgnoreTopFunction("gopkg.in/natefinch/lumberjack%2ev2.(*Logger).millRun"),
}
goleak.VerifyTestMain(m, opts...)
}
5 changes: 5 additions & 0 deletions executor/sample_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ func (s *testTableSampleSuite) SetUpSuite(c *C) {
s.domain = d
}

func (s *testTableSampleSuite) TearDownSuite(c *C) {
s.domain.Close()
c.Assert(s.store.Close(), IsNil)
}

func (s *testTableSampleSuite) initSampleTest(c *C) *testkit.TestKit {
atomic.StoreUint32(&ddl.EnableSplitTableRegion, 1)
tk := testkit.NewTestKit(c, s.store)
Expand Down
2 changes: 1 addition & 1 deletion executor/seqtest/seq_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (s *seqTestSuite) SetUpSuite(c *C) {

func (s *seqTestSuite) TearDownSuite(c *C) {
s.domain.Close()
s.store.Close()
c.Assert(s.store.Close(), IsNil)
}

func (s *seqTestSuite) TestEarlyClose(c *C) {
Expand Down
2 changes: 1 addition & 1 deletion executor/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (s *testUpdateSuite) SetUpSuite(c *C) {

func (s *testUpdateSuite) TearDownSuite(c *C) {
s.domain.Close()
s.store.Close()
c.Assert(s.store.Close(), IsNil)
}

func (s *testUpdateSuite) TearDownTest(c *C) {
Expand Down

0 comments on commit bb6bc87

Please sign in to comment.