diff --git a/executor/executor_test.go b/executor/executor_test.go index 8d20f0f48e2c4..3b236a0507ff9 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -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) { @@ -8577,7 +8577,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) diff --git a/executor/main_test.go b/executor/main_test.go index dbd7e4c057811..b5ac20bf97e21 100644 --- a/executor/main_test.go +++ b/executor/main_test.go @@ -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...) } diff --git a/executor/sample_test.go b/executor/sample_test.go index c2575b6ca7bb8..d200919081e84 100644 --- a/executor/sample_test.go +++ b/executor/sample_test.go @@ -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) diff --git a/executor/seqtest/seq_executor_test.go b/executor/seqtest/seq_executor_test.go index 72f4ebb95b9f2..bb81ab9c9d270 100644 --- a/executor/seqtest/seq_executor_test.go +++ b/executor/seqtest/seq_executor_test.go @@ -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) { diff --git a/executor/update_test.go b/executor/update_test.go index d22b8af74353a..683fe7455574a 100644 --- a/executor/update_test.go +++ b/executor/update_test.go @@ -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) {