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

ddl: speed up the execution time of ddl test and Test Chunk #7 ddl-other #24780

Merged
merged 4 commits into from
May 21, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 19 additions & 51 deletions ddl/db_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ var _ = Suite(&testIntegrationSuite3{&testIntegrationSuite{}})
var _ = Suite(&testIntegrationSuite4{&testIntegrationSuite{}})
var _ = Suite(&testIntegrationSuite5{&testIntegrationSuite{}})
var _ = Suite(&testIntegrationSuite6{&testIntegrationSuite{}})
var _ = SerialSuites(&testIntegrationSuite7{&testIntegrationSuite{}})
var _ = SerialSuites(&testIntegrationSuite8{&testIntegrationSuite{}})

type testIntegrationSuite struct {
lease time.Duration
Expand Down Expand Up @@ -127,8 +125,6 @@ type testIntegrationSuite4 struct{ *testIntegrationSuite }
type testIntegrationSuite5 struct{ *testIntegrationSuite }
type testIntegrationSuite6 struct{ *testIntegrationSuite }
type testIntegrationSuite7 struct{ *testIntegrationSuite }
type testIntegrationSuite8 struct{ *testIntegrationSuite }
type testIntegrationSuite9 struct{ *testIntegrationSuite }

func (s *testIntegrationSuite5) TestNoZeroDateMode(c *C) {
tk := testkit.NewTestKit(c, s.store)
Expand Down Expand Up @@ -223,9 +219,10 @@ func (s *testIntegrationSuite2) TestCreateTableWithKeyWord(c *C) {
c.Assert(err, IsNil)
}

func (s *testIntegrationSuite1) TestUniqueKeyNullValue(c *C) {
func (s *testIntegrationSuite6) TestUniqueKeyNullValue(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("USE test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int primary key, b varchar(255))")

tk.MustExec("insert into t values(1, NULL)")
Expand Down Expand Up @@ -308,7 +305,7 @@ func (s *testIntegrationSuite2) TestIssue19229(c *C) {
tk.MustExec("drop table sett")
}

func (s *testIntegrationSuite1) TestIndexLength(c *C) {
func (s *testIntegrationSuite7) TestIndexLength(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("create table idx_len(a int(0), b timestamp(0), c datetime(0), d time(0), f float(0), g decimal(0))")
Expand Down Expand Up @@ -384,7 +381,7 @@ func (s *testIntegrationSuite1) TestIssue4432(c *C) {
tk.MustExec("drop table tx")
}

func (s *testIntegrationSuite1) TestIssue5092(c *C) {
func (s *testIntegrationSuite7) TestIssue5092(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")

Expand Down Expand Up @@ -641,6 +638,9 @@ func (s *testIntegrationSuite3) TestTableDDLWithFloatType(c *C) {
}

func (s *testIntegrationSuite1) TestTableDDLWithTimeType(c *C) {
if israce.RaceEnabled {
c.Skip("skip race test")
}
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
Expand Down Expand Up @@ -1059,7 +1059,7 @@ func (s *testIntegrationSuite4) TestIndexOnMultipleGeneratedColumn5(c *C) {
tk.MustExec("admin check table t")
}

func (s *testIntegrationSuite2) TestCaseInsensitiveCharsetAndCollate(c *C) {
func (s *testIntegrationSuite6) TestCaseInsensitiveCharsetAndCollate(c *C) {
tk := testkit.NewTestKit(c, s.store)

tk.MustExec("create database if not exists test_charset_collate")
Expand Down Expand Up @@ -1288,41 +1288,6 @@ func (s *testIntegrationSuite5) TestBackwardCompatibility(c *C) {
tk.MustExec("admin check index t idx_b")
}

func (s *testIntegrationSuite3) TestMultiRegionGetTableEndHandle(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("drop database if exists test_get_endhandle")
tk.MustExec("create database test_get_endhandle")
tk.MustExec("use test_get_endhandle")

tk.MustExec("create table t(a bigint PRIMARY KEY nonclustered, b int)")
for i := 0; i < 1000; i++ {
tk.MustExec(fmt.Sprintf("insert into t values(%v, %v)", i, i))
}

// Get table ID for split.
dom := domain.GetDomain(tk.Se)
is := dom.InfoSchema()
tbl, err := is.TableByName(model.NewCIStr("test_get_endhandle"), model.NewCIStr("t"))
c.Assert(err, IsNil)
tblID := tbl.Meta().ID

d := s.dom.DDL()
testCtx := newTestMaxTableRowIDContext(c, d, tbl)

// Split the table.
tableStart := tablecodec.GenTableRecordPrefix(tblID)
s.cluster.SplitKeys(tableStart, tableStart.PrefixNext(), 100)

maxHandle, emptyTable := getMaxTableHandle(testCtx, s.store)
c.Assert(emptyTable, IsFalse)
c.Assert(maxHandle, Equals, kv.IntHandle(1000))

tk.MustExec("insert into t values(10000, 1000)")
maxHandle, emptyTable = getMaxTableHandle(testCtx, s.store)
c.Assert(emptyTable, IsFalse)
c.Assert(maxHandle, Equals, kv.IntHandle(1001))
}

type testMaxTableRowIDContext struct {
c *C
d ddl.DDL
Expand Down Expand Up @@ -1369,6 +1334,9 @@ func getHistoryDDLJob(store kv.Storage, id int64) (*model.Job, error) {
}

func (s *testIntegrationSuite6) TestCreateTableTooLarge(c *C) {
if israce.RaceEnabled {
c.Skip("skip race test")
}
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")

Expand All @@ -1390,7 +1358,7 @@ func (s *testIntegrationSuite6) TestCreateTableTooLarge(c *C) {
atomic.StoreUint32(&config.GetGlobalConfig().TableColumnCountLimit, originLimit)
}

func (s *testIntegrationSuite8) TestCreateTableTooManyIndexes(c *C) {
func (s *testSerialDBSuite1) TestCreateTableTooManyIndexes(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")

Expand Down Expand Up @@ -1519,7 +1487,7 @@ func (s *testIntegrationSuite6) TestAddColumnTooMany(c *C) {
tk.MustGetErrCode(alterSQL, errno.ErrTooManyFields)
}

func (s *testIntegrationSuite8) TestCreateTooManyIndexes(c *C) {
func (s *testSerialDBSuite1) TestCreateTooManyIndexes(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
count := config.GetGlobalConfig().IndexLimit - 1
Expand All @@ -1541,7 +1509,7 @@ func (s *testIntegrationSuite8) TestCreateTooManyIndexes(c *C) {
tk.MustGetErrCode(alterSQL, errno.ErrTooManyKeys)
}

func (s *testIntegrationSuite8) TestCreateSecondaryIndexInCluster(c *C) {
func (s *testSerialDBSuite1) TestCreateSecondaryIndexInCluster(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")

Expand Down Expand Up @@ -2271,7 +2239,7 @@ func (s *testIntegrationSuite3) TestParserIssue284(c *C) {
tk.MustExec("drop table test.t_parser_issue_284_2")
}

func (s *testIntegrationSuite7) TestAddExpressionIndex(c *C) {
func (s *testSerialDBSuite1) TestAddExpressionIndex(c *C) {
config.UpdateGlobal(func(conf *config.Config) {
conf.Experimental.AllowsExpressionIndex = true
})
Expand Down Expand Up @@ -2337,7 +2305,7 @@ func (s *testIntegrationSuite7) TestAddExpressionIndex(c *C) {
tk.MustGetErrMsg("create table t(a int, key ((a+1)));", "[ddl:8200]Unsupported creating expression index without allow-expression-index in config")
}

func (s *testIntegrationSuite7) TestCreateExpressionIndexError(c *C) {
func (s *testSerialDBSuite1) TestCreateExpressionIndexError(c *C) {
defer config.RestoreFunc()()
config.UpdateGlobal(func(conf *config.Config) {
conf.Experimental.AllowsExpressionIndex = true
Expand Down Expand Up @@ -2380,7 +2348,7 @@ func (s *testIntegrationSuite7) TestCreateExpressionIndexError(c *C) {
tk.MustGetErrCode("CREATE TABLE t1 (col1 INT, PRIMARY KEY ((ABS(col1))) NONCLUSTERED);", errno.ErrFunctionalIndexPrimaryKey)
}

func (s *testIntegrationSuite7) TestAddExpressionIndexOnPartition(c *C) {
func (s *testSerialDBSuite1) TestAddExpressionIndexOnPartition(c *C) {
config.UpdateGlobal(func(conf *config.Config) {
conf.Experimental.AllowsExpressionIndex = true
})
Expand Down Expand Up @@ -2634,7 +2602,7 @@ func (s *testSerialDBSuite) TestDropLastVisibleColumnOrColumns(c *C) {
tk.MustExec("drop table if exists t_drop_last_column, t_drop_last_columns")
}

func (s *testIntegrationSuite7) TestAutoIncrementTableOption(c *C) {
func (s *testSerialDBSuite1) TestAutoIncrementTableOption(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("drop database if exists test_auto_inc_table_opt;")
tk.MustExec("create database test_auto_inc_table_opt;")
Expand Down Expand Up @@ -2726,7 +2694,7 @@ func (s *testIntegrationSuite3) TestStrictDoubleTypeCheck(c *C) {
tk.MustExec(sql)
}

func (s *testIntegrationSuite7) TestDuplicateErrorMessage(c *C) {
func (s *testSerialDBSuite) TestDuplicateErrorMessage(c *C) {
defer collate.SetNewCollationEnabledForTest(false)
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
Expand Down
24 changes: 14 additions & 10 deletions ddl/db_partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/admin"
"github.com/pingcap/tidb/util/collate"
"github.com/pingcap/tidb/util/israce"
"github.com/pingcap/tidb/util/mock"
"github.com/pingcap/tidb/util/testkit"
)
Expand Down Expand Up @@ -359,7 +360,7 @@ func (s *testIntegrationSuite2) TestCreateTableWithHashPartition(c *C) {
tk.MustExec("create table t4 (a int, b int) partition by hash(floor(a-b)) partitions 10")
}

func (s *testIntegrationSuite7) TestCreateTableWithRangeColumnPartition(c *C) {
func (s *testSerialDBSuite1) TestCreateTableWithRangeColumnPartition(c *C) {
collate.SetNewCollationEnabledForTest(true)
defer collate.SetNewCollationEnabledForTest(false)
tk := testkit.NewTestKit(c, s.store)
Expand Down Expand Up @@ -593,6 +594,9 @@ create table log_message_1 (
}

func (s *testIntegrationSuite1) TestDisableTablePartition(c *C) {
if israce.RaceEnabled {
c.Skip("skip race test")
}
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test;")
for _, v := range []string{"'AUTO'", "'OFF'", "0", "'ON'"} {
Expand Down Expand Up @@ -1603,7 +1607,7 @@ func (s *testIntegrationSuite5) TestMultiPartitionDropAndTruncate(c *C) {
result.Check(testkit.Rows(`2010`))
}

func (s *testIntegrationSuite7) TestDropPartitionWithGlobalIndex(c *C) {
func (s *testSerialDBSuite1) TestDropPartitionWithGlobalIndex(c *C) {
config.UpdateGlobal(func(conf *config.Config) {
conf.EnableGlobalIndex = true
})
Expand Down Expand Up @@ -1641,7 +1645,7 @@ func (s *testIntegrationSuite7) TestDropPartitionWithGlobalIndex(c *C) {
})
}

func (s *testIntegrationSuite7) TestAlterTableExchangePartition(c *C) {
func (s *testSerialDBSuite1) TestAlterTableExchangePartition(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists e")
Expand Down Expand Up @@ -2076,7 +2080,7 @@ func (s *testIntegrationSuite4) TestExchangePartitionTableCompatiable(c *C) {
c.Assert(err, IsNil)
}

func (s *testIntegrationSuite7) TestExchangePartitionExpressIndex(c *C) {
func (s *testSerialDBSuite1) TestExchangePartitionExpressIndex(c *C) {
config.UpdateGlobal(func(conf *config.Config) {
conf.Experimental.AllowsExpressionIndex = true
})
Expand Down Expand Up @@ -3205,7 +3209,7 @@ func (s *testIntegrationSuite3) TestUnsupportedPartitionManagementDDLs(c *C) {
c.Assert(err, ErrorMatches, ".*alter table partition is unsupported")
}

func (s *testIntegrationSuite7) TestCommitWhenSchemaChange(c *C) {
func (s *testSerialDBSuite1) TestCommitWhenSchemaChange(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec(`create table schema_change (a int, b timestamp)
Expand Down Expand Up @@ -3270,7 +3274,7 @@ func (s *testIntegrationSuite7) TestCommitWhenSchemaChange(c *C) {
tk.MustQuery("select * from nt").Check(testkit.Rows())
}

func (s *testIntegrationSuite7) TestCreatePartitionTableWithWrongType(c *C) {
func (s *testSerialDBSuite1) TestCreatePartitionTableWithWrongType(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
Expand Down Expand Up @@ -3311,7 +3315,7 @@ func (s *testIntegrationSuite7) TestCreatePartitionTableWithWrongType(c *C) {
c.Assert(err, NotNil)
}

func (s *testIntegrationSuite7) TestAddPartitionForTableWithWrongType(c *C) {
func (s *testSerialDBSuite1) TestAddPartitionForTableWithWrongType(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop tables if exists t_int, t_char, t_date")
Expand Down Expand Up @@ -3361,7 +3365,7 @@ func (s *testIntegrationSuite7) TestAddPartitionForTableWithWrongType(c *C) {
c.Assert(ddl.ErrWrongTypeColumnValue.Equal(err), IsTrue)
}

func (s *testIntegrationSuite7) TestPartitionListWithTimeType(c *C) {
func (s *testSerialDBSuite1) TestPartitionListWithTimeType(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustExec("use test;")
tk.MustExec("set @@session.tidb_enable_list_partition = ON")
Expand All @@ -3370,7 +3374,7 @@ func (s *testIntegrationSuite7) TestPartitionListWithTimeType(c *C) {
tk.MustQuery(`select * from t_list1 partition (p0);`).Check(testkit.Rows("2018-02-03"))
}

func (s *testIntegrationSuite7) TestPartitionListWithNewCollation(c *C) {
func (s *testSerialDBSuite1) TestPartitionListWithNewCollation(c *C) {
collate.SetNewCollationEnabledForTest(true)
defer collate.SetNewCollationEnabledForTest(false)
tk := testkit.NewTestKitWithInit(c, s.store)
Expand All @@ -3387,7 +3391,7 @@ func (s *testIntegrationSuite7) TestPartitionListWithNewCollation(c *C) {
c.Assert(strings.Contains(str, "partition:p0"), IsTrue)
}

func (s *testIntegrationSuite7) TestAddTableWithPartition(c *C) {
func (s *testSerialDBSuite1) TestAddTableWithPartition(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustExec("use test;")
tk.MustExec("drop table if exists global_partition_table;")
Expand Down
Loading