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

executor: split unit tests to speedup execution time #10364

Merged
merged 3 commits into from May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 51 additions & 0 deletions executor/executor_test.go
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
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
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
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
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