Skip to content

Commit

Permalink
*: make test more TestSortInDisk stable (#18424) (#18529)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-srebot authored Jul 31, 2020
1 parent 6055d8b commit e7c73b0
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
21 changes: 21 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ var _ = SerialSuites(&testAutoRandomSuite{&baseTestSuite{}})
var _ = SerialSuites(&testClusterTableSuite{})
var _ = SerialSuites(&testPrepareSerialSuite{&baseTestSuite{}})
var _ = SerialSuites(&testSplitTable{&baseTestSuite{}})
var _ = SerialSuites(&testSerialSuite1{&baseTestSuite{}})

type testSuite struct{ *baseTestSuite }
type testSuiteP1 struct{ *baseTestSuite }
Expand Down Expand Up @@ -4103,6 +4104,26 @@ func (s *testSuite8) TearDownTest(c *C) {
}
}

type testSerialSuite1 struct {
*baseTestSuite
}

func (s *testSerialSuite1) 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 if tb[1] == "SEQUENCE" {
tk.MustExec(fmt.Sprintf("drop sequence %v", tableName))
} else {
tk.MustExec(fmt.Sprintf("drop table %v", tableName))
}
}
}

func (s *testSuiteP2) TestStrToDateBuiltin(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustQuery(`select str_to_date('20190101','%Y%m%d%!') from dual`).Check(testkit.Rows("2019-01-01"))
Expand Down
8 changes: 7 additions & 1 deletion executor/merge_join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"strings"

. "github.com/pingcap/check"
"github.com/pingcap/failpoint"
"github.com/pingcap/tidb/config"
"github.com/pingcap/tidb/util"
"github.com/pingcap/tidb/util/testkit"
Expand Down Expand Up @@ -240,13 +241,18 @@ func checkPlanAndRun(tk *testkit.TestKit, c *C, plan string, sql string) *testki
return tk.MustQuery(sql)
}

func (s *testSuite2) TestMergeJoinInDisk(c *C) {
func (s *testSerialSuite1) TestMergeJoinInDisk(c *C) {
originCfg := config.GetGlobalConfig()
newConf := *originCfg
newConf.OOMUseTmpStorage = true
config.StoreGlobalConfig(&newConf)
defer config.StoreGlobalConfig(originCfg)

c.Assert(failpoint.Enable("github.com/pingcap/tidb/executor/testMergeJoinRowContainerSpill", "return(true)"), IsNil)
defer func() {
c.Assert(failpoint.Disable("github.com/pingcap/tidb/executor/testMergeJoinRowContainerSpill"), IsNil)
}()

tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")

Expand Down
2 changes: 1 addition & 1 deletion executor/pkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

var _ = Suite(&pkgTestSuite{})
var _ = SerialSuites(&pkgTestSuite{})
var _ = SerialSuites(&pkgTestSerialSuite{})

type pkgTestSuite struct {
}
Expand Down
22 changes: 19 additions & 3 deletions executor/sort_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@ import (
"strings"

. "github.com/pingcap/check"
"github.com/pingcap/failpoint"
"github.com/pingcap/tidb/config"
"github.com/pingcap/tidb/util"
"github.com/pingcap/tidb/util/testkit"
)

func (s *testSuite) TestSortInDisk(c *C) {
func (s *testSerialSuite1) TestSortInDisk(c *C) {
originCfg := config.GetGlobalConfig()
newConf := *originCfg
newConf.OOMUseTmpStorage = true
config.StoreGlobalConfig(&newConf)
defer config.StoreGlobalConfig(originCfg)
c.Assert(failpoint.Enable("github.com/pingcap/tidb/executor/testSortedRowContainerSpill", "return(true)"), IsNil)
defer func() {
c.Assert(failpoint.Disable("github.com/pingcap/tidb/executor/testSortedRowContainerSpill"), IsNil)
}()

tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
Expand Down Expand Up @@ -60,7 +65,18 @@ func (s *testSuite) TestSortInDisk(c *C) {
c.Assert(tk.Se.GetSessionVars().StmtCtx.DiskTracker.MaxConsumed(), Greater, int64(0))
}

func (s *testSuite) TestIssue16696(c *C) {
func (s *testSerialSuite1) TestIssue16696(c *C) {
originCfg := config.GetGlobalConfig()
newConf := *originCfg
newConf.OOMUseTmpStorage = true
config.StoreGlobalConfig(&newConf)
defer config.StoreGlobalConfig(originCfg)
c.Assert(failpoint.Enable("github.com/pingcap/tidb/executor/testSortedRowContainerSpill", "return(true)"), IsNil)
defer func() {
c.Assert(failpoint.Disable("github.com/pingcap/tidb/executor/testSortedRowContainerSpill"), IsNil)
}()
c.Assert(failpoint.Enable("github.com/pingcap/tidb/executor/testRowContainerSpill", "return(true)"), IsNil)
defer func() { c.Assert(failpoint.Disable("github.com/pingcap/tidb/executor/testRowContainerSpill"), IsNil) }()
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
Expand All @@ -69,7 +85,7 @@ func (s *testSuite) TestIssue16696(c *C) {
for i := 0; i < 6; i++ {
tk.MustExec("insert into t select * from t")
}
tk.MustExec("set tidb_mem_quota_query = 4125000;") // 4.125 MB
tk.MustExec("set tidb_mem_quota_query = 1;")
rows := tk.MustQuery("explain analyze select t1.a, t1.a +1 from t t1 join t t2 join t t3 order by t1.a").Rows()
for _, row := range rows {
length := len(row)
Expand Down

0 comments on commit e7c73b0

Please sign in to comment.