From 1fb452faee26bf957d1b5da37f9424a6d9efa2fc Mon Sep 17 00:00:00 2001 From: tison Date: Mon, 4 Apr 2022 21:20:45 +0800 Subject: [PATCH 1/2] executor: migrate test-infra to testify for executor_test.testSerialSuite2 Signed-off-by: tison --- executor/executor_legacy_test.go | 24 ------------------------ executor/executor_test.go | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/executor/executor_legacy_test.go b/executor/executor_legacy_test.go index 8b31f528667cc..9bf29a3059ba8 100644 --- a/executor/executor_legacy_test.go +++ b/executor/executor_legacy_test.go @@ -58,7 +58,6 @@ import ( "github.com/pingcap/tidb/sessionctx" "github.com/pingcap/tidb/sessionctx/stmtctx" "github.com/pingcap/tidb/sessionctx/variable" - "github.com/pingcap/tidb/statistics" "github.com/pingcap/tidb/store/copr" error2 "github.com/pingcap/tidb/store/driver/error" "github.com/pingcap/tidb/store/mockstore" @@ -93,10 +92,8 @@ func TestT(t *testing.T) { } var _ = Suite(&testSuite{&baseTestSuite{}}) -var _ = Suite(&testSuiteP1{&baseTestSuite{}}) var _ = Suite(&testSuiteP2{&baseTestSuite{}}) var _ = Suite(&testSuite1{}) -var _ = SerialSuites(&testSerialSuite2{}) var _ = SerialSuites(&testSuiteWithCliBaseCharset{}) var _ = Suite(&testSuite2{&baseTestSuite{}}) var _ = Suite(&testSuite3{&baseTestSuite{}}) @@ -110,7 +107,6 @@ var _ = SerialSuites(&globalIndexSuite{&baseTestSuite{}}) var _ = SerialSuites(&testSerialSuite{&baseTestSuite{}}) type testSuite struct{ *baseTestSuite } -type testSuiteP1 struct{ *baseTestSuite } type testSuiteP2 struct{ *baseTestSuite } type testSplitTable struct{ *baseTestSuite } type globalIndexSuite struct{ *baseTestSuite } @@ -2088,10 +2084,6 @@ type testSuite1 struct { testSuiteWithCliBase } -type testSerialSuite2 struct { - testSuiteWithCliBase -} - func (s *testSuiteWithCliBase) SetUpSuite(c *C) { cli := &checkRequestClient{} hijackClient := func(c tikv.Client) tikv.Client { @@ -3277,22 +3269,6 @@ func (s *testSuiteP2) TestIssue10435(c *C) { ) } -func (s *testSerialSuite2) TestUnsignedFeedback(c *C) { - tk := testkit.NewTestKit(c, s.store) - oriProbability := statistics.FeedbackProbability.Load() - statistics.FeedbackProbability.Store(1.0) - defer func() { statistics.FeedbackProbability.Store(oriProbability) }() - tk.MustExec("use test") - tk.MustExec("drop table if exists t") - tk.MustExec("create table t(a bigint unsigned, b int, primary key(a))") - tk.MustExec("insert into t values (1,1),(2,2)") - tk.MustExec("analyze table t") - tk.MustQuery("select count(distinct b) from t").Check(testkit.Rows("2")) - result := tk.MustQuery("explain analyze select count(distinct b) from t") - c.Assert(result.Rows()[2][4], Equals, "table:t") - c.Assert(result.Rows()[2][6], Equals, "keep order:false") -} - func (s *testSuiteWithCliBaseCharset) TestCharsetFeature(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") diff --git a/executor/executor_test.go b/executor/executor_test.go index 7f09b575c5d9a..525877a8b84e8 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -23,6 +23,7 @@ import ( "github.com/pingcap/tidb/domain" "github.com/pingcap/tidb/parser/mysql" "github.com/pingcap/tidb/sessionctx/variable" + "github.com/pingcap/tidb/statistics" "github.com/pingcap/tidb/testkit" "github.com/pingcap/tidb/testkit/testdata" "github.com/pingcap/tidb/util/dbterror" @@ -1523,3 +1524,21 @@ func TestDropColWithPrimaryKey(t *testing.T) { tk.MustExec("set global tidb_enable_change_multi_schema = on") tk.MustExec("alter table t drop column c3") } + +func TestUnsignedFeedback(t *testing.T) { + store, clean := testkit.CreateMockStore(t) + defer clean() + + tk := testkit.NewTestKit(t, store) + oriProbability := statistics.FeedbackProbability.Load() + statistics.FeedbackProbability.Store(1.0) + defer func() { statistics.FeedbackProbability.Store(oriProbability) }() + tk.MustExec("use test") + tk.MustExec("create table t(a bigint unsigned, b int, primary key(a))") + tk.MustExec("insert into t values (1,1),(2,2)") + tk.MustExec("analyze table t") + tk.MustQuery("select count(distinct b) from t").Check(testkit.Rows("2")) + result := tk.MustQuery("explain analyze select count(distinct b) from t") + require.Equal(t, "table:t", result.Rows()[2][4]) + require.Equal(t, "keep order:false", result.Rows()[2][6]) +} From 61ae02750d0df9342e0575fac87a4354bf653ecc Mon Sep 17 00:00:00 2001 From: tison Date: Mon, 4 Apr 2022 21:26:08 +0800 Subject: [PATCH 2/2] executor: remove dummy globalIndexSuite Signed-off-by: tison --- executor/executor_legacy_test.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/executor/executor_legacy_test.go b/executor/executor_legacy_test.go index 9bf29a3059ba8..5de18019dd4af 100644 --- a/executor/executor_legacy_test.go +++ b/executor/executor_legacy_test.go @@ -103,13 +103,11 @@ var _ = SerialSuites(&testRecoverTable{}) var _ = SerialSuites(&testClusterTableSuite{}) var _ = SerialSuites(&testSplitTable{&baseTestSuite{}}) var _ = SerialSuites(&testSerialSuite1{&baseTestSuite{}}) -var _ = SerialSuites(&globalIndexSuite{&baseTestSuite{}}) var _ = SerialSuites(&testSerialSuite{&baseTestSuite{}}) type testSuite struct{ *baseTestSuite } type testSuiteP2 struct{ *baseTestSuite } type testSplitTable struct{ *baseTestSuite } -type globalIndexSuite struct{ *baseTestSuite } type testSerialSuite struct{ *baseTestSuite } // MockGC is used to make GC work in the test environment. @@ -171,13 +169,6 @@ func (s *baseTestSuite) TearDownSuite(c *C) { c.Assert(s.store.Close(), IsNil) } -func (s *globalIndexSuite) SetUpSuite(c *C) { - s.baseTestSuite.SetUpSuite(c) - config.UpdateGlobal(func(conf *config.Config) { - conf.EnableGlobalIndex = true - }) -} - func (s *testSuite) TearDownTest(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test")