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

test: fix unit test and make test running serially. (#16525) #16614

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion executor/seqtest/seq_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestT(t *testing.T) {
TestingT(t)
}

var _ = Suite(&seqTestSuite{})
var _ = SerialSuites(&seqTestSuite{})
var _ = Suite(&seqTestSuite1{})

type seqTestSuite struct {
Expand Down
17 changes: 13 additions & 4 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,23 @@ import (
)

var _ = Suite(&testIntegrationSuite{})
var _ = SerialSuites(&testIntegrationSerialSuite{})

type testIntegrationSuite struct {
type testIntegrationSuiteBase struct {
store kv.Storage
dom *domain.Domain
ctx sessionctx.Context
}

func (s *testIntegrationSuite) cleanEnv(c *C) {
type testIntegrationSuite struct {
testIntegrationSuiteBase
}

type testIntegrationSerialSuite struct {
testIntegrationSuiteBase
}

func (s *testIntegrationSuiteBase) cleanEnv(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
r := tk.MustQuery("show tables")
Expand All @@ -63,15 +72,15 @@ func (s *testIntegrationSuite) cleanEnv(c *C) {
}
}

func (s *testIntegrationSuite) SetUpSuite(c *C) {
func (s *testIntegrationSuiteBase) SetUpSuite(c *C) {
var err error
testleak.BeforeTest()
s.store, s.dom, err = newStoreWithBootstrap()
c.Assert(err, IsNil)
s.ctx = mock.NewContext()
}

func (s *testIntegrationSuite) TearDownSuite(c *C) {
func (s *testIntegrationSuiteBase) TearDownSuite(c *C) {
s.dom.Close()
s.store.Close()
testleak.AfterTest(c)()
Expand Down
5 changes: 5 additions & 0 deletions planner/core/physical_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
)

var _ = Suite(&testPlanSuite{})
var _ = SerialSuites(&testPlanSerialSuite{&testPlanSuite{}})

type testPlanSuite struct {
*parser.Parser
Expand All @@ -41,6 +42,10 @@ type testPlanSuite struct {
testData testutil.TestData
}

type testPlanSerialSuite struct {
*testPlanSuite
}

func (s *testPlanSuite) SetUpSuite(c *C) {
s.is = infoschema.MockInfoSchema([]*model.TableInfo{core.MockSignedTable(), core.MockUnsignedTable()})
s.Parser = parser.New()
Expand Down
2 changes: 1 addition & 1 deletion planner/core/point_get_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
dto "github.com/prometheus/client_model/go"
)

var _ = Suite(&testPointGetSuite{})
var _ = SerialSuites(&testPointGetSuite{})

type testPointGetSuite struct {
store kv.Storage
Expand Down
14 changes: 9 additions & 5 deletions planner/core/prepare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ import (
)

var _ = Suite(&testPrepareSuite{})
var _ = SerialSuites(&testPrepareSerialSuite{})

type testPrepareSuite struct {
}

func (s *testPrepareSuite) TestPrepareCache(c *C) {
type testPrepareSerialSuite struct {
}

func (s *testPrepareSerialSuite) TestPrepareCache(c *C) {
defer testleak.AfterTest(c)()
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
Expand Down Expand Up @@ -87,7 +91,7 @@ func (s *testPrepareSuite) TestPrepareCache(c *C) {
tk.MustQuery("execute stmt6").Check(testkit.Rows("1", "2", "3", "4", "5", "6"))
}

func (s *testPrepareSuite) TestPrepareCacheIndexScan(c *C) {
func (s *testPrepareSerialSuite) TestPrepareCacheIndexScan(c *C) {
defer testleak.AfterTest(c)()
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
Expand Down Expand Up @@ -121,7 +125,7 @@ func (s *testPrepareSuite) TestPrepareCacheIndexScan(c *C) {
tk.MustQuery("execute stmt1 using @a, @b").Check(testkit.Rows("1 3", "1 3"))
}

func (s *testPlanSuite) TestPrepareCacheDeferredFunction(c *C) {
func (s *testPlanSerialSuite) TestPrepareCacheDeferredFunction(c *C) {
defer testleak.AfterTest(c)()
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
Expand Down Expand Up @@ -182,7 +186,7 @@ func (s *testPlanSuite) TestPrepareCacheDeferredFunction(c *C) {
c.Assert(planStr[0] < planStr[1], IsTrue, Commentf("plan 1: %v, plan 2: %v", planStr[0], planStr[1]))
}

func (s *testPrepareSuite) TestPrepareCacheNow(c *C) {
func (s *testPrepareSerialSuite) TestPrepareCacheNow(c *C) {
defer testleak.AfterTest(c)()
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
Expand Down Expand Up @@ -266,7 +270,7 @@ func (s *testPrepareSuite) TestPrepareOverMaxPreparedStmtCount(c *C) {
}

// unit test for issue https://github.com/pingcap/tidb/issues/8518
func (s *testPrepareSuite) TestPrepareTableAsNameOnGroupByWithCache(c *C) {
func (s *testPrepareSerialSuite) TestPrepareTableAsNameOnGroupByWithCache(c *C) {
defer testleak.AfterTest(c)()
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
Expand Down