diff --git a/table/tables/index_test.go b/table/tables/index_test.go index 2629e3e7e9dfa..2824c53072c09 100644 --- a/table/tables/index_test.go +++ b/table/tables/index_test.go @@ -28,9 +28,7 @@ import ( "github.com/pingcap/tidb/ddl" "github.com/pingcap/tidb/domain" "github.com/pingcap/tidb/kv" - "github.com/pingcap/tidb/session" "github.com/pingcap/tidb/sessionctx/stmtctx" - "github.com/pingcap/tidb/store/mockstore" "github.com/pingcap/tidb/table" "github.com/pingcap/tidb/table/tables" "github.com/pingcap/tidb/tablecodec" @@ -47,16 +45,6 @@ type testIndexSuite struct { dom *domain.Domain } -var s = testIndexSuite{} - -func TestSetUpSuite(t *testing.T) { - store, err := mockstore.NewMockStore() - require.Nil(t, err) - s.s = store - s.dom, err = session.BootstrapSession(store) - require.Nil(t, err) -} - func TestIndex(t *testing.T) { tblInfo := &model.TableInfo{ ID: 1, @@ -399,8 +387,3 @@ func buildTableInfo(t *testing.T, sql string) *model.TableInfo { return tblInfo } -func TestTearDownSuite(t *testing.T) { - s.dom.Close() - err := s.s.Close() - require.Nil(t, err) -} diff --git a/table/tables/main_test.go b/table/tables/main_test.go index be83c73b29f93..10b135e26e4b1 100644 --- a/table/tables/main_test.go +++ b/table/tables/main_test.go @@ -15,18 +15,53 @@ package tables_test import ( + "github.com/pingcap/tidb/session" + "github.com/pingcap/tidb/store/mockstore" + "log" + "os" "testing" "github.com/pingcap/tidb/util/testbridge" "go.uber.org/goleak" ) +var s = testIndexSuite{} + func TestMain(m *testing.M) { testbridge.WorkaroundGoCheckFlags() + setUpIndexSuite() + exitCode := m.Run() + tearDownIndexSuite() + if exitCode != 0 { + os.Exit(exitCode) + } + opts := []goleak.Option{ goleak.IgnoreTopFunction("go.etcd.io/etcd/pkg/logutil.(*MergeLogger).outputLoop"), goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"), } goleak.VerifyTestMain(m, opts...) } + +func setUpIndexSuite() { + println("setUpIndexSuite") + store, err := mockstore.NewMockStore() + if err != nil { + log.Fatal(err) + } + s.s = store + s.dom, err = session.BootstrapSession(store) + if err != nil { + log.Fatal(err) + } +} + +func tearDownIndexSuite() { + println("tearDownIndexSuite") + s.dom.Close() + err := s.s.Close() + if err != nil { + log.Fatal(err) + } +}