Skip to content

Commit

Permalink
executor: split unit tests to speedup execution time (#10364)
Browse files Browse the repository at this point in the history
  • Loading branch information
eurekaka authored and ngaut committed May 6, 2019
1 parent 7ecb315 commit f17a115
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 40 deletions.
51 changes: 51 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3636,6 +3636,57 @@ func (s *testSuite3) TearDownTest(c *C) {
}
}

type testSuite4 struct {
cluster *mocktikv.Cluster
mvccStore mocktikv.MVCCStore
store kv.Storage
domain *domain.Domain
*parser.Parser
ctx *mock.Context
}

func (s *testSuite4) SetUpSuite(c *C) {
s.Parser = parser.New()
flag.Lookup("mockTikv")
useMockTikv := *mockTikv
if useMockTikv {
s.cluster = mocktikv.NewCluster()
mocktikv.BootstrapWithSingleStore(s.cluster)
s.mvccStore = mocktikv.MustNewMVCCStore()
store, err := mockstore.NewMockTikvStore(
mockstore.WithCluster(s.cluster),
mockstore.WithMVCCStore(s.mvccStore),
)
c.Assert(err, IsNil)
s.store = store
session.SetSchemaLease(0)
session.SetStatsLease(0)
}
d, err := session.BootstrapSession(s.store)
c.Assert(err, IsNil)
d.SetStatsUpdating(true)
s.domain = d
}

func (s *testSuite4) TearDownSuite(c *C) {
s.domain.Close()
s.store.Close()
}

func (s *testSuite4) TearDownTest(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
r := tk.MustQuery("show full tables")
for _, tb := range r.Rows() {
tableName := tb[0]
if tb[1] == "VIEW" {
tk.MustExec(fmt.Sprintf("drop view %v", tableName))
} else {
tk.MustExec(fmt.Sprintf("drop table %v", tableName))
}
}
}

func (s *testSuite) TestStrToDateBuiltin(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustQuery(`select str_to_date('18/10/22','%y/%m/%d') from dual`).Check(testkit.Rows("2018-10-22"))
Expand Down
2 changes: 1 addition & 1 deletion executor/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/pingcap/tidb/util/testkit"
)

func (s *testSuite2) TestStmtLabel(c *C) {
func (s *testSuite4) TestStmtLabel(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("create table label (c1 int primary key, c2 int, c3 int, index (c2))")
Expand Down
2 changes: 1 addition & 1 deletion executor/sort_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/pingcap/tidb/util/testkit"
)

func (s *testSuite2) TestSortRand(c *C) {
func (s *testSuite4) TestSortRand(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
Expand Down
4 changes: 2 additions & 2 deletions executor/union_scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/pingcap/tidb/util/testkit"
)

func (s *testSuite2) TestDirtyTransaction(c *C) {
func (s *testSuite4) TestDirtyTransaction(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
Expand Down Expand Up @@ -94,7 +94,7 @@ func (s *testSuite2) TestDirtyTransaction(c *C) {
tk.MustExec("commit")
}

func (s *testSuite2) TestUnionScanWithCastCondition(c *C) {
func (s *testSuite4) TestUnionScanWithCastCondition(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("create table ta (a varchar(20))")
Expand Down
2 changes: 1 addition & 1 deletion executor/window_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/pingcap/tidb/util/testkit"
)

func (s *testSuite2) TestWindowFunctions(c *C) {
func (s *testSuite4) TestWindowFunctions(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
Expand Down
Loading

0 comments on commit f17a115

Please sign in to comment.