From 80a23200a12e7b85ee464bb46a1c3955d05fe62f Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Wed, 3 Feb 2021 19:45:16 +0800 Subject: [PATCH 1/2] statistics,executor: fix some unit tests that run twice --- executor/clustered_index_test.go | 2 +- executor/executor_test.go | 2 +- statistics/handle/handle_test.go | 4 ++-- statistics/handle/update_test.go | 12 ++++++++---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/executor/clustered_index_test.go b/executor/clustered_index_test.go index 0d6f611ec2177..5c9d9db32ac37 100644 --- a/executor/clustered_index_test.go +++ b/executor/clustered_index_test.go @@ -22,7 +22,7 @@ import ( ) type testClusteredSuite struct{ *baseTestSuite } -type testClusteredSerialSuite struct{ *testClusteredSuite } +type testClusteredSerialSuite struct{ *baseTestSuite } func (s *testClusteredSuite) SetUpTest(c *C) { } diff --git a/executor/executor_test.go b/executor/executor_test.go index d34d4b486aa5b..28bf54ac6741c 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -119,7 +119,7 @@ var _ = Suite(&testSuite6{&baseTestSuite{}}) var _ = Suite(&testSuite7{&baseTestSuite{}}) var _ = Suite(&testSuite8{&baseTestSuite{}}) var _ = Suite(&testClusteredSuite{&baseTestSuite{}}) -var _ = SerialSuites(&testClusteredSerialSuite{&testClusteredSuite{&baseTestSuite{}}}) +var _ = SerialSuites(&testClusteredSerialSuite{}) var _ = SerialSuites(&testShowStatsSuite{&baseTestSuite{}}) var _ = Suite(&testBypassSuite{}) var _ = Suite(&testUpdateSuite{}) diff --git a/statistics/handle/handle_test.go b/statistics/handle/handle_test.go index a319b2f0f6426..bc666995a55a9 100644 --- a/statistics/handle/handle_test.go +++ b/statistics/handle/handle_test.go @@ -840,10 +840,10 @@ func (s *testStatsSuite) TestCorrelationStatsCompute(c *C) { c.Assert(foundS1 && foundS2, IsTrue) } -var _ = SerialSuites(&statsSerialSuite{&testStatsSuite{}}) +var _ = SerialSuites(&statsSerialSuite{}) type statsSerialSuite struct { - *testStatsSuite + testSuiteBase } func (s *statsSerialSuite) TestIndexUsageInformation(c *C) { diff --git a/statistics/handle/update_test.go b/statistics/handle/update_test.go index 71b50da123995..a694822a8ef91 100644 --- a/statistics/handle/update_test.go +++ b/statistics/handle/update_test.go @@ -45,13 +45,17 @@ import ( var _ = Suite(&testStatsSuite{}) -type testStatsSuite struct { +type testSuiteBase struct { store kv.Storage do *domain.Domain hook *logHook } -func (s *testStatsSuite) SetUpSuite(c *C) { +type testStatsSuite struct { + testSuiteBase +} + +func (s *testSuiteBase) SetUpSuite(c *C) { testleak.BeforeTest() // Add the hook here to avoid data race. s.registerHook() @@ -60,13 +64,13 @@ func (s *testStatsSuite) SetUpSuite(c *C) { c.Assert(err, IsNil) } -func (s *testStatsSuite) TearDownSuite(c *C) { +func (s *testSuiteBase) TearDownSuite(c *C) { s.do.Close() s.store.Close() testleak.AfterTest(c)() } -func (s *testStatsSuite) registerHook() { +func (s *testSuiteBase) registerHook() { conf := &log.Config{Level: os.Getenv("log_level"), File: log.FileLogConfig{}} _, r, _ := log.InitLogger(conf) s.hook = &logHook{r.Core, ""} From 9c0e5567bfe2c302b80815c690d911f2be81a595 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Thu, 4 Feb 2021 08:59:03 +0800 Subject: [PATCH 2/2] fix CI --- executor/clustered_index_test.go | 10 ++++------ executor/executor_test.go | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/executor/clustered_index_test.go b/executor/clustered_index_test.go index 5c9d9db32ac37..e96863522410e 100644 --- a/executor/clustered_index_test.go +++ b/executor/clustered_index_test.go @@ -21,13 +21,11 @@ import ( "github.com/pingcap/tidb/util/testkit" ) -type testClusteredSuite struct{ *baseTestSuite } -type testClusteredSerialSuite struct{ *baseTestSuite } +type testClusteredSuiteBase struct{ baseTestSuite } +type testClusteredSuite struct{ testClusteredSuiteBase } +type testClusteredSerialSuite struct{ testClusteredSuiteBase } -func (s *testClusteredSuite) SetUpTest(c *C) { -} - -func (s *testClusteredSuite) newTK(c *C) *testkit.TestKit { +func (s *testClusteredSuiteBase) newTK(c *C) *testkit.TestKit { tk := testkit.NewTestKitWithInit(c, s.store) tk.MustExec("set @@tidb_enable_clustered_index = 1") return tk diff --git a/executor/executor_test.go b/executor/executor_test.go index 28bf54ac6741c..32252dbd89aa3 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -118,7 +118,7 @@ var _ = Suite(&testSuiteAgg{baseTestSuite: &baseTestSuite{}}) var _ = Suite(&testSuite6{&baseTestSuite{}}) var _ = Suite(&testSuite7{&baseTestSuite{}}) var _ = Suite(&testSuite8{&baseTestSuite{}}) -var _ = Suite(&testClusteredSuite{&baseTestSuite{}}) +var _ = Suite(&testClusteredSuite{}) var _ = SerialSuites(&testClusteredSerialSuite{}) var _ = SerialSuites(&testShowStatsSuite{&baseTestSuite{}}) var _ = Suite(&testBypassSuite{})